-URLwsdl.exe
から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
ingetDocuments
は、例外から「実際の」サービス応答を取得するハックな回避策です。Message
これは、私がこれを実装したい方法ではありません。
だから私の質問は:MTOM
応答を受け入れるようにプロキシ クラスのバインディングを変更する方法はありますか?