我正在尝试创建一个第三方应该有望消费的服务 .
使用者与SOAP 1.1兼容,这就是我为服务器使用basicHttpBinding的原因 . 当提出实际请求时,服务器期望的内容类型似乎出现了问题 . 使用basicHttpBinding我不明白为什么服务器仍然期望'application/soap+xml',据我所知,这只是SOAP 1.2所要求的 .
我已经使用过wireshark来弄清楚这两个人正在沟通的内容 . 请参阅下面的tcp流和设置 .
任何帮助表示赞赏 .
3rd party app request
POST / HTTP / 1.1 SOAPAction:http://tempuri.org/ITestService/Hello Content-Type:text / xml; charset = utf-8主持人:shdesktop:8000内容长度:297期望:100-continue连接:关闭
WCF Server response
HTTP / 1.1 415无法处理消息,因为内容类型为'text / xml; charset = utf-8'不是预期的类型'application / soap xml;字符集= UTF-8' . 内容长度:0服务器:Microsoft-HTTPAPI / 2 . 0日期:2010年2月9日星期二14:03:19 GMT连接:关闭
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>
3 回答
basicHttpBinding
确实使用SOAP 1.1 - 但在这种情况下,您的内容类型为application/soap+xml
.由于您的客户端正在发送
text/xml
- 他们是否有机会期待REST接口?这将由WCFwebHttpBinding
处理 .在MSDN WCF REST Developer Center上阅读有关WCF中REST的更多信息,并查看Pluralsight screencast series on WCF REST - 强烈推荐!
通常,当我们在包含文本的Web服务中收到消息/错误时:
这意味着Web服务器返回了错误页面而不是预期的xml响应 .
我有完全相同的问题 - 定义是说它是肥皂1.2但是期望1.1因为内容类型不同 .
我发现如果我调整了我的服务器配置:
至:
wsdl这次将它暴露为Soap 1.1 .