none
Content type mismatch consuming soap web service RRS feed

  • Question

  • Hello, I need help about a problem with a wcf service development.

    I call from my wcf service another web service (a soap web service).
    I receive this error message:

    The content type application/xml; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were:

    <?xml version=\"1.0\"?>\n<definitions xmlns=\"http://schemas.xmlsoap.org/wsdl/\" xmlns:tns=\"http://xxx.xx.xxx.xxx/xxxws/xxxservice/xxxx/index?ws=1\" xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\"  -----

    I'm not sure about this problem. Is this really a mismatch between server and client ?
    I tried different types of configuration in my wcf service web.config without result (basicHttpBinding, wsHttpBinding).

    Could someone help me? 

    Thanks.
    Sunday, December 17, 2017 9:15 PM

All replies

  • Hi ipseNat,

    >>I call from my wcf service another web service (a soap web service)

    What is the SOAP Web Service? Is it another WCF Service or asmx service? If you create a new Console App and call this Soap Web Service, will it throw the same exception?

    >>match between server and client ?

    How did you generate the client? Did you generate the client by Adding Service Reference? Did you change anything under Client Binding or Service Binding?

    >>I tried different types of configuration in my wcf service web.config without result (basicHttpBinding, wsHttpBinding).

    It would be helpful if you could share us a simple project which contains WCF Service and Soap Service, we will try to make a test based on your provided project.

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, December 18, 2017 2:37 AM
  • Hi, thanks for the reply

    I have no direct control on the web service (I have notes that indicate it as a "soap web service"). In have only a url and I can browse it. 
    So I can see the wsdl. I generated ( using svcutil ) client methods and types. 
    The url really is like this:

    http://111.11.111.111/aa/abc/web/project1 ( no extension like .svc or .asmx).
    The soap action in the wsdl is : soapAction="http://111.11.111.111/aa/abc/web/project1/index?ws=1

    I tried to generate a new Console App and call the "Soap Web Service" (I used a "web reference")
    I received the right response!

    this is (more or less) my client implementation:

    1) web service call

    ChannelFactory<destinationInterface> cFactory = ChannelFactorySingletonCollection<destinationInterface>.Instance.GetCachedFactory<destinationInterface>(
    new EndpointAddress(destinationUrl), ChannelFactoryCreationStrategy.PolicyBased);
    destinationInterface proxy = cFactory.CreateChannel();

    string response = proxy.destinationMethod(param1, param2, param3);


    2) service interface (I used svcutil generated code)

    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(Namespace = "http://111.11.111.111/aa/abc/web/project1/index?ws=1", ConfigurationName = "MyInterfacesNamespace.destinationInterface")]

    public interface destinationInterface
    {

    [System.ServiceModel.OperationContractAttribute(Action = "http://111.11.111.111/aa/abc/web/project1/index?ws=1#destinationMethod", ReplyAction = "*")]
    [System.ServiceModel.XmlSerializerFormatAttribute(Style = System.ServiceModel.OperationFormatStyle.Rpc, Use = System.ServiceModel.OperationFormatUse.Encoded)]
    [return: System.ServiceModel.MessageParameterAttribute(Name = "return")]
    string destinationMethod(param1Type param1, param2Type param2, param3Type param3);

    }

    In the web.config of my wcf service I tried configurations like this:

     <bindings>
          <basicHttpBinding>
            <binding name="project1ControllerBinding" />
          </basicHttpBinding>

          <wsHttpBinding>
            <binding name="NoSecurityBinding" />
          </wsHttpBinding>
        </bindings>

    <client>
          <endpoint address="http://111.11.111.111/aa/abc/web/project1/index?ws=1"
                    binding="basicHttpBinding" bindingConfiguration="project1ControllerBinding"
                    contract="MyInterfacesNamespace.destinationInterface"
                    name="destinationInterface" />
    </client> 
      </system.serviceModel>
    </configuration>

    Note: the test Console App created app.config like this (I changed namespaces and names with my project ones).
    I thought that was, more or less,  what was expected by my wcf web.config.

     <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="project1ControllerBinding" />
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://111.11.111.111/aa/abc/web/project1/index?ws=1"
                    binding="basicHttpBinding" bindingConfiguration="project1ControllerBinding"
                    contract="destinationNamespace.project1ControllerPort"
                    name="project1.controllers.project1ControllerControllerPort" />
            </client>
        </system.serviceModel>


    Monday, December 18, 2017 9:57 AM
  • Hi ipseNat,

    Based on your description, it works under new console app.

    Did you receive this error message throw in your WCF Service which call web service code or in the WCF Service client which call wcf service?

    Based on the configuration between web.config of wcf service and app.config in Console App, there is no different. Did you use the same code call web service in WCF Service?

    Per to web service call, it seems you use ChannelFactory, did you use the same code in Console App?

    >> I used a "web reference"

    For Add Web Reference in VS, it is usually used for asmx web service. You may need to use generated client code instead of ChannelFactory.

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, December 19, 2017 5:34 AM