Content Type application/soap+xml; charset=utf-8 was not supported by service

后端 未结 17 2323
长发绾君心
长发绾君心 2020-12-15 02:54

I am getting the error below while trying to add WCF service to WCFTestClient. I went through a number of solutions on the web but I couldn\'t get it to work.

Can

相关标签:
17条回答
  • 2020-12-15 03:00

    My case had a different solution. The client was using basichttpsbinding[1] and the service was using wshttpbinding.

    I resolved the problem by changing the server binding to basichttpsbinding. Also, i had to set target framework to 4.5 by adding:

      <system.web>
        <compilation debug="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5"/>
      </system.web>
    

    [1] the comunication was over https.

    0 讨论(0)
  • 2020-12-15 03:00

    I too had the same error in trace logs. My newly created function in API was throwing the same error but to my surprise, the old functions were performing good. The issue was - My contract data members had few variables of type object. soap-xml was not able to handle it well, however, I can see that array of object types (object[]) were getting passed without any issues. Only a simple object type was not getting parsed by soap. This could be one more reason why the services throw the above error.

    0 讨论(0)
  • 2020-12-15 03:04

    In my case same error was caused by missing

    [DataContract]
    ...
    [DataMember] 
    

    attributes in the returned data type.

    Check for that and try addinging those and see if it helps.

    0 讨论(0)
  • 2020-12-15 03:07

    My problem was our own collection class, which was flagged with [DataContract]. From my point of view, this was a clean approach and it worked fine with XmlSerializer but for the WCF endpoint it was breaking and we had to remove it. XmlSerializer still works without.

    Not working

    [DataContract]
    public class AttributeCollection : List<KeyValuePairSerializable<string, string>>
    

    Working

    public class AttributeCollection : List<KeyValuePairSerializable<string, string>>
    
    0 讨论(0)
  • 2020-12-15 03:09

    I had to add the ?wsdl parameter to the end of the url. For example: http://localhost:8745/YourServiceName/?wsdl

    0 讨论(0)
  • 2020-12-15 03:11

    As suggested by others this happens due to service client mismatch.

    I ran into the same problem, when was debugging got to know that there is a mismatch in the binding. Instead of WSHTTPBinding I was referring to BasicHttpBinding. In my case I am referring both BasicHttp and WsHttp. I was dynamically assigning the binding based on the reference. So check your service constructor as shown below

    Refer this image

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