1

I am having issue with gsoap client c++ call to my simple wcf service which expose:

public double Add(double n1, double n2) {
    double result = n1 + n2;
    return result;
}

Below is my gsoap client test code:

BasicHttpBinding_USCORERestaurantService svc;
_ns1__Add         request;
_ns1__AddResponse response;

//svc->endpoint
double n1 = 1.12;
double n2 = 2.32;

request.n1 =&n1;
request.n2= &n2;
svc.soap->keep_alive=1;
int iResult = svc.__ns1__Add(&request, &response); // response result always return 0

I have a break point at the service, the parameter for n1,n2 always 0;

Below is my wsdl file:

<?xml version="1.0" encoding="utf-8" ?> 
 <wsdl:definitions name="RestaurantService" targetNamespace="http://www.thinktecture.com/services/restaurant/2006/12" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://www.thinktecture.com/services/restaurant/2006/12" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata">
 <wsdl:types>
 <xsd:schema elementFormDefault="qualified" targetNamespace="http://www.thinktecture.com/services/restaurant/2006/12">
 <xsd:element name="Add">
 <xsd:complexType>
 <xsd:sequence>
  <xsd:element minOccurs="0" name="n1" type="xsd:double" /> 
  <xsd:element minOccurs="0" name="n2" type="xsd:double" /> 
  </xsd:sequence>
  </xsd:complexType>
  </xsd:element>
 <xsd:element name="AddResponse">
 <xsd:complexType>
 <xsd:sequence>
  <xsd:element minOccurs="0" name="AddResult" type="xsd:double" /> 
  </xsd:sequence>
  </xsd:complexType>
  </xsd:element>
  </xsd:schema>
  </wsdl:types>
 <wsdl:message name="RestaurantService_Add_InputMessage">
  <wsdl:part name="parameters" element="tns:Add" /> 
  </wsdl:message>
 <wsdl:message name="RestaurantService_Add_OutputMessage">
  <wsdl:part name="parameters" element="tns:AddResponse" /> 
  </wsdl:message>
 <wsdl:portType name="RestaurantService">
 <wsdl:operation name="Add">
  <wsdl:input wsaw:Action="http://www.thinktecture.com/services/restaurant/2006/12/RestaurantService/Add" message="tns:RestaurantService_Add_InputMessage" /> 
  <wsdl:output wsaw:Action="http://www.thinktecture.com/services/restaurant/2006/12/RestaurantService/AddResponse" message="tns:RestaurantService_Add_OutputMessage" /> 
  </wsdl:operation>
  </wsdl:portType>
 <wsdl:binding name="BasicHttpBinding_RestaurantService" type="tns:RestaurantService">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" /> 
 <wsdl:operation name="Add">
  <soap:operation soapAction="http://www.thinktecture.com/services/restaurant/2006/12/RestaurantService/Add" style="document" /> 
 <wsdl:input>
  <soap:body use="literal" /> 
  </wsdl:input>
 <wsdl:output>
  <soap:body use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
 <wsdl:service name="RestaurantService">
 <wsdl:port name="BasicHttpBinding_RestaurantService" binding="tns:BasicHttpBinding_RestaurantService">
  <soap:address location="http://localhost:3456/WebHost/Service.svc/RS" /> 
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>

Below is soap message that I enabled logging:

call from gsoap c++ client
<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="http://www.thinktecture.com/services/restaurant/2006/12">
<s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://localhost:3456/WebHost/Service.svc/RS</To>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://www.thinktecture.com/services/restaurant/2006/12/RestaurantService/Add</Action>
</s:Header>
<SOAP-ENV:Body>
<ns1:Add>
<n1 xsi:type="xsd:double" xmlns="">1.1200000000000001</n1>
<n2 xsi:type="xsd:double" xmlns="">2.3199999999999998</n2>
</ns1:Add>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

return message from service:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<ActivityId CorrelationId="ac83c5fa-e518-4883-a381-f5ec63411226" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">dddc227b-82e3-4578-b282-572017003943</ActivityId>
</s:Header>
<s:Body>
<AddResponse xmlns="http://www.thinktecture.com/services/restaurant/2006/12">
<AddResult>0</AddResult>
</AddResponse>
</s:Body>
</s:Envelope>
John H
  • 33
  • 5
  • I have a hunch this has to do with namespaces. Try removing the 'xmlns=""' for n1 and n2 in the request (e.g. intercept and change the request using Fiddler) and see if it changes anything. – Eugene Osovetsky Dec 21 '12 at 06:55
  • Thanks Eugene for your help. I was able to compare soap header message for 2.7 and 2.8: below soap2.8 header: 1.1200000000000001 2.3199999999999998 below is soap2.7 header: 13.18 24.359999999999999 – John H Dec 27 '12 at 17:38
  • the difference is against . How do I change my wsdl so that the soap body change from to ? – John H Dec 27 '12 at 17:47

2 Answers2

1

I have the same issue when WCF service always return 0 on request Add(int n1, int n2). After long time working I have found resolution, my workaround is applying the gSoap 2.7.16 instead of the last 2.8.1_2, it works flawlessly.

dzzunga
  • 11
  • 2
  • 1
    Thank you very much..You saved my day...It works after I changed gSoap-2.7.16. Thanks again. – John H Dec 26 '12 at 15:32
  • Great. Thank you timiil. Using your XmlSerializerFormat(...) I am back to gSOAP version 2.8.12_2 without problem, RPC is good for me. – dzzunga Dec 27 '12 at 05:30
1

after hours work, i had fixed this thing, if you are using WCF , you need add an attribute into your operation, for example:

[ServiceContract]
    public interface IMyService
    {
        [OperationContract]
        [XmlSerializerFormat(Style = OperationFormatStyle.Rpc, Use = OperationFormatUse.Literal)]
        long Method1(int a, int b, long c, string d);
     }

so the gsoap can send the argument value correctly to server.

timiil
  • 21
  • 4