aboutsummaryrefslogtreecommitdiff
path: root/gsoap-palm/interop/src/interop2Ctest.cpp
blob: 5d943d52ed29d94a7c577f814b54e6c1e9801d97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
//===================================================================================
//
//    (C) COPYRIGHT International Business Machines Corp., 2002 All Rights Reserved
//    Licensed Materials - Property of IBM
//    US Government Users Restricted Rights - Use, duplication or
//    disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
//
//    IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
//    ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//    PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
//    CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
//    USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
//    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
//    OR PERFORMANCE OF THIS SOFTWARE.
//
//    The program may be used, executed, copied, modified, and distributed
//    without royalty for the purpose of developing, using, marketing, or distributing.
// 
//=======================================================================================
// gSOAP v2 Interop B test round 2
#include "soapH.h"
extern "C" void displayText(char *text);
extern "C" int interopC(const char *site);


struct Namespace namespacesC[] =
{ {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/"},
  {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/"},
  {"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance"},
  {"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema"},
  {"m", "http://soapinterop.org/"},
  {"s", "http://soapinterop.org/xsd"},
  {"a", "http://xml.apache.org/xml-soap"},
  {"h", "http://soapinterop.org/echoheader/"},
  {NULL, NULL}
};
int interopC(const char *url)
{ struct soap *soap;
  char *site=(char*)url;
  bool ok=true;
  xsd__int n = 42;
  float f  = 3.40282e+38;
  struct SOAP_ENV__Header h;
  struct m__echoVoidResponse r;
  struct s__SOAPStruct s;

  h.h__echoMeStringRequest = NULL;
  h.h__echoMeStringRequest_ = NULL;
  h.h__echoMeStringResponse = NULL;
  h.h__echoMeStructRequest = NULL;
  h.h__echoMeStructRequest_ = NULL;
  h.h__echoMeStructResponse = NULL;
  h.h__someUnknownRequest = NULL;
  h.h__someUnknownRequest_ = NULL;
  s.varString = "hello world";
  s.varInt = &n;
  s.varFloat = &f;


  displayText("running test C on");
  displayText((char*)url);
  soap = soap_new();
  soap->namespaces = (struct Namespace *)namespacesC;

  soap->send_timeout = 300;
  soap->recv_timeout = 300;

  // request from client (with mustUnderstand="0", recipient is target)
  h.h__echoMeStringRequest = "hello world";
  soap->header = &h;
  soap->actor = "http://schemas.xmlsoap.org/soap/actor/next";
  if (soap_call_m__echoVoid(soap, site, "http://soapinterop.org/", r))
  { 
    displayText("echo1 failed");
    ok=false;
  }
  else
    displayText("echo1 passed");

  // request from client (with mustUnderstand="0", recipient is not target)
  soap->header = &h;
  soap->actor = "http://some/other/actor";
  if (soap_call_m__echoVoid(soap, site, "http://soapinterop.org/", r))
  { 
    displayText("echo2 failed");
    ok=false;
  }
  else
    displayText("echo2 passed");

  // request from client (with mustUnderstand="1", recipient is target)
  h.h__echoMeStringRequest = NULL;
  h.h__echoMeStructRequest_ = &s;
  soap->header = &h;
  soap->actor = "http://schemas.xmlsoap.org/soap/actor/next";
  if (soap_call_m__echoVoid(soap, site, "http://soapinterop.org/", r))
  { 
    displayText("echo3 failed");
    ok=false;
  }
  else
    displayText("echo3 passed");

  // request from client (with mustUnderstand="1", recipient is not target)
  soap->header = &h;
  soap->actor = "http://some/other/actor";
  if (soap_call_m__echoVoid(soap,site, "http://soapinterop.org/", r))
  { 
    displayText("echo4 failed");
    ok=false;
  }
  else if (soap->header && soap->header->h__echoMeStructResponse)
  { 
    displayText("echo4 should be no response header");
    ok=false;
   }
  else
    displayText("echo4 passed");

  // Unknown header element: request from client (with mustUnderstand="0", recipient is target)
  h.h__echoMeStructRequest_ = NULL;
  h.h__someUnknownRequest = "XYZ";
  soap->header = &h;
  soap->actor = "http://schemas.xmlsoap.org/soap/actor/next";
  if (soap_call_m__echoVoid(soap, site, "http://soapinterop.org/", r))
  { 
    displayText("echo5 failed");
    ok=false;
  }
  else
    displayText("echo5 passed");

  // Unknown header element: request from client (with mustUnderstand="1", recipient is target)
  h.h__someUnknownRequest = NULL;
  h.h__someUnknownRequest_ = "XYZ";
  soap->header = &h;
  soap->actor = "http://schemas.xmlsoap.org/soap/actor/next";
  if (soap_call_m__echoVoid(soap, site, "http://soapinterop.org/", r) != SOAP_MUSTUNDERSTAND)
  { 
    displayText("echo6 failed");
    ok=false;
  }
  else
    displayText("echo6 passed");

  // Unknown header element: request from client (with mustUnderstand="0", recipient is not target)
  h.h__someUnknownRequest_ = NULL;
  h.h__someUnknownRequest = "XYZ";
  soap->header = &h;
  soap->actor = "http://some/other/actor";
  if (soap_call_m__echoVoid(soap, site, "http://soapinterop.org/", r))
  { 
    displayText("echo7 failed");
    ok=false;
  }
  else
    displayText("echo7 passed");

  // Unknown header element: request from client (with mustUnderstand="1", recipient is not target)
  h.h__someUnknownRequest = NULL;
  h.h__someUnknownRequest_ = "XYZ";
  soap->header = &h;
  soap->actor = "http://some/other/actor";
  if (soap_call_m__echoVoid(soap, site, "http://soapinterop.org/", r))
  { 
    displayText("echo8 failed");
    ok=false;
  }
  else
    displayText("echo8 passed");

  soap_end(soap);
  if (ok)
  	displayText("All Passed");
  else
	  displayText("FAILURES");

  return 0;
}