Hi everybody,

For a very simple web-service (adding two doubles) I built a server and two 
versions of a client (C and C++). The C++ version works fine, while the C 
version fails with message
"SOAP 1.1 fault: SOAP-ENV:Client [no subcode]
"Validation constraint violation: tag name or namespace mismatch in element 
'SOAP-ENV:Envelope'"
Detail: [no detail]"

Everything was done in MS Visual Studio 2008 under Windows XP.

Am I doing something wrong?


The C client is the following:

#include "soapH.h"
#include "scisoap.nsmap"

int main(int argc, char **argv)
{ 
  struct soap soap;
  char fault[300];
  double c = 0;

  soap_init(&soap);

  /* Calculate the sum */
  if(soap_call_ns1__add(&soap, NULL, NULL, 1.5, 4.5, &c) != SOAP_OK)
  {
    soap_sprint_fault(&soap, fault, 300);
    return -1;
  }

  soap_end(&soap);
  soap_done(&soap);

  return 0;
}


The C++ client:

#include "soapscisoapProxy.h"
#include "scisoap.nsmap"

#include <iostream>

int main(int argc, char **argv)
{ 
  scisoap proxy;

  double r;

  if(proxy.ns1__add(1.5, 4.5, r) != SOAP_OK)
  {
          soap_print_fault(proxy.soap, stderr);
  }
  else
  {
          std::cout << "r : " << r << std::endl;
  }

  return 0;
}


The server:

#include "soapH.h"
#include "scisoap.nsmap"

int main(int argc, char **argv)
{ 
  SOAP_SOCKET m, s; /* master and slave sockets */
  struct soap soap;
  soap_init(&soap);
  m = soap_bind(&soap, NULL, 5050, 100);
  if (!soap_valid_socket(m))
  { 
    soap_print_fault(&soap, stderr);
    exit(-1);
  }
  fprintf(stderr, "Server socket bound: master socket = %d\n", m);
  for ( ; ; )
  { 
    s = soap_accept(&soap);
    fprintf(stderr, "Accepted connection: slave socket = %d\n", s);
    if (!soap_valid_socket(s))
    { 
      soap_print_fault(&soap, stderr);
      exit(-1);
    } 
    soap_serve(&soap);
    if (soap.error)
    { 
      soap_print_fault(&soap, stderr);
    } 
    soap_end(&soap);
  }
 
  return 0;
} 

int ns1__add(struct soap *soap, double a, double b, double *result)
{
  *result = a + b;
  return SOAP_OK;
}


The request from the C client:

POST / HTTP/1.1
Host: <ip>:5050
User-Agent: gSOAP/2.7
Content-Type: text/xml; charset=utf-8
Content-Length: 0
Connection: close
SOAPAction: ""

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:ns1="urn:scisoap">
  <SOAP-ENV:Header></SOAP-ENV:Header>
  <SOAP-ENV:Body 
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>
    <ns1:add>
      <a>1.5</a>
      <b>4.5</b>
    </ns1:add>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


The response from the server:

HTTP/1.1 200 OK
Server: gSOAP/2.7
Content-Type: text/xml; charset=utf-8
Content-Length: 505
Connection: close

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:ns1="urn:scisoap">
  <SOAP-ENV:Header></SOAP-ENV:Header>
  <SOAP-ENV:Body 
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>
    <ns1:addResponse>
      <result>6</result>
    </ns1:addResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


The request from C++ client:

POST / HTTP/1.1
Host: <ip>:5050
User-Agent: gSOAP/2.7
Content-Type: text/xml; charset=utf-8
Content-Length: 456
Connection: close
SOAPAction: ""

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:ns1="urn:scisoap">
  <SOAP-ENV:Body 
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>
    <ns1:add>
      <a>1.5</a>
      <b>4.5</b>
    </ns1:add>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


The response from the server:

HTTP/1.1 200 OK
Server: gSOAP/2.7
Content-Type: text/xml; charset=utf-8
Content-Length: 470
Connection: close

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:ns1="urn:scisoap">
  <SOAP-ENV:Body 
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>
    <ns1:addResponse>
      <result>6</result>
    </ns1:addResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


The WSDL is the following:

<?xml version="1.0" encoding="UTF-8"?>
<definitions name="scisoap"
 targetNamespace="urn:scisoap"
 xmlns:tns="urn:scisoap"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema";
 xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/";
 xmlns="http://schemas.xmlsoap.org/wsdl/";>

<types>

 <schema targetNamespace="scisoap.xsd"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema";
  xmlns="http://www.w3.org/2001/XMLSchema";>
  <import namespace="http://schemas.xmlsoap.org/soap/encoding/"; 
    schemaLocation="http://schemas.xmlsoap.org/soap/encoding/"/>
 </schema>

</types>

<message name="AddRequest">
 <part name="a" type="xsd:double"/>
 <part name="b" type="xsd:double"/>
</message>

<message name="AddResponse">
 <part name="result" type="xsd:double"/>
</message>

<portType name="scisoapPortType">
 <operation name="add">
  <documentation>Performs addition</documentation>
  <input message="tns:AddRequest"/>
  <output message="tns:AddResponse"/>
 </operation>
</portType>

<binding name="scisoap" type="tns:scisoapPortType">
 <SOAP:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
 <operation name="add">
  <SOAP:operation style="rpc" soapAction=""/>
  <input>
     <SOAP:body use="encoded" namespace="urn:scisoap" 
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  </input>
  <output>
     <SOAP:body use="encoded" namespace="urn:scisoap" 
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  </output>
 </operation>
</binding>

<service name="SciSOAPService">
 <documentation>Service executes commands with Scilab</documentation>
 <port name="SciSOAPPort" binding="tns:scisoap">
  <SOAP:address location="http://<ip>:5050"/>
 </port>
</service>

</definitions>


Thanks in advance,
Artem

Reply via email to