I am trying to consume a web service (SOAP API) but when the function is called, I get this exception:
The content type multipart/related; type="application/xop+xml"; boundary="uuid:53c58624-2aef-492e-83df-1129be39d10d"; start="<[email protected]>"; start-info="text/xml" 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. The first 1024 bytes of the response were: '--uuid:53c58624-2aef-492e-83df-1129be39d10d
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"/><soap:Body><ns2:exportDevicesResponse xmlns:ns2="http://devicemgmt.nbapi.cgms.cisco.com/"><deviceReport><data><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:[email protected]"/></data><date>2021-06-24T14:25:45.877-04:00</date><query>base.Channel.exportDevicesAsync(request)</query><status>COMPLETED</status></deviceReport></ns2:exportDevicesResponse></soap:Body></soap:Envelope>
--uuid:53c58624-2aef-492e-83df-1129be39d10d
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>
Content-Disposition: attachment;name="130_1624559145'.
I'm using .NET Core 3.1 and used this Medium Article to set up my WSDL files/Connected Services. I have tried adding the following to my App.config file (though I'm not sure if I have it actually attached, it still has the green + sign). But it didn't seem to work.
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding messageEncoding="Mtom">
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
I have also tried:
BasicHttpBinding binding = new BasicHttpBinding();
binding.MessageEncoding = WSMessageEncoding.Mtom;
But it doesn't seem to work because .MessageEncoding does not seem to be supported in .NET Core 3.1 and only in .NET Framework. So, does anyone know of a fix to the exception or to allow the binding to be encoded as Mtom?