Ask a questionAsk a question
 

AnswerClient and service binding mismatch?

  • Friday, February 16, 2007 3:01 PMKevinBurton Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I have a WCF web service that when I call I get an exception:

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

    It seems that only difference is text/xml needs to be changed to 'application/soap+xml'. Any ideas on how to fix this? The service is self-hosted (console host). The service reference was generated from this service without a problem.

    Thank you.

    Kevin

Answers

  • Friday, February 16, 2007 7:22 PMCarlos FigueiraMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Yesm 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). WSHttpBinding uses SOAP 1.2, BasicHttpBinding uses SOAP 1.1. Can you verify that the bindings used by the client/server are the same?

All Replies

  • Friday, February 16, 2007 7:17 PMTodd West - Microsoft Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    The complete set of exceptions and stack would be helpful.  This is expected if the service is IIS hosted and there's an activation problem.
  • Friday, February 16, 2007 7:22 PMCarlos FigueiraMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Yesm 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). WSHttpBinding uses SOAP 1.2, BasicHttpBinding uses SOAP 1.1. Can you verify that the bindings used by the client/server are the same?
  • Friday, February 16, 2007 9:09 PMKevinBurton Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Here is the stack trace. The service reference (The proxy was generated from a self-hosted console app. Would that be a problem if I used the same proxy code but just pointed it to the IIS hosted version of the service?

    System.ServiceModel.ProtocolException: Content Type application/soap+xml; charset=utf-8 was not supported by service http://developer03/MyCompany/Services/MyServices.svc. The client and service bindings may be mismatched. ---> System.Net.WebException: The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..

    at System.Net.HttpWebRequest.GetResponse()

    at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)

    --- End of inner exception stack trace ---

    Server stack trace:

    at System.ServiceModel.Security.IssuanceTokenProviderBase`1.DoNegotiation(TimeSpan timeout)

    at System.ServiceModel.Security.SspiNegotiationTokenProvider.OnOpen(TimeSpan timeout)

    at System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)

    at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)

    at System.ServiceModel.Security.CommunicationObjectSecurityTokenProvider.Open(TimeSpan timeout)

    at System.ServiceModel.Security.SecurityUtils.OpenCommunicationObject(ICommunicationObject obj, TimeSpan timeout)

    at System.ServiceModel.Security.SecurityUtils.OpenTokenProviderIfRequired(SecurityTokenProvider tokenProvider, TimeSpan timeout)

    at System.ServiceModel.Security.SymmetricSecurityProtocol.OnOpen(TimeSpan timeout)

    at System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)

    at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)

    at System.ServiceModel.Security.SecurityProtocol.Open(TimeSpan timeout)

    at System.ServiceModel.Channels.SecurityChannelFactory`1.ClientSecurityChannel`1.OnOpen(TimeSpan timeout)

    at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)

    at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.DoOperation(SecuritySessionOperation operation, EndpointAddress target, Uri via, SecurityToken currentToken, TimeSpan timeout)

    at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.GetTokenCore(TimeSpan timeout)

    at System.IdentityModel.Selectors.SecurityTokenProvider.GetToken(TimeSpan timeout)

    at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.OnOpen(TimeSpan timeout)

    at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)

    at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)

    at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)

    at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)

    at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)

    at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout)

    at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)

    at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)

    at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)

    at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]:

    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)

    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

     

    1 passed, 0 failed, 0 skipped, took 173.25 seconds.

     

    Any suggestions?

    Thank you.

    Kevin

  • Monday, September 08, 2008 8:17 PMtysonbrown Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    We had a similar issue where we could generate the proxies from one server, and not from the other. We would get the same error message that you were getting. The cause of this one was that the server that worked had the application pool running as Network Service, and the one that didn't work was running as Local Service. As soon as we switched it to Network Service, it started working.

  • Tuesday, August 25, 2009 2:41 PMSaishyam Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    I am getting a similar error

    The remote server returned an error: (415) Cannot process the message because the content type 'multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:77451d20-7af6-414c-bd3d-54ab50d958d7+id=4";start-info="text/xml"' was not the expected type 'text/xml; charset=utf-8'..

    and app pool is running under Network Service Identity. I am not sure what the problem with my setting is.

    This is the client binding model


      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="BasicHttpBinding_IQuasarDataLayer" messageEncoding="Mtom" transferMode="Streamed" maxBufferSize="10485760" maxReceivedMessageSize="67108864">
              <readerQuotas maxDepth="64" maxStringContentLength="214748364" maxArrayLength="214748364"
                  maxBytesPerRead="4096" maxNameTableCharCount="16384" />
              <security mode="None">
                <transport clientCredentialType="None" proxyCredentialType="None"
                  realm="" />
                <message clientCredentialType="UserName" algorithmSuite="Default" />
              </security>
            </binding>
          </basicHttpBinding>
        </bindings>   
        <client>
          <endpoint address="http://XXX/QuasarWebHelpRequestRemoting/DataLayerService.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IQuasarDataLayer"
            contract="QuasarDataLayer.IQuasarDataLayer" name="BasicHttpBinding_IQuasarDataLayer" />
        </client>
      </system.serviceModel> 

    and this is the WCF Service config


    <system.serviceModel>
      <bindings>
        <basicHttpBinding>
          <binding name="BasicHttpBinding_IQuasarDataLayer" messageEncoding="Mtom" transferMode="Streamed" maxBufferSize="10485760" maxReceivedMessageSize="67108864">
            <readerQuotas maxDepth="64" maxStringContentLength="214748364" maxArrayLength="214748364"
                maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            <security mode="None">
              <transport clientCredentialType="None" />
            </security>
          </binding>
        </basicHttpBinding>
      </bindings>
        <services>
          <service name="QuasarDataLayer.DataLayerService" behaviorConfiguration="QuasarDataLayer.Service1Behavior">       
            <endpoint address="" binding="basicHttpBinding" contract="QuasarDataLayer.IQuasarDataLayer"/>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
          </service>
        </services>
      <!--serviceHostingEnvironment aspNetCompatibilityEnabled="true"/-->
      <behaviors>
          <serviceBehaviors>
            <behavior name="QuasarDataLayer.Service1Behavior">         
              <serviceMetadata httpGetEnabled="true"/>         
              <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>



    Please let me know where am I making mistakes. I appreciate your help.


    Thanks and regards,

    Sai