Reputation: 624
I am trying to connect to a third-party service described as a .wsdl file. I can't provide the whole file because it's too long, but essential parts are:
<wsdl:port name="ec2HttpSoap12Endpoint" binding="tns:ec2Soap12Binding">
<soap12:address location="<service url>.ec2HttpSoap12Endpoint/"/>
</wsdl:port>
<wsdl:binding name="ec2Soap12Binding" type="tns:ec2PortType">
<soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="someOperation">
<soap12:operation soapAction="urn:someOperation" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
...
</wsdl:binding>
My code is simple:
ec2PortTypeClient client = new ec2PortTypeClient("ec2HttpSoap12Endpoint", "<service url>");
var response = ePortConnect.someOperation(...).Result.@return;
But I get an exception:
ProtocolException: The content type multipart/related; boundary="MIMEBoundary_f9ac1ac9023b2de2dbb6e3f07d0952ff0bbdfdd7433cd9ec"; type="application/xop+xml"; start="<[email protected]>"; start-info="application/soap+xml"; action="urn:someOperation" of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). ... The first 1024 bytes of the response were:
And then a totally normal response from the server!
Looks like the definition is normal, but response type should be set to XOP, or my C# code is wrong. The server is responding normally, but response isn't being parsed due to type mismatch. What am I doing wrong?
Supplier claims that .wsdl is correct and I believe them. But what can possibly be wrong in my two-line code?
Link to a complete .wsdl file.
Upvotes: 3
Views: 1530
Reputation: 2387
Try Mtom
instead of text to encode SOAP messages.
Config: <binding messageEncoding="Mtom"> Code: binding.MessageEncoding = WSMessageEncoding.Mtom;
Upvotes: 1