wsdl.exe
我通过-URL创建了一个 C# 代理类WSDL
。我在我无法控制的 Web 应用程序的上下文中使用此代理类(因此无法更改 aweb.conf
或类似内容)。我也无法更改正在与之交谈的 Web 服务中的任何内容。
调用 Web 服务时,我收到以下异常:
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'.
根据我的阅读,这是Web 服务使用MTOM的问题。现在我试图告诉我的班级接受 MTOM,但我发现的只是web.conf
.
代理类派生自SoapHttpClientProtocol
并且看起来像这样(相关部分):
[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());
}
}
}
try ... catch
in是一个 hacky 解决方法,可以从getDocuments
异常中获取“真正的”服务响应Message
——这并不是我真正想要实现的方式。
所以我的问题是:有没有办法改变代理类中的绑定来接受MTOM
响应?