aboutsummaryrefslogtreecommitdiff
path: root/gsoap-palm/interop/src/interop2Btest.cpp
blob: 3e80fc66fa032ef9b689dba259b8934e90bb4db9 (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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
//===================================================================================
//
//    (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 interopB(const char *site);

int interopB(const char *url)
{
  struct soap *soap;
  char *site=(char*)url;
//  char* site ="http://websrv.cs.fsu.edu/~engelen/interop2B.cgi";
  char* action = "http://soapinterop.org/";
  
  bool ok=true;
  int i, g;
  xsd__string s = "Hello World! <>&";
  xsd__int n = 2147483647;
  xsd__float f = 3.40282e+38;
  struct ArrayOfstring a;
  struct ArrayOfstring2D aai;
  struct ArrayOfstring2D aao;

  struct s__SOAPStruct sti;
  struct ns__echoStructAsSimpleTypesResponse Ro;
  struct ns__echoSimpleTypesAsStructResponse Rsto;
  struct s__SOAPStructStruct ssti;
  struct ns__echoNestedStructResponse Rssto;
  struct s__SOAPArrayStruct sati;
  struct ns__echoNestedArrayResponse Rsato;

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

//  FILE *fd = fopen("interop2Bfaults.html", "a");

//  soap_init(&soap);

  soap->send_timeout = 30;
  soap->recv_timeout = 30;

  sti.varString = "Hello";
  sti.varInt = &n;
  sti.varFloat = &f;

  ssti.varString = "SOAP!";
  ssti.varInt = &n;
  ssti.varFloat = &f;
  ssti.varStruct = &sti;

  a.__size = 5;
  a.__offset = 2;
  a.__ptr = (char**)malloc(a.__size*sizeof(char*));
  a.__ptr[0] = "Interop";
  a.__ptr[1] = "Test";
  a.__ptr[2] = "Round";
  a.__ptr[3] = "2";
  a.__ptr[4] = a.__ptr[1];

  aai.__size[0] = 2;
  aai.__size[1] = 3;
  aai.__offset[0] = 0;
  aai.__offset[1] = 0;
  aai.__ptr = (char**)malloc(aai.__size[0]*aai.__size[1]*sizeof(char*));
  aai.__ptr[0] = "Interop Test";
  aai.__ptr[1] = NULL;
  aai.__ptr[2] = "Round";
  aai.__ptr[3] = "2";
  aai.__ptr[4] = a.__ptr[1];
  aai.__ptr[5] = NULL;

  sati.varString = a.__ptr[0];
  sati.varInt = &n;
  sati.varFloat = &f;
  sati.varArray = a;
   
  if (soap_call_ns__echoStructAsSimpleTypes(soap, site, "http://soapinterop.org/", sti, Ro))
  { 
    displayText("echoStructAsSimpleTypes failed");
    ok=false;
  }  else if (!Ro._outputString || strcmp(sti.varString, Ro._outputString) || !Ro._outputInteger || *sti.varInt != *Ro._outputInteger
  || !Ro._outputFloat || *sti.varFloat != *Ro._outputFloat)
  {
  	displayText("echoStructAsSimpleTypes mismatched");
    ok=false;
  }
  else
  	displayText("echoStructAsSimpleTypes passed");

  if (soap_call_ns__echoSimpleTypesAsStruct(soap, site, "http://soapinterop.org/", s, &n, &f, Rsto))
  { 
    displayText("echoSimpleTypesAsStruct failed");
    ok=false;
  }
  else if (!Rsto._return.varString || strcmp(s, Rsto._return.varString) || !Rsto._return.varInt || n != *Rsto._return.varInt || !Rsto._return.varFloat || f != *Rsto._return.varFloat)
  {
  	displayText("echoSimpleTypesAsStruct mismatched");
    ok=false;
  }
  else
  	displayText("echoSimpleTypesAsStruct passed");

  if (soap_call_ns__echo2DStringArray(soap,site, "http://soapinterop.org/", aai, aao))
  { 
    displayText("echo2DStringArray failed");
    ok=false;
  }
  else
  { g = 0;
    if (aai.__size[0] != aao.__size[0] || aai.__size[1] != aao.__size[1] || !aao.__ptr)
      g = 1;
    else
      for (i = 0; i < aai.__size[0]*aai.__size[1]; i++)
        if (aai.__ptr[i] && (!aao.__ptr[i] || strcmp(aai.__ptr[i], aao.__ptr[i])))
	  g = 1;
    if (g)
    {
    	displayText("echo2DStringArray mismatched");
    ok=false;
    }
    else
	  	displayText("echo2DStringArray passed");
  }

  if (soap_call_ns__echoNestedStruct(soap, site, "http://soapinterop.org/", ssti, Rssto))
  { 
    displayText("echoNestedStruct failed");
    ok=false;
  }
  else if (!Rssto._return.varString || strcmp(ssti.varString, Rssto._return.varString) ||
  !Rssto._return.varInt || *ssti.varInt != *Rssto._return.varInt ||
  !Rssto._return.varFloat || *ssti.varFloat != *Rssto._return.varFloat ||
  !Rssto._return.varStruct || 
  !Rssto._return.varStruct->varString || strcmp(ssti.varStruct->varString, Rssto._return.varStruct->varString) ||
  !Rssto._return.varStruct->varInt || *ssti.varStruct->varInt != *Rssto._return.varStruct->varInt || 
  !Rssto._return.varStruct->varFloat || *ssti.varStruct->varFloat != *Rssto._return.varStruct->varFloat)
    {
    	displayText("echoNestedStruct mismatched");
    ok=false;
  }
  else
  	displayText("echoNestedStruct passed");

  if (soap_call_ns__echoNestedArray(soap, site, "http://soapinterop.org/", sati, Rsato))
  { 
    displayText("echoNestedArray failed");
    ok=false;
  }
  else if (!Rsato._return.varString || strcmp(sati.varString, Rsato._return.varString) ||
  !Rsato._return.varInt || *sati.varInt != *Rsato._return.varInt ||
  !Rsato._return.varFloat || *sati.varFloat != *Rsato._return.varFloat ||
  sati.varArray.__size+sati.varArray.__offset != Rsato._return.varArray.__size+Rsato._return.varArray.__offset)
    {
    	displayText("echoNestedArray mismatched");
    ok=false;
  }
  else
  { g = 0;
    for (i = sati.varArray.__offset; i < sati.varArray.__size+sati.varArray.__offset; i++)
      if (!Rsato._return.varArray.__ptr[i-Rsato._return.varArray.__offset] ||
          strcmp(sati.varArray.__ptr[i-sati.varArray.__offset], Rsato._return.varArray.__ptr[i-Rsato._return.varArray.__offset]))
          g = 1;
    if (g)
    {
    	displayText("echoNestedArray mismatched");
	    ok=false;
    }
    else
	  	displayText("echoNestedArray passed");
  }

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

  return 0;
}

static struct Namespace namespaces[] =
{
  {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/"},
  {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/"},
  //{"SOAP-ENV", "http://www.w3.org/2002/06/soap-envelope"},	// SOAP 1.2
  //{"SOAP-ENC", "http://www.w3.org/2002/06/soap-encoding"},	// SOAP 1.2
  {"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"},
  {"ns", "http://soapinterop.org/"},
  {"s", "http://soapinterop.org/xsd"},
  {NULL, NULL}
};