none
Content Type application/soap+xml; charset=utf-8 was sent to a service expecting text/xml; charset=utf-8. The client and service bindings may be mismatched RRS feed

  • Question

  • Hi

    (I have seen several similar questions, but they didnt help)

    I call a WCF service from a silverlight page (I made sure I called the silverlight endpoint of the service) and get this error in the WCF trace

    System.ServiceModel.ProtocolException: Content Type application/soap+xml; charset=utf-8 was sent to a service expecting text/xml; charset=utf-8.  The client and service bindings may be mismatched.

    The server endpoint has WS2007FederationHttpBinding as per WSDL.

    There is another service hosted in the IIS and I can call it successfully. I compared the client side request for these 2 services are they are identical. On the server side both use WS2007FederationHttpBinding 

    I spent ton of hours to fix this issue to no avail.

    Any help is greatly appreciated.

    Thanks

    Thursday, January 23, 2014 9:42 PM

All replies

  • Hi,

    >>System.ServiceModel.ProtocolException: Content Type application/soap+xml; charset=utf-8 was sent to a service expecting text/xml; charset=utf-8.  The client and service bindings may be mismatched.

    From the above error, this is usually a mismatch in the client/server bindings, where the message version in the service uses SOAP 1.2 (which expects application/soap+xml) and the version in the client uses SOAP 1.1 (which sends text/xml). WS-Binding uses SOAP 1.2, BasicHttpBinding uses SOAP 1.1. Please try to check whether the bindings used by the client/server are the same.

    And it will be better if you can post your configure file here.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 24, 2014 2:02 AM
    Moderator
  • Thanks Amy. Actually this service was special cased during the construction.Found out by looking in to our common library code.

    Now I have another issue. I need to create the code in silverlight project that creates the custom binding to connect to this web service. Here is the client config for this. My problem is

    1. I don't want to hardcode the server name in the binding.

    2. Silverlight does not have WS2007FederationHttpBinding class available (to create the custom binding from)

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <system.serviceModel>
            <bindings>
                <customBinding>
                    <binding name="WS2007FederationHttpBinding_IDataFetchService"
                        sendTimeout="00:05:00">
                        <transactionFlow />
                        <security defaultAlgorithmSuite="Default" authenticationMode="IssuedTokenOverTransport"
                            requireDerivedKeys="true" includeTimestamp="true" messageSecurityVersion="WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10">
                            <issuedTokenParameters keyType="BearerKey">
                                <additionalRequestParameters>
                                    <trust:SecondaryParameters xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
                                        <trust:KeyType xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer</trust:KeyType>
                                        <trust:CanonicalizationAlgorithm xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://www.w3.org/2001/10/xml-exc-c14n#</trust:CanonicalizationAlgorithm>
                                        <trust:EncryptionAlgorithm xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://www.w3.org/2001/04/xmlenc#aes256-cbc</trust:EncryptionAlgorithm>
                                    </trust:SecondaryParameters>
                                </additionalRequestParameters>
                                <issuer address="https://machinefoo.domainbar.com/adfs/services/trust/13/kerberosmixed"
                                    binding="customBinding" bindingConfiguration="https://machinefoo.domainbar.com/adfs/services/trust/13/kerberosmixed" />
                                <issuerMetadata address="https://machinefoo.domainbar.com/adfs/services/trust/mex" />
                            </issuedTokenParameters>
                            <localClientSettings detectReplays="false" />
                            <localServiceSettings detectReplays="false" />
                        </security>
                        <textMessageEncoding messageVersion="Soap11WSAddressing10" />
                        <httpsTransport />
                    </binding>
                    <binding name="https://machinefoo.domainbar.com/adfs/services/trust/13/kerberosmixed"
                        sendTimeout="00:05:00">
                        <security defaultAlgorithmSuite="Basic128" authenticationMode="KerberosOverTransport"
                            requireDerivedKeys="false" includeTimestamp="true" messageSecurityVersion="WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10">
                            <localClientSettings detectReplays="false" />
                            <localServiceSettings detectReplays="false" />
                        </security>
                        <textMessageEncoding />
                        <httpsTransport />
                    </binding>
                </customBinding>
            </bindings>
            <client>
                <endpoint address="https://machinefoo.domainbar.com:8801/DataFetchService/Company.Platform.Data.DataFetchWCFWS.DataFetchService.svc"
                    binding="customBinding" bindingConfiguration="WS2007FederationHttpBinding_IDataFetchService"
                    contract="IDataFetchService" name="WS2007FederationHttpBinding_IDataFetchService" />
                <endpoint address="https://machinefoo.domainbar.com:8801/DataFetchService/Company.Platform.Data.DataFetchWCFWS.DataFetchService.svc/Silverlight"
                    binding="customBinding" bindingConfiguration="WS2007FederationHttpBinding_IDataFetchService"
                    contract="IDataFetchService" name="WS2007FederationHttpBinding_IDataFetchService.Silverlight" />
            </client>
        </system.serviceModel>
    </configuration>

    Wednesday, January 29, 2014 8:08 PM