none
WCF integration with GSOAP

    Question

  • Hi,

    I’m trying to write a c++ client that talks to .net WCF server. For that aim I’m using the GSOAP application.

    I was successful in writing a c++ client that talks to an asp.net server, but when I tried to write c++ client and a WCF server they failed to interact.

    When the client sent a request to the server the following fault was received:

    Error 415 fault: SOAP-ENV:Server [no subcode]

    "HTTP Error"

    Detail: HTTP/1.1 415 Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.

    It looks like the WCF server doesn’t know how to deal with the format of the client requests.

    Does anybody know why this occurs? Can I change the server settings to allow him receive the client messages format?

    Thanks.

     

    Dror.

    Tuesday, December 26, 2006 2:10 PM

Answers

  • Problem was solved!

    Thanks to Peter Zehler who provided the solution:

    All that was needed is to remove the soap1.2 namespace from the WSDL/Schema. If the soap1.2 namespace is present, gSoap will produce a soap1.2 client, even if the -1 option in soapcpp2 is specified.

     

    And again - thank for Peter!

    Wednesday, January 3, 2007 7:47 AM

All replies

  • text/xml is the media type for SOAP 1.1 while application/soap+xml is the media type for SOAP 1.2.  Are the client and server configured for the same versions?

    - Nicholas Allen

    http://blogs.msdn.com/drnick

     

    Wednesday, December 27, 2006 9:40 AM
  • Thanks for the reply,

    It really looks like WCF with basicHttpBinding use soap1.1, while gSoap generates client that uses soap1.2.

    It is my understanding that bp1.0 requires soap1.1 version. 

    If all of the above is correct, then the question is only why does gSoap uses soap1.2 (or how can i "force" gSoap to use soap1.1).

     

    Dror.

    Thursday, December 28, 2006 6:53 AM
  • That's correct, BP 1.0 requires the use of SOAP 1.1.  I haven't used gSOAP, but this reference to their documentation may help: http://www.cs.fsu.edu/~engelen/soapdoc2.html#tth_sEc8.1.

    - Nicholas Allen

    http://blogs.msdn.com/drnick

    Thursday, December 28, 2006 9:44 AM
  • Hi,

    Does anyone knows about a reliable (and tested) integration tool between c++ and WCF?

    Thanks, Dror.

    Thursday, December 28, 2006 9:45 AM
  • Thanks alot for the quick reply.

    I've allready tried most of the gSoap compilation options, including -1 option that is supposed to force client to use soap1.1, but to no avail.

    The client request content-type remains application/soap+xml, and the server still throws 415 fault.

    Maybe i'm missing something....

    Thanks again.

    Dror.

    Thursday, December 28, 2006 10:02 AM
  • Problem was solved!

    Thanks to Peter Zehler who provided the solution:

    All that was needed is to remove the soap1.2 namespace from the WSDL/Schema. If the soap1.2 namespace is present, gSoap will produce a soap1.2 client, even if the -1 option in soapcpp2 is specified.

     

    And again - thank for Peter!

    Wednesday, January 3, 2007 7:47 AM
  • Drore,

    I am working on a similar C and WCF integration. But I am having problems with the placement of SOAPAction field. WCF webservice expects it as a SOAP header(Action tag) where as gSOAP client is sending it as HTTP header(SOAPAction). Do you have any idea how to generate the gSOAP stub to put the SOAP Action in SOAP header?

    Original post: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2379083&SiteID=1&mode=1
    Monday, November 12, 2007 6:53 AM
  •  

    Hi,

    I have exactly the same problem.

    What did you do to your wsdl ?

    What do you mean by "remove the soap1.2 namespace from the WSDL/Schema" ?

    Could you give me an example

     

    Thanks

    Friday, November 16, 2007 8:47 AM
  • Has anyone come to any sort of resolution on this?  A group of us are attempting the same thing currently, trying to get a gSOAP client to talk to a WCF SOAP server.

    Thanks.
    Friday, November 30, 2007 8:26 PM
  •  

    Actually I haven’t dealt with gSoap integration since. I don’t remember how exactly I removed the namespace from the wsdl. But I can think of at least 2 directions you can try:

    1. Save the wsdl to file, and manually remove the soap1.2 namespace.
    2. In the WCF server use custom binding and change the message version to SOAP1.1
    Saturday, December 1, 2007 7:54 PM
  • I am very new to gSOAP and WCF.If possible, could you please write the detail steps or point to any documents.

    Thanks in advance..
    Nagesh
    Wednesday, January 23, 2008 6:24 AM
  • There is a easy solution for WCF integration with gSoap:
    First download the microsoft examples (see http://msdn2.microsoft.com/en-us/library/ms751514.aspx)
    Go to the Samples\TechnologySamples\Extensibility\Interop\RouteByBody directory
    Get the files
    DispatchByBodyOperationSelector.cs and
    DispatchByBodyBehaviorAttribute.cs.

    Append them to your project.
    Now change your service contract the following way:

      [ServiceContract(Namespace = "http://yournamespace"), XmlSerializerFormat, DispatchByBodyBehavior]

    add to your service class the following function:
        [OperationContract(Action = "")]
        public void DoNothing()
        {
        }

    Adapt your web.config:
      <system.serviceModel>
        <bindings>
          <customBinding>
            <binding name="gSoap">
              <textMessageEncoding messageVersion="Soap12" />
              <httpTransport />
            </binding>
          </customBinding>
        </bindings>
        <services>
          <service name="Test.TestService">
            <endpoint contract="Test.TestService" binding="customBinding" bindingConfiguration="gSoap" address="http://myserver/TestService" />
          </service>
        </services>
      </system.serviceModel>

    and your done.

    Generate your gsoap client with wsdl2h and soapcpp2 (see gsoap manual), and it works out of the box.

    Thursday, March 6, 2008 8:57 AM
  • I spend whole day for solving this problem. And I won )

    I didn't change wsdl-file, but I solved this problem another way.
    For removing soap 1.2 namespace from the your web-service client project you should to change strings

     {"SOAP-ENV", "http://www.w3.org/2003/05/soap-envelope", "http://www.w3.org/2003/05/soap-envelope", NULL},
     {"SOAP-ENC", "http://www.w3.org/2003/05/soap-encoding", "http://www.w3.org/2003/05/soap-encoding", NULL},
     {"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance", NULL},
     {"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema", NULL},

    to 

    {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", NULL, NULL},
     {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/", NULL, NULL},
     {"xsi", "http://www.w3.org/2001/XMLSchema-instance", NULL, NULL},
     {"xsd", "http://www.w3.org/2001/XMLSchema", NULL, NULL},

    in your .nsmap file and *Proxy.cpp file.

    • Proposed as answer by Alex_UAN Tuesday, July 21, 2009 9:32 AM
    Tuesday, July 21, 2009 9:28 AM
  • It's usually not a good idea to modify generated files, since the changes will be overridden when the files are generated again.
    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    Tuesday, July 21, 2009 3:49 PM
    Moderator
  • But changing the wsdl file is not solve this problem also. Because after modifying Web-service we will need to generate wsdl again. And it also override all changes.
    (sorry for my poor english)
    Tuesday, July 21, 2009 7:42 PM
  • Or you could do what I did and just hack stdsoap2.c (the previous solutions didn't work for me) -

    if (status == SOAP_FILE && soap->http_content)
          s = soap->http_content;
        else if (status == SOAP_HTML)
          s = "text/html; charset=utf-8";
        else if (count || ((soap->omode & SOAP_IO) == SOAP_IO_CHUNK))
        { /* change to override mime type ---  if (soap->version == 2)
            s = "application/soap+xml; charset=utf-8"; */
        }
    Monday, September 28, 2009 5:23 AM
  • Thanks Alex... this worked for me. I was able to change what you mention above and hit a WCF service from C++ on Linux using gSOAP. I also compile step by step instructions to hit a WCF service with a c++ client here.
    Saturday, October 24, 2009 11:39 PM