简体   繁体   中英

Cannot process the message because the content type 'application/soap+msbin1' was not the expected type 'text/xml

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

PD 5 months to delay answer ^^

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM