views:

884

answers:

2
+2  Q: 

WCF and Soap 1.1

I am trying to create a service that a 3rd party should hopefully consume.
The consumer is compatible with SOAP 1.1, which is why I am using basicHttpBinding for the server. When the actual request is made, something seems to go wrong with the content types expected by the server. Using basicHttpBinding I dont get why the server still expects 'application/soap+xml' which, to my knowledge, is only required by SOAP 1.2.

I've used wireshark to figure out exactly what those two were communicating about. See tcp stream and setup below.

Any help is appreciated.

3rd party app request

POST / HTTP/1.1

SOAPAction: http://tempuri.org/ITestService/Hello

Content-Type: text/xml; charset=utf-8

Host: shdesktop:8000

Content-Length: 297

Expect: 100-continue

Connection: Close

WCF Server response

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

Content-Length: 0

Server: Microsoft-HTTPAPI/2.0

Date: Tue, 09 Feb 2010 14:03:19 GMT

Connection: close

Service configuration

<system.serviceModel>
    <services>
      <service behaviorConfiguration="behTestService" name="ConsoleApplication1.TestService">
        <endpoint address="" binding="mexHttpBinding" contract="IMetadataExchange" />
        <endpoint address="TestService" binding="basicHttpBinding"
            contract="ConsoleApplication1.ITestService" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8000" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="behTestService">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
+2  A: 

Generally when we get a message / error in a web service which includes the text:

content type 'text/xml'

It means that the web server returned an error page instead of the expected xml response.

Shiraz Bhaiji
+1  A: 

The basicHttpBinding does use SOAP 1.1 - but in that case, you would have a content type of application/soap+xml.

Since your client is sending text/xml - any chance they're expecting a REST interface? This would be handled by the WCF webHttpBinding.

Read more about REST in WCF on the MSDN WCF REST Developer Center and check out the Pluralsight screencast series on WCF REST - highly recommended!

marc_s
oh, SOAP 1.1 would use 'application/soap+xml'? I will test the webHttpBinding tomorrow, thank you! I know for a fact that it works when I create a simple asmx service, if it makes any difference.
Silas Hansen
@Silas: "old-style" ASP.NET webservices (ASMX) **and** WCF basicHttpBinding use SOAP 1.1 - so that should be ok, really. You need to check whether your client is sending you a SOAP request, or just trying to post an XML to your URL
marc_s
I was calling http://<hostname> instead I needed to call http://<hostname>/TestService. Stupid mistake by me. Thanks for all the help though!
Silas Hansen