1 /* 2 * EasySoap++ - A C++ library for SOAP (Simple Object Access Protocol) 3 * Copyright (C) 2001 David Crowley; SciTegic, Inc. 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public 16 * License along with this library; if not, write to the Free 17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 */ 19 20 #if !defined(AFX_USERLANDVALIDATORHANDLER_H__D2938615_0A93_4675_9446_13E981BEF182__INCLUDED_) 21 #define AFX_USERLANDVALIDATORHANDLER_H__D2938615_0A93_4675_9446_13E981BEF182__INCLUDED_ 22 23 #include <easysoap/SOAP.h> 24 #include <easysoap/SOAPDispatchHandler.h> 25 26 USING_EASYSOAP_NAMESPACE 27 28 class UserlandValidatorHandler : 29 public SOAPDispatchHandler<UserlandValidatorHandler> 30 { 31 public: UserlandValidatorHandler()32 UserlandValidatorHandler() 33 { 34 DispatchMethod("countTheEntities", &UserlandValidatorHandler::countTheEntities); 35 DispatchMethod("easyStructTest", &UserlandValidatorHandler::easyStructTest); 36 DispatchMethod("echoStructTest", &UserlandValidatorHandler::echoStructTest); 37 DispatchMethod("manyTypesTest", &UserlandValidatorHandler::manyTypesTest); 38 DispatchMethod("moderateSizeArrayCheck",&UserlandValidatorHandler::moderateSizeArrayCheck); 39 DispatchMethod("nestedStructTest", &UserlandValidatorHandler::nestedStructTest); 40 DispatchMethod("simpleStructReturnTest",&UserlandValidatorHandler::simpleStructReturnTest); 41 } 42 GetTarget(const SOAPEnvelope &)43 UserlandValidatorHandler* GetTarget(const SOAPEnvelope&) 44 { 45 return this; 46 } 47 48 void countTheEntities(const SOAPMethod& req, SOAPMethod& resp); 49 void easyStructTest(const SOAPMethod& req, SOAPMethod& resp); 50 void echoStructTest(const SOAPMethod& req, SOAPMethod& resp); 51 void manyTypesTest(const SOAPMethod& req, SOAPMethod& resp); 52 void moderateSizeArrayCheck(const SOAPMethod& req, SOAPMethod& resp); 53 void nestedStructTest(const SOAPMethod& req, SOAPMethod& resp); 54 void simpleStructReturnTest(const SOAPMethod& req, SOAPMethod& resp); 55 56 57 // The first struct we have to handle 58 struct stooges 59 { 60 int larry; 61 int curly; 62 int moe; 63 }; 64 65 // struct we use for the echoStructTest 66 // It's just a bunch of stooges 67 struct echostruct 68 { 69 stooges substruct0; 70 stooges substruct1; 71 stooges substruct2; 72 stooges substruct3; 73 stooges substruct4; 74 stooges substruct5; 75 stooges substruct6; 76 stooges substruct7; 77 stooges substruct8; 78 stooges substruct9; 79 }; 80 }; 81 82 // how we de-serialize the stooges struct 83 inline const SOAPParameter& 84 operator>>(const SOAPParameter& param, UserlandValidatorHandler::stooges& st) 85 { 86 param.GetParameter("larry") >> st.larry; 87 param.GetParameter("curly") >> st.curly; 88 param.GetParameter("moe") >> st.moe; 89 return param; 90 } 91 92 // how we serialize ths stooges struct; 93 inline SOAPParameter& 94 operator<<(SOAPParameter& param, const UserlandValidatorHandler::stooges& st) 95 { 96 param.AddParameter("larry") << st.larry; 97 param.AddParameter("curly") << st.curly; 98 param.AddParameter("moe") << st.moe; 99 param.SetIsStruct(); 100 return param; 101 } 102 103 104 // how we de-serialze the echo struct. 105 // notice how easy it is with operator overloading :) 106 inline const SOAPParameter& 107 operator>>(const SOAPParameter& param, UserlandValidatorHandler::echostruct& st) 108 { 109 param.GetParameter("substruct0") >> st.substruct0; 110 param.GetParameter("substruct1") >> st.substruct1; 111 param.GetParameter("substruct2") >> st.substruct2; 112 param.GetParameter("substruct3") >> st.substruct3; 113 param.GetParameter("substruct4") >> st.substruct4; 114 param.GetParameter("substruct5") >> st.substruct5; 115 param.GetParameter("substruct6") >> st.substruct6; 116 param.GetParameter("substruct7") >> st.substruct7; 117 param.GetParameter("substruct8") >> st.substruct8; 118 param.GetParameter("substruct9") >> st.substruct9; 119 return param; 120 } 121 122 // and here we serialize it. It's so easy. 123 inline SOAPParameter& 124 operator<<(SOAPParameter& param, const UserlandValidatorHandler::echostruct& st) 125 { 126 param.AddParameter("substruct0") << st.substruct0; 127 param.AddParameter("substruct1") << st.substruct1; 128 param.AddParameter("substruct2") << st.substruct2; 129 param.AddParameter("substruct3") << st.substruct3; 130 param.AddParameter("substruct4") << st.substruct4; 131 param.AddParameter("substruct5") << st.substruct5; 132 param.AddParameter("substruct6") << st.substruct6; 133 param.AddParameter("substruct7") << st.substruct7; 134 param.AddParameter("substruct8") << st.substruct8; 135 param.AddParameter("substruct9") << st.substruct9; 136 param.SetIsStruct(); 137 return param; 138 } 139 140 #endif // !defined(AFX_USERLANDVALIDATORHANDLER_H__D2938615_0A93_4675_9446_13E981BEF182__INCLUDED_) 141 142 143 144