// gSOAP v2 Interop test round 2 base
#include "soapH.h"
int main(int argc, char **argv)
{ struct soap soap;
int i, g;
xsd__string so, si = "Hello World! <>&";
struct ArrayOfstring Asi, Aso;
xsd__int no, ni = 1234567890;
xsd__int n = 2147483647;
struct ArrayOfint Ani, Ano;
xsd__float f1 = 3.40282e+38;
xsd__float f2 = 3.14;
xsd__float fo, fi = 123.456;
xsd__float nan = FLT_NAN, inf = FLT_PINFTY, ninf = FLT_NINFTY;
struct ArrayOffloat Afi, Afo;
struct s__SOAPStruct sti, *p;
struct ns__echoStructResponse sto;
struct ArrayOfSOAPStruct Asti, Asto;
struct ns__echoVoidResponse Rv;
struct xsd__base64Binary b64i, b64o;
xsd__dateTime dto, dti = "1967-12-29T01:02:03";
struct xsd__hexBinary hbi, hbo;
xsd__decimal Do, Di = "1234567890.123456789";
xsd__boolean bo, bi = true;
struct a__Map mi, mo;
struct ArrayOfMap Ami, Amo;
FILE *fd = fopen("interop2faults.html", "a");
fprintf(fd, "");
soap_init(&soap);
soap.send_timeout = 30;
soap.recv_timeout = 30;
//soap.keep_alive = 1;
//soap.socket_flags = MSG_NOSIGNAL;
Asi.__size = 8;
Asi.__offset = 0;
Asi.__ptr = (xsd__string*)malloc(Asi.__size*sizeof(xsd__string));
Asi.__ptr[0] = NULL;
Asi.__ptr[1] = " Hello\tWorld";
Asi.__ptr[2] = NULL;
Asi.__ptr[3] = "! ";
Asi.__ptr[4] = NULL;
Asi.__ptr[5] = si;
Asi.__ptr[6] = NULL;
Asi.__ptr[7] = si;
Ani.__size = 0;
Ani.__offset = 0;
Ani.__ptr = NULL; // (xsd__int*)malloc(Ani.__size*sizeof(xsd__int));
Afi.__size = 5;
Afi.__offset = 0;
Afi.__ptr = (xsd__float**)malloc(Afi.__size*sizeof(xsd__float*));
Afi.__ptr[0] = &f1;
Afi.__ptr[1] = &nan; // FLT_NAN;
Afi.__ptr[2] = &inf; // FLT_PINFTY;
Afi.__ptr[3] = &ninf; // FLT_NINFTY;
Afi.__ptr[4] = &f2;
sti.varString = "Hello";
sti.varInt = &n;
sti.varFloat = &f1;
Asti.__size = 3;
Asti.__offset = 2;
Asti.__ptr = (struct s__SOAPStruct**)malloc((Asti.__size+1)*sizeof(struct s__SOAPStruct*));
p = (struct s__SOAPStruct*)malloc(Asti.__size*sizeof(struct s__SOAPStruct));
Asti.__ptr[0] = p;
Asti.__ptr[1] = p+1;
Asti.__ptr[2] = p+2;
Asti.__ptr[3] = p;
Asti.__ptr[0]->varString = "Hello";
Asti.__ptr[0]->varInt = &n;
Asti.__ptr[0]->varFloat = &f1;
Asti.__ptr[1]->varString = "World";
Asti.__ptr[1]->varInt = &n;
Asti.__ptr[1]->varFloat = &f2;
Asti.__ptr[2]->varString = "!";
Asti.__ptr[2]->varInt = &n;
Asti.__ptr[2]->varFloat = &f2;
b64i.__ptr = (unsigned char*)"This is an example Base64 encoded string";
b64i.__size = strlen((char*)b64i.__ptr)+1;
hbi.__ptr = (unsigned char*)"This is an example HexBinary encoded string";
hbi.__size = strlen((char*)hbi.__ptr)+1;
mi.__size = 2;
mi.__ptr = (struct _item*)malloc(mi.__size*sizeof(struct _item));
mi.__ptr[0].key = new xsd__string_("hello");
mi.__ptr[0].value = new xsd__string_("world");
mi.__ptr[1].key = new xsd__int_(2);
mi.__ptr[1].value = new xsd__boolean_(true);
Ami.__size = 2;
Ami.__ptr = (struct a__Map**)malloc(Ami.__size*sizeof(struct a__Map*));
Ami.__ptr[0] = &mi;
Ami.__ptr[1] = &mi;
if (argc < 2)
return -1;
if (soap_call_ns__echoString(&soap, argv[1], "http://soapinterop.org/", si, so))
{ printf("
FAULT | \n", argv[1]);
fprintf(fd, "", argv[1]);
soap_print_fault(&soap, fd);
soap_print_fault_location(&soap, fd);
fprintf(fd, "
");
}
else if (!so || strcmp(si, so))
{ printf("FAIL | \n", argv[1]);
fprintf(fd, "Strings differ. Input:%s
Response:%s
", argv[1], si, so);
}
else
printf("PASS | \n");
fflush(stdout);
if (soap_call_ns__echoInteger(&soap, argv[1], "http://soapinterop.org/", ni, no))
{ printf("FAULT | \n", argv[1]);
fprintf(fd, "", argv[1]);
soap_print_fault(&soap, fd);
soap_print_fault_location(&soap, fd);
fprintf(fd, "
");
}
else if (ni != no)
{ printf("FAIL | \n", argv[1]);
fprintf(fd, "Integers differ:%d
%d
", argv[1], ni, no);
}
else
printf("PASS | \n");
fflush(stdout);
if (soap_call_ns__echoFloat(&soap, argv[1], "http://soapinterop.org/", fi, fo))
{ printf("FAULT | \n", argv[1]);
fprintf(fd, "", argv[1]);
soap_print_fault(&soap, fd);
soap_print_fault_location(&soap, fd);
fprintf(fd, "
");
}
else if (ni != no)
{ printf("FAIL | \n", argv[1]);
fprintf(fd, "Floats differ. Input:%.7G
Response:%.7G
", argv[1], fi, fo);
}
else
printf("PASS | \n");
fflush(stdout);
if (soap_call_ns__echoStruct(&soap, argv[1], "http://soapinterop.org/", sti, sto))
{ printf("FAULT | \n", argv[1]);
fprintf(fd, "", argv[1]);
soap_print_fault(&soap, fd);
soap_print_fault_location(&soap, fd);
fprintf(fd, "
");
}
else if (!sto._return.varString || strcmp(sti.varString, sto._return.varString) || !sto._return.varInt || *sti.varInt != *sto._return.varInt || !sto._return.varFloat || *sti.varFloat != *sto._return.varFloat)
{ printf("FAIL | \n", argv[1]);
fprintf(fd, "Structs differ. Input:%s\n%d\n%.7G
Response:%s\n%d\n%.7G
", argv[1], sti.varString, *sti.varInt, *sti.varFloat, sto._return.varString, *sto._return.varInt, *sto._return.varFloat);
}
else
printf("PASS | \n");
fflush(stdout);
if (soap_call_ns__echoStringArray(&soap, argv[1], "http://soapinterop.org/", Asi, Aso))
{ printf("FAULT | \n", argv[1]);
fprintf(fd, "", argv[1]);
soap_print_fault(&soap, fd);
soap_print_fault_location(&soap, fd);
fprintf(fd, "
");
}
else
{ g = 0;
if (Asi.__size != Aso.__size)
g = 1;
else
for (i = 0; i < Asi.__size; i++)
if (Asi.__ptr[i] && Aso.__ptr[i] && strcmp(Asi.__ptr[i], Aso.__ptr[i]))
g = 1;
else if (!Asi.__ptr[i])
;
else if (Asi.__ptr[i] && !Aso.__ptr[i])
g = 1;
if (g)
{ printf("FAIL | \n", argv[1]);
fprintf(fd, "String arrays differ. Input:", argv[1]);
for (i = 0; i < Asi.__size; i++)
fprintf(fd, "%s\n", Asi.__ptr[i]);
fprintf(fd, "
Response:");
for (i = 0; i < Aso.__size; i++)
fprintf(fd, "%s\n", Aso.__ptr[i]);
fprintf(fd, "
");
}
else
printf("PASS | \n");
}
if (soap_call_ns__echoIntegerArray(&soap, argv[1], "http://soapinterop.org/", Ani, Ano))
{ printf("FAULT | \n", argv[1]);
fprintf(fd, "", argv[1]);
soap_print_fault(&soap, fd);
soap_print_fault_location(&soap, fd);
fprintf(fd, "
");
}
else
{ g = 0;
if (Ani.__size != Ano.__size)
g = 1;
else
for (i = 0; i < Ani.__size; i++)
if (Ani.__ptr[i] && (!Ano.__ptr[i] || *Ani.__ptr[i] != *Ano.__ptr[i]))
g = 1;
if (g)
{ printf("FAIL | \n", argv[1]);
fprintf(fd, "Integer arrays differ. Input:", argv[1]);
for (i = 0; i < Ani.__size; i++)
fprintf(fd, "%d\n", Ani.__ptr[i]?*Ani.__ptr[i]:0);
fprintf(fd, "
Response:");
for (i = 0; i < Ano.__size; i++)
fprintf(fd, "%d\n", Ano.__ptr[i]?*Ano.__ptr[i]:0);
fprintf(fd, "
");
}
else
printf("PASS | \n");
}
if (soap_call_ns__echoFloatArray(&soap, argv[1], "http://soapinterop.org/", Afi, Afo))
{ printf("FAULT | \n", argv[1]);
fprintf(fd, "", argv[1]);
soap_print_fault(&soap, fd);
soap_print_fault_location(&soap, fd);
fprintf(fd, "
");
}
else
{ g = 0;
if (Afi.__size != Afo.__size)
g = 1;
else
for (i = 0; i < Afi.__size; i++)
if (Afi.__ptr[i] && Afo.__ptr[i] && isnan(*Afi.__ptr[i]) && isnan(*Afo.__ptr[i]))
;
else if (Afi.__ptr[i] && (!Afo.__ptr[i] || *Afi.__ptr[i] != *Afo.__ptr[i]))
g = 1;
if (g)
{ printf("FAIL | \n", argv[1]);
fprintf(fd, "Float arrays differ. Input:", argv[1]);
for (i = 0; i < Afi.__size; i++)
if (Afi.__ptr[i])
fprintf(fd, "%.7G\n", *Afi.__ptr[i]);
else
fprintf(fd, "NIL\n");
fprintf(fd, "
Response:");
for (i = 0; i < Afo.__size; i++)
if (Afo.__ptr[i])
fprintf(fd, "%.7G\n", *Afo.__ptr[i]);
else
fprintf(fd, "NIL\n");
fprintf(fd, "
");
}
else
printf("PASS | \n");
}
if (soap_call_ns__echoStructArray(&soap, argv[1], "http://soapinterop.org/", Asti, Asto))
{ printf("FAULT | \n", argv[1]);
fprintf(fd, "", argv[1]);
soap_print_fault(&soap, fd);
soap_print_fault_location(&soap, fd);
fprintf(fd, "
");
}
else
{ g = 0;
if (Asti.__size+Asti.__offset != Asto.__size+Asto.__offset)
g = 1;
else
for (i = Asti.__offset; i < Asti.__size+Asti.__offset; i++)
if (!Asto.__ptr[i-Asto.__offset] ||
!Asto.__ptr[i-Asto.__offset]->varString ||
strcmp(Asti.__ptr[i-Asti.__offset]->varString, Asto.__ptr[i-Asto.__offset]->varString) ||
!Asto.__ptr[i-Asto.__offset]->varInt ||
*Asti.__ptr[i-Asti.__offset]->varInt != *Asto.__ptr[i-Asto.__offset]->varInt ||
!Asto.__ptr[i-Asto.__offset]->varFloat ||
*Asti.__ptr[i-Asti.__offset]->varFloat != *Asto.__ptr[i-Asto.__offset]->varFloat)
g = 1;
if (g)
{ printf("FAIL | \n", argv[1]);
fprintf(fd, "Struct arrays differ. Input:", argv[1]);
for (i = 0; i < Asti.__size; i++)
fprintf(fd, "%s %d %.7G\n", Asti.__ptr[i]->varString, *Asti.__ptr[i]->varInt, *Asti.__ptr[i]->varFloat);
fprintf(fd, "
Response:");
for (i = 0; i < Asto.__size; i++)
if (Asto.__ptr[i])
fprintf(fd, "%s %d %.7G\n", Asto.__ptr[i]->varString?Asto.__ptr[i]->varString:"", Asto.__ptr[i]->varInt?*Asto.__ptr[i]->varInt:0, Asto.__ptr[i]->varFloat?*Asto.__ptr[i]->varFloat:0);
else
fprintf(fd, "nil\n");
fprintf(fd, "
");
}
else
printf("PASS | \n");
}
if (soap_call_ns__echoVoid(&soap, argv[1], "http://soapinterop.org/", Rv))
{ printf("FAULT | \n", argv[1]);
fprintf(fd, "", argv[1]);
soap_print_fault(&soap, fd);
soap_print_fault_location(&soap, fd);
fprintf(fd, "
");
}
else
printf("PASS | \n");
fflush(stdout);
if (soap_call_ns__echoBase64(&soap, argv[1], "http://soapinterop.org/", b64i, b64o))
{ printf("FAULT | \n", argv[1]);
fprintf(fd, "", argv[1]);
soap_print_fault(&soap, fd);
soap_print_fault_location(&soap, fd);
fprintf(fd, "
");
}
else if ((b64i.__size+2)/3 != (b64o.__size+2)/3 || strcmp((char*)b64i.__ptr, (char*)b64o.__ptr))
{ printf("FAIL | \n", argv[1]);
fprintf(fd, "Base64 differ. Input:%s
Response:%s
", argv[1], b64i.__ptr, b64o.__ptr);
}
else
printf("PASS | \n");
fflush(stdout);
if (soap_call_ns__echoDate(&soap, argv[1], "http://soapinterop.org/", dti, dto))
{ printf("FAULT | \n", argv[1]);
fprintf(fd, "", argv[1]);
soap_print_fault(&soap, fd);
soap_print_fault_location(&soap, fd);
fprintf(fd, "
");
}
else if (!dto || strncmp(dti, dto, 19))
{ printf("FAIL | \n", argv[1]);
fprintf(fd, "Date differ. Input:%s
Response:%s
", argv[1], dti, dto);
}
else
printf("PASS | \n");
fflush(stdout);
if (soap_call_ns__echoHexBinary(&soap, argv[1], "http://soapinterop.org/", hbi, hbo))
{ printf("FAULT | \n", argv[1]);
fprintf(fd, "", argv[1]);
soap_print_fault(&soap, fd);
soap_print_fault_location(&soap, fd);
fprintf(fd, "
");
}
else if (hbi.__size != hbo.__size || strcmp((char*)hbi.__ptr, (char*)hbo.__ptr))
{ printf("FAIL | \n", argv[1]);
fprintf(fd, "HexBinary differ. Input:%s
Response:%s
", argv[1], hbi.__ptr, hbo.__ptr);
}
else
printf("PASS | \n");
fflush(stdout);
if (soap_call_ns__echoDecimal(&soap, argv[1], "http://soapinterop.org/", Di, Do))
{ printf("FAULT | \n", argv[1]);
fprintf(fd, "", argv[1]);
soap_print_fault(&soap, fd);
soap_print_fault_location(&soap, fd);
fprintf(fd, "
");
}
else if (strcmp(Di, Do))
{ printf("FAIL | \n", argv[1]);
fprintf(fd, "Decimal differ. Input:%s
Response:%s
", argv[1], Di, Do);
}
else
printf("PASS | \n");
fflush(stdout);
if (soap_call_ns__echoBoolean(&soap, argv[1], "http://soapinterop.org/", bi, bo))
{ printf("FAULT | \n", argv[1]);
fprintf(fd, "", argv[1]);
soap_print_fault(&soap, fd);
soap_print_fault_location(&soap, fd);
fprintf(fd, "
");
}
else if (bi != bo)
{ printf("FAIL | \n", argv[1]);
fprintf(fd, "Boolean differ. Input:%d
Response:%d
", argv[1], (int)bi, (int)bo);
}
else
printf("PASS | \n");
fflush(stdout);
if (argc == 3)
{
if (soap_call_ns__echoMap(&soap, argv[1], "http://soapinterop.org/", mi, mo))
{ printf("FAULT | \n", argv[1]);
fprintf(fd, "", argv[1]);
soap_print_fault(&soap, fd);
soap_print_fault_location(&soap, fd);
fprintf(fd, "
");
}
else
{ g = 0;
if (mi.__size != mo.__size || !mo.__ptr)
g = 1;
else
{ for (i = 0; i < mi.__size; i++)
; // need to check values here!
}
if (g)
{ printf("FAIL | \n", argv[1]);
fprintf(fd, "Maps differ.
", argv[1]);
}
else
printf("PASS | \n");
}
if (soap_call_ns__echoMapArray(&soap, argv[1], "http://soapinterop.org/", Ami, Amo))
{ printf("FAULT | \n", argv[1]);
fprintf(fd, "", argv[1]);
soap_print_fault(&soap, fd);
soap_print_fault_location(&soap, fd);
fprintf(fd, "
");
}
else
{ g = 0;
if (Ami.__size != Amo.__size || !Amo.__ptr)
g = 1;
else
{ for (i = 0; i < Ami.__size; i++)
; // need to check values here, but I am too lazy to do this now :-)
}
if (g)
{ printf("FAIL | \n", argv[1]);
fprintf(fd, "Maps arrays differ.
", argv[1]);
}
else
printf("PASS | \n");
}
}
else
printf("N/A | N/A | \n");
fflush(stdout);
fprintf(fd, "");
fclose(fd);
return 0;
}
struct Namespace namespaces[] =
{ {"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"},
{"ns", "http://soapinterop.org/"},
{"s", "http://soapinterop.org/xsd"},
{"a", "http://xml.apache.org/xml-soap"},
{NULL, NULL}
};