无法处理消息,因为内容类型“application/soap+msbin1"不是预期的类型“text/xml" [英] Cannot process the message because the content type 'application/soap+msbin1' was not the expected type 'text/xml

查看:41
本文介绍了无法处理消息,因为内容类型“application/soap+msbin1"不是预期的类型“text/xml"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Silverlight 应用程序,它在我的开发环境 (Win 7) 中成功调用了 WCF.当我检查 Fiddler 中返回的内容类型时,它显示如下.

HTTP/1.1 200 OK缓存控制:私有内容长度:18849内容类型:文本/xml;字符集=utf-8服务器:Microsoft-IIS/7.5X-AspNet 版本:4.0.30319X-Powered-By: ASP.NET日期:2014 年 9 月 1 日星期一 14:59:01 GMT

但是,一旦我在我的 QA 服务器 (IIS 6.0) 中部署应用程序,对 WCF 服务的调用就会失败并显示以下错误(同样来自 Fiddler)

<块引用>

HTTP/1.1 415 无法处理消息,因为内容类型application/soap+msbin1"不是预期的类型text/xml;字符集=utf-8'.

我想知道为什么它从 text/xml 改变;部署时将 dev 中的 charset=utf-8 转换为 application/soap+msbin1.

我已经阅读了有关绑定不匹配的原因,并尝试验证客户端和服务器之间的所有内容是否匹配,但我无法获得内容类型匹配.

以下是我的配置片段.

Web.Config

 <绑定><基本HttpBinding><binding name="DataSoap" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"><安全模式=传输"/></binding><binding name="DataSoap1" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"><安全模式=传输"/></binding></basicHttpBinding></绑定><服务><服务名称="MyApp.Web.GetData" behaviorConfiguration="MyApp.Web.GetData" ><endpoint address="" binding="basicHttpBinding" bindingConfiguration="DataSoap" contract="MyApp.Web.GetData"/><endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/></服务></服务><行为><服务行为><行为名称="MyApp.Web.GetData"><serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/><serviceDebug includeExceptionDetailInFaults="true"/><dataContractSerializer maxItemsInObjectGraph="2147483646"/></行为><行为名称=""><serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/><serviceDebug includeExceptionDetailInFaults="true"/></行为></serviceBehaviors></行为><serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/></system.serviceModel>

下面是 ServiceReferences.ClientConfig

<预><代码><配置><system.serviceModel><绑定><基本HttpBinding><binding name="DataSoap" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"><安全模式=传输"/></binding><binding name="DataSoap1" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"><安全模式=传输"/></binding></basicHttpBinding><自定义绑定><绑定名称="CustomBinding_GetData"><binaryMessageEncoding/><httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/></binding></customBinding></绑定><客户><端点地址="//localhost/MyApp/Webservice/Data.asmx"binding="basicHttpBinding" bindingConfiguration="DataSoap"contract="ServiceReference1.DataSoap" name="DataSoap"/><端点地址="//localhost/MyApp/Webservice/GetData.svc"binding="basicHttpBinding" bindingConfiguration="DataSoap1"contract="GetData.GetData" name="CustomBinding_GetData"/></客户端></system.serviceModel>

解决方案

我正在做一些类似于我在 security mode="None" 中所做的工作,现在对我有用.你可以试试看.但是,如果您必须使用安全模式,我认为您应该尝试另一种类型的绑定,例如 WSHttpBinding 而不是 basicHttpBinding

PD5个月延迟答复^^

I have a Silverlight application that calls a WCF successfully in my development environment (Win 7). When i inspect the content type returned in Fiddler, it is showing as below.

HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 18849
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 01 Sep 2014 14:59:01 GMT

However, as soon as i deploy the application in my QA server (IIS 6.0) the call to the WCF service fails with below error (again according from Fiddler)

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

I am wondering why it's changing from text/xml; charset=utf-8 in dev to application/soap+msbin1 when deployed.

I have read up about mismatched bindings being the cause and tried to verify that every thing matches between client and server but i am i cant to get the content type matching.

Below are snippets of my configurations.

Web.Config

 <system.serviceModel>
    <bindings>

        <basicHttpBinding>
            <binding name="DataSoap" maxBufferSize="2147483647"  maxReceivedMessageSize="2147483647">
                <security mode="Transport" />
            </binding>
            <binding name="DataSoap1" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
                <security mode="Transport" />
            </binding>
        </basicHttpBinding>
       </bindings>
    <services>
        <service name="MyApp.Web.GetData" behaviorConfiguration="MyApp.Web.GetData" >
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="DataSoap"  contract="MyApp.Web.GetData" />
            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="MyApp.Web.GetData">
                <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="true"/>
                <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
            </behavior>
            <behavior name="">
                <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>

And below is the ServiceReferences.ClientConfig

<configuration>
<system.serviceModel>        
    <bindings>            
        <basicHttpBinding>
            <binding name="DataSoap" maxBufferSize="2147483647"  maxReceivedMessageSize="2147483647">
                <security mode="Transport" />
            </binding>
            <binding name="DataSoap1" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
                <security mode="Transport" />
            </binding>
        </basicHttpBinding>           
        <customBinding>
            <binding name="CustomBinding_GetData">
                <binaryMessageEncoding />
                <httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
            </binding>
        </customBinding>
    </bindings>
    <client>
        <endpoint address="//localhost/MyApp/Webservice/Data.asmx"
            binding="basicHttpBinding" bindingConfiguration="DataSoap"
            contract="ServiceReference1.DataSoap" name="DataSoap" />

        <endpoint address="//localhost/MyApp/Webservice/GetData.svc"
            binding="basicHttpBinding" bindingConfiguration="DataSoap1"
            contract="GetData.GetData" name="CustomBinding_GetData" />
    </client>
</system.serviceModel>

解决方案

I am working in something similar what I did put the security mode="None" and now works for me. You can try it. But if you have to use a security mode you I think you should try another type of binding like WSHttpBinding instead of basicHttpBinding

P.D. 5 months to delay answer ^^

这篇关于无法处理消息,因为内容类型“application/soap+msbin1"不是预期的类型“text/xml"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆