WCF and Soap 1.1
I am trying to create a service that a 3rd party should hopefu开发者_Go百科lly 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>
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!
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.
I had the exact same issue - the definition was saying that it was soap 1.2 but expecting 1.1 as the content-type was different.
I found that if i adjusted my server configuration from:
...
<endpoint address="" .../>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8001/services/fooService" />
</baseAddresses>
</host>
...
To:
...
<endpoint address="fooService" .../>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8001/services" />
</baseAddresses>
</host>
...
The wsdl exposed it as Soap 1.1 this time.
精彩评论