~ifolder-dev/simias/trunk-packaging

« back to all changes in this revision

Viewing changes to tools/gsoap/gsoap-linux-2.7/gsoap-symbian/.svn/text-base/interop2test.cpp.svn-base

  • Committer: Jorge O. Castro
  • Date: 2007-12-03 06:56:46 UTC
  • Revision ID: jorge@ubuntu.com-20071203065646-mupcnjcwgm5mnhyt
* Remove a bunch of .svn directories we no longer need.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//===================================================================================
2
 
//
3
 
//    (C) COPYRIGHT International Business Machines Corp., 2002 All Rights Reserved
4
 
//    Licensed Materials - Property of IBM
5
 
//    US Government Users Restricted Rights - Use, duplication or
6
 
//    disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
7
 
//
8
 
//    IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
9
 
//    ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
10
 
//    PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
11
 
//    CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
12
 
//    USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
 
//    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
14
 
//    OR PERFORMANCE OF THIS SOFTWARE.
15
 
//
16
 
//    The program may be used, executed, copied, modified, and distributed
17
 
//    without royalty for the purpose of developing, using, marketing, or distributing.
18
 
// 
19
 
//=======================================================================================
20
 
// gSOAP v2 Interop test round 2 base
21
 
//#include "interoptA.h"
22
 
#include "soapH.h" 
23
 
 
24
 
extern "C" void displayText(char *text);
25
 
extern "C" int interopA(const char *url);
26
 
 
27
 
struct Namespace namespacesA[] =
28
 
{ {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/"},
29
 
  {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/"},
30
 
  {"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance"},
31
 
  {"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema"},
32
 
  {"ns", "http://soapinterop.org/"},
33
 
  {"s", "http://soapinterop.org/xsd"},
34
 
  {"a", "http://xml.apache.org/xml-soap"},
35
 
  {"h", "http://soapinterop.org/echoheader/"},
36
 
  {NULL, NULL}
37
 
};
38
 
 
39
 
int interopA(const char *url)
40
 
41
 
  struct soap *soap;
42
 
  int i, g;
43
 
  xsd__string so, si = "Hello World! <>&";
44
 
  struct ArrayOfstring Asi, Aso;
45
 
  xsd__int no, ni = 1234567890;
46
 
  xsd__int n = 2147483647;
47
 
  struct ArrayOfint Ani, Ano;
48
 
//  xsd__float f1 = 3.40282e+38;
49
 
  xsd__float f1 = 123.5678;
50
 
  xsd__float f2 = 3.14;
51
 
  xsd__float fo, fi = 123.456;
52
 
//  xsd__float fo, fi = 3e2;
53
 
//#ifdef SYMBIAN
54
 
//  const struct soap_double_nan { unsigned int n1, n2; } soap_double_nan;
55
 
//#endif
56
 
  xsd__float nan = FLT_NAN, inf = FLT_PINFTY, ninf = FLT_NINFTY;
57
 
  struct ArrayOffloat Afi, Afo;
58
 
  struct s__SOAPStruct sti, *p;
59
 
  struct ns__echoStructResponse sto;
60
 
  struct ArrayOfSOAPStruct Asti, Asto;
61
 
  struct ns__echoVoidResponse Rv;
62
 
  struct xsd__base64Binary b64i, b64o;
63
 
  xsd__dateTime dto, dti = "1967-12-29T01:02:03";
64
 
  struct xsd__hexBinary hbi, hbo;
65
 
  xsd__decimal Do, Di = "1234567890.123456789";
66
 
  xsd__boolean bo, bi = true;
67
 
  //struct a__Map mi, mo;
68
 
  //struct ArrayOfMap Ami, Amo;
69
 
  // char buff[100];
70
 
  displayText("running test A on");
71
 
  displayText((char*)url);
72
 
  soap = soap_new();
73
 
  soap->namespaces = (struct Namespace *)namespacesA;
74
 
 
75
 
//  soap.send_timeout = 30;
76
 
//  soap.recv_timeout = 30;
77
 
 
78
 
 
79
 
  Asi.__size = 8;
80
 
  Asi.__offset = 0;
81
 
  Asi.__ptr = (xsd__string*)malloc(Asi.__size*sizeof(xsd__string));
82
 
  Asi.__ptr[0] = NULL;
83
 
  Asi.__ptr[1] = " Hello\tWorld";
84
 
  Asi.__ptr[2] = NULL;
85
 
  Asi.__ptr[3] = "! ";
86
 
  Asi.__ptr[4] = NULL;
87
 
  Asi.__ptr[5] = si;
88
 
  Asi.__ptr[6] = NULL;
89
 
  Asi.__ptr[7] = si;
90
 
 
91
 
  Ani.__size = 0;
92
 
  Ani.__offset = 0;
93
 
  Ani.__ptr = NULL; // (xsd__int*)malloc(Ani.__size*sizeof(xsd__int));
94
 
 
95
 
  Afi.__size = 5;
96
 
  Afi.__offset = 0;
97
 
  Afi.__ptr = (xsd__float**)malloc(Afi.__size*sizeof(xsd__float*));
98
 
  Afi.__ptr[0] = &f1;
99
 
  Afi.__ptr[1] = &nan; // FLT_NAN;
100
 
  Afi.__ptr[2] = &inf; // FLT_PINFTY;
101
 
  Afi.__ptr[3] = &ninf; // FLT_NINFTY;
102
 
  Afi.__ptr[4] = &f2;
103
 
 
104
 
  sti.varString = "Hello";
105
 
  sti.varInt = &n;
106
 
  sti.varFloat = &f1;
107
 
 
108
 
  Asti.__size = 3;
109
 
  Asti.__offset = 2;
110
 
  Asti.__ptr = (struct s__SOAPStruct**)malloc((Asti.__size+1)*sizeof(struct s__SOAPStruct*));
111
 
  p = (struct s__SOAPStruct*)malloc(Asti.__size*sizeof(struct s__SOAPStruct));
112
 
  Asti.__ptr[0] = p;
113
 
  Asti.__ptr[1] = p+1;
114
 
  Asti.__ptr[2] = p+2;
115
 
  Asti.__ptr[3] = p;
116
 
  Asti.__ptr[0]->varString = "Hello";
117
 
  Asti.__ptr[0]->varInt = &n;
118
 
  Asti.__ptr[0]->varFloat = &f1;
119
 
  Asti.__ptr[1]->varString = "World";
120
 
  Asti.__ptr[1]->varInt = &n;
121
 
  Asti.__ptr[1]->varFloat = &f2;
122
 
  Asti.__ptr[2]->varString = "!";
123
 
  Asti.__ptr[2]->varInt = &n;
124
 
  Asti.__ptr[2]->varFloat = &f2;
125
 
 
126
 
//  b64i.__ptr = (unsigned char*)"This is an example Base64 encoded string";
127
 
//  b64i.__size = strlen((char*)b64i.__ptr)+1;
128
 
  unsigned char b64data[4]={0x80, 0x81, 0x82, 0x83};
129
 
  b64i.__ptr = b64data;
130
 
  b64i.__size = 4;
131
 
 
132
 
  hbi.__ptr = (unsigned char*)"This is an example HexBinary encoded string";
133
 
  hbi.__size = strlen((char*)hbi.__ptr)+1;
134
 
/*
135
 
  mi.__size = 2;
136
 
  mi.__ptr = (struct _item*)malloc(mi.__size*sizeof(struct _item));
137
 
  mi.__ptr[0].key = new xsd__string_("hello");
138
 
  mi.__ptr[0].value = new xsd__string_("world");
139
 
  mi.__ptr[1].key = new xsd__int_(2);
140
 
  mi.__ptr[1].value = new xsd__boolean_(true);
141
 
 
142
 
  Ami.__size = 2;
143
 
  Ami.__ptr = (struct a__Map**)malloc(Ami.__size*sizeof(struct a__Map*));
144
 
  Ami.__ptr[0] = &mi;
145
 
  Ami.__ptr[1] = &mi; */
146
 
  char *site=(char*)url;
147
 
//    char* site ="http://websrv.cs.fsu.edu/~engelen/interop2.cgi";
148
 
//  char* site = "http://nagoya.apache.org:5049/axis/services/echo ";
149
 
  char* action = "http://soapinterop.org/";
150
 
  
151
 
  bool ok=true;
152
 
  
153
 
  if (soap_call_ns__echoString(soap, site, action, si, so))
154
 
  { 
155
 
    displayText("echoString fail");
156
 
    ok=false;
157
 
  }
158
 
  else if (!so || strcmp(si, so))
159
 
  { 
160
 
    ok=false;
161
 
    displayText("echoString mismatched");
162
 
  }
163
 
  else
164
 
    displayText("echoString pass");
165
 
 
166
 
 
167
 
  if (soap_call_ns__echoInteger(soap, site, "http://soapinterop.org/", ni, no))
168
 
  { 
169
 
    ok=false;
170
 
    displayText("echoInteger fail");
171
 
  }
172
 
  else if (ni != no)
173
 
  {  
174
 
    ok=false;
175
 
    displayText("echoInteger mismatched");
176
 
  }
177
 
  else
178
 
    displayText("echoInteger pass");
179
 
 
180
 
  if (soap_call_ns__echoFloat(soap, site, "http://soapinterop.org/", fi, fo))
181
 
  { 
182
 
    ok=false;
183
 
    displayText("echoFloat fail");
184
 
  }
185
 
  else if (fi != fo)
186
 
  {  
187
 
    ok=false;
188
 
    displayText("echoFloat mismatched");
189
 
  }
190
 
  else
191
 
    displayText("echoFloat pass");
192
 
 
193
 
  if (soap_call_ns__echoStruct(soap, site, "http://soapinterop.org/", sti, sto))
194
 
  { 
195
 
    ok=false;
196
 
  displayText("echoStruct fail");
197
 
  }
198
 
  else if (!sto._return.varString || strcmp(sti.varString, sto._return.varString)
199
 
         || !sto._return.varInt || *sti.varInt != *sto._return.varInt 
200
 
         || !sto._return.varFloat || *sti.varFloat != *sto._return.varFloat)
201
 
  { 
202
 
    ok=false;
203
 
          displayText("echoStruct mismatch");
204
 
  }
205
 
  else 
206
 
    displayText("echoStruct pass");
207
 
 
208
 
  if (soap_call_ns__echoStringArray(soap, site, "http://soapinterop.org/", Asi, Aso))
209
 
  {
210
 
     soap_set_fault(soap); 
211
 
    soap_faultdetail(soap);
212
 
    ok=false;
213
 
  displayText("echoStringArray fail");
214
 
  }
215
 
  else
216
 
  { g = 0;
217
 
    if (Asi.__size != Aso.__size)
218
 
      g = 1;
219
 
    else
220
 
      for (i = 0; i < Asi.__size; i++)
221
 
        if (Asi.__ptr[i] && Aso.__ptr[i] && strcmp(Asi.__ptr[i], Aso.__ptr[i]))
222
 
          g = 1;
223
 
        else if (!Asi.__ptr[i])
224
 
          ;
225
 
        else if (Asi.__ptr[i] && !Aso.__ptr[i])
226
 
          g = 1;
227
 
    if (g)
228
 
    {
229
 
    ok=false;
230
 
    displayText("echoStringArray mismatch"); 
231
 
    }
232
 
    else
233
 
     displayText("echoStringArray pass");
234
 
  }
235
 
 
236
 
  if (soap_call_ns__echoIntegerArray(soap, site, "http://soapinterop.org/", Ani, Ano))
237
 
  { displayText("echoIntegerArray fail");
238
 
    ok=false;
239
 
  }
240
 
  else
241
 
  { g = 0;
242
 
    if (Ani.__size != Ano.__size)
243
 
      g = 1;
244
 
    else
245
 
      for (i = 0; i < Ani.__size; i++)
246
 
        if (Ani.__ptr[i] && (!Ano.__ptr[i] || *Ani.__ptr[i] != *Ano.__ptr[i]))
247
 
          g = 1;
248
 
    if (g)
249
 
    { displayText("echoIntegerArray mismatch");
250
 
    ok=false;
251
 
    }
252
 
    else
253
 
      displayText("echoIntegerArray pass");
254
 
  }
255
 
 
256
 
  if (soap_call_ns__echoFloatArray(soap, site, "http://soapinterop.org/", Afi, Afo))
257
 
  { displayText("echoFloatArray fail");
258
 
    ok=false;
259
 
  }
260
 
  else
261
 
  { g = 0;
262
 
    if (Afi.__size != Afo.__size)
263
 
      g = 1;
264
 
    else
265
 
      for (i = 0; i < Afi.__size; i++)
266
 
        if (Afi.__ptr[i] && Afo.__ptr[i] && soap_isnan(*Afi.__ptr[i]) && soap_isnan(*Afo.__ptr[i]))
267
 
          ;
268
 
        else if (Afi.__ptr[i] && (!Afo.__ptr[i] || *Afi.__ptr[i] != *Afo.__ptr[i]))
269
 
          g = 1;
270
 
    if (g)
271
 
    { displayText("echoFloatArray mismatch");
272
 
    ok=false;
273
 
    }
274
 
    else
275
 
     displayText("echoFloatArray pass");
276
 
  }
277
 
 
278
 
  if (soap_call_ns__echoStructArray(soap, site, "http://soapinterop.org/", Asti, Asto))
279
 
  { displayText("echoStructArray fail");
280
 
    ok=false;
281
 
  }
282
 
  else
283
 
  { g = 0;
284
 
    if (Asti.__size+Asti.__offset != Asto.__size+Asto.__offset)
285
 
      g = 1;
286
 
    else
287
 
      for (i = Asti.__offset; i < Asti.__size+Asti.__offset; i++)
288
 
        if (!Asto.__ptr[i-Asto.__offset] ||
289
 
        !Asto.__ptr[i-Asto.__offset]->varString ||
290
 
        strcmp(Asti.__ptr[i-Asti.__offset]->varString, Asto.__ptr[i-Asto.__offset]->varString) ||
291
 
        !Asto.__ptr[i-Asto.__offset]->varInt ||
292
 
        *Asti.__ptr[i-Asti.__offset]->varInt != *Asto.__ptr[i-Asto.__offset]->varInt ||
293
 
        !Asto.__ptr[i-Asto.__offset]->varFloat ||
294
 
        *Asti.__ptr[i-Asti.__offset]->varFloat != *Asto.__ptr[i-Asto.__offset]->varFloat)
295
 
          g = 1;
296
 
    if (g)
297
 
    { displayText("echoStructArray mismatch");
298
 
    ok=false;
299
 
    }
300
 
    else
301
 
      displayText("echoStructArray pass");
302
 
  }
303
 
 
304
 
  if (soap_call_ns__echoVoid(soap, site, "http://soapinterop.org/", Rv))
305
 
  { displayText("echoVoid fail");
306
 
    ok=false;
307
 
  }
308
 
  else
309
 
    displayText("echoVoid pass");
310
 
  
311
 
 
312
 
  if (soap_call_ns__echoBase64(soap, site, "http://soapinterop.org/", b64i, b64o))
313
 
  { displayText("echoBase64 fail");
314
 
    ok=false;
315
 
  }
316
 
  else if ((b64i.__size+2)/3 != (b64o.__size+2)/3 || strncmp((char*)b64i.__ptr, (char*)b64o.__ptr,b64i.__size))
317
 
  { 
318
 
  displayText("echoBase64 mismatch");
319
 
    ok=false;
320
 
  }
321
 
  else
322
 
   displayText("echoBase64 pass");
323
 
 
324
 
  if (soap_call_ns__echoDate(soap, site, "http://soapinterop.org/", dti, dto))
325
 
  { 
326
 
  displayText("echoDate fail");
327
 
    ok=false;
328
 
  }
329
 
  else if (!dto || strncmp(dti, dto, 19))
330
 
  { 
331
 
  displayText("echoDate mismatch");
332
 
    ok=false;
333
 
  }
334
 
  else
335
 
    displayText("echoDate pass");
336
 
 
337
 
 
338
 
  if (soap_call_ns__echoHexBinary(soap, site, "http://soapinterop.org/", hbi, hbo))
339
 
  { 
340
 
    ok=false;
341
 
  displayText("echoHexBinary fail");
342
 
  }
343
 
  else if (hbi.__size != hbo.__size || strcmp((char*)hbi.__ptr, (char*)hbo.__ptr))
344
 
  { 
345
 
    ok=false;
346
 
  displayText("echoHexBinary mismatch");
347
 
  }
348
 
  else
349
 
    displayText("echoHexBinary pass");
350
 
 
351
 
 
352
 
  if (soap_call_ns__echoDecimal(soap, site, "http://soapinterop.org/", Di, Do))
353
 
  { 
354
 
    ok=false;
355
 
  displayText("echoDecimal pass");
356
 
  }
357
 
  else if (strcmp(Di, Do))
358
 
  { 
359
 
    ok=false;
360
 
  displayText("echoDecimal mismatch");
361
 
  }
362
 
  else
363
 
    displayText("echoDecimal pass");
364
 
  
365
 
 
366
 
  if (soap_call_ns__echoBoolean(soap, site, "http://soapinterop.org/", bi, bo))
367
 
  { 
368
 
    ok=false;
369
 
  displayText("echoBoolean fail");
370
 
  }
371
 
  else if (bi != bo)
372
 
  { 
373
 
    ok=false;
374
 
  displayText("echoBoolean mismatch");
375
 
  }
376
 
  else
377
 
    displayText("echoBoolean pass");
378
 
 
379
 
  if (ok)
380
 
    displayText("ALL PASS");
381
 
  else
382
 
    displayText("FAILURES");
383
 
  return 0;
384
 
  
385
 
end:
386
 
  return 1;
387
 
}
388