Content Type text/xml; charset=utf-8 was not supported by service

前端 未结 10 1757
北海茫月
北海茫月 2020-12-01 09:59

I have a problem with a WCF service. I have a console application and I need to consume the service without using app.config, so I had to set the endpoint, etc. by code. I d

相关标签:
10条回答
  • 2020-12-01 10:47

    In my case, I had to specify messageEncoding to Mtom in app.config of the client application like that:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <startup> 
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
        </startup>
        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="IntegrationServiceSoap" messageEncoding="Mtom"/>
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://localhost:29495/IntegrationService.asmx"
                    binding="basicHttpBinding" bindingConfiguration="IntegrationServiceSoap"
                    contract="IntegrationService.IntegrationServiceSoap" name="IntegrationServiceSoap" />
            </client>
        </system.serviceModel>
    </configuration>
    

    Both my client and server use basicHttpBinding. I hope this helps the others :)

    0 讨论(0)
  • 2020-12-01 10:48

    I was facing the similar issue when using the Channel Factory. it was actually due to wrong Contract specified in the endpoint.

    0 讨论(0)
  • 2020-12-01 10:51

    First Google hit says:

    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.

    It usually seems to be a wsHttpBinding on one side and a basicHttpBinding on the other.

    0 讨论(0)
  • 2020-12-01 10:51

    I've seen this behavior today when the

       <service name="A.B.C.D" behaviorConfiguration="returnFaults">
            <endpoint contract="A.B.C.ID" binding="basicHttpBinding" address=""/>
        </service>
    

    was missing from the web.config. The service.svc file was there and got served. It took a while to realize that the problem was not in the binding configuration it self...

    0 讨论(0)
提交回复
热议问题