Search code examples
c#soapbindingcontenttype

How to specify ContentType for customBinding?


In my App.config I have this binding:

        <customBinding>
            <binding name="B2BJSONSoap12">
                <textMessageEncoding messageVersion="Soap12" />
                <httpsTransport />
            </binding>
        </customBinding>

And this endpount for it:

        <endpoint address="https://xxx.xxx.xxx/b2bJSON.asmx"
            binding="customBinding" bindingConfiguration="B2BJSONSoap12"
            contract="SROCS.B2BJSONSoap" name="B2BJSONSoap12" />

In code I create B2BJSONSoapClient (which was loaded by wsdl) for invoking methods. And when I try to invoke one I get System.ServiceModel.ProtocolException (in Russian) whish says someting like that:

Content type text/html; Charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). When using a special encoder, you need to implement the IsContentTypeSupported method correctly.

So how do I specify Content type to be "application/soap+xml"?

I can do that using HttpWebRequest without client, but that'd be way more work...


Solution

  • So problem was with incorrect username and password, I don't know why service gave me this exception. It wokrs now with the same settings.