首页 文章

无法处理消息,因为内容类型'application/soap+msbin1'不是预期类型'text / xml

提问于
浏览
2

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

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

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

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

我想知道为什么它从text / xml改变了;部署时,应用程序/ soap msbin1在dev中的charset = utf-8 .

我已经阅读了关于不匹配的绑定的原因,并试图验证客户端和服务器之间的每件事都匹配,但我不能让内容类型匹配 .

以下是我配置的摘要 .

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>

以下是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>

1 回答

  • 0

    我的工作类似于我所做的 security mode="None" ,现在适合我 . 你可以尝试一下 . 但是如果你必须使用安全模式,我认为你应该尝试其他类型的绑定,如WSHttpBinding而不是basicHttpBinding

    P.D. 5个月延迟回答^^

相关问题