Search code examples
c#.netweb-serviceswsdl

Content type mismatch when consuming java wsdl from .net


There is a wsdl hosted on apache or jboss on a remote server that I am trying to use in my c# project. I have added a service reference in visual studio, which automatically generated an app.config file for me, where the system.serviceModel section looks as follows

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="ArtesiaWebServicesHttpBinding" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="655360" maxBufferPoolSize="524288" maxReceivedMessageSize="655360"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    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://serverpath/ArtesiaWebServices"
            binding="basicHttpBinding" bindingConfiguration="ArtesiaWebServicesHttpBinding"
            contract="DAMService.ArtesiaWebServicesInterface" name="ArtesiaWebServicesHttpPort" />
    </client>
</system.serviceModel>

At runtime, during a method call, I get the following error:

The content type multipart/related; type="application/xop+xml"; start=""; start-info="text/xml"; boundary="----=_Part_386_1206794365.1374255761229" 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.

What could be the problem?


Solution

  • The problem was solved by changing messageEncoding property of the binding to "Mtom" instead of "Text"