I created a C# proxy class via wsdl.exe from a WSDL-URL. I'm using this proxy class in the context of a web app which I do not control (so there's no way to change a web.conf or similar). I'm also unable to change anything in the web service that I'm talking to.
When calling the web service, I receive the following exception:
Client found response content type of 'multipart/related; type="application/xop+xml";
boundary="uuid:5c314128-0dc0-4cad-9b1a-dc4a3e5917bb"; start="<root.message@cxf.apache.org>";
start-info="application/soap+xml"', but expected 'application/soap+xml'.
From what I've read, this is a problem with MTOM being used by the web service. Now I'm trying to tell my class to accept MTOM, but all I've found is configuration in the web.conf.
The proxy class is derived from SoapHttpClientProtocol and looks like this (relevant parts):
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name = "myrequestSoapBinding", Namespace = "http://namespace.of.company.of.webservice/")]
public class myrequest : System.Web.Services.Protocols.SoapHttpClientProtocol
{
public myrequest(string url)
{
this.SoapVersion = System.Web.Services.Protocols.SoapProtocolVersion.Soap12;
this.Url = url;
}
[return: System.Xml.Serialization.XmlElementAttribute("return", Form = System.Xml.Schema.XmlSchemaForm.Unqualified, DataType = "base64Binary")]
public byte[] getDocuments([System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, DataType = "base64Binary")] byte[] input)
{
try
{
object[] results = this.Invoke("getDocuments", new object[] {
input});
return ((byte[])(results[0]));
}
catch (Exception ex)
{
var realResponse = StripResponse(ex.Message);
return Encoding.UTF8.GetBytes(realResponse.ToString());
}
}
}
The try ... catch in getDocuments is a hacky workaround that gets the 'real' service response out of the exception Message - which is not really how I want to implement this.
So my question is: Is there a way to change the binding in the proxy class to accept MTOM responses?