【发布时间】:2016-06-03 14:02:10
【问题描述】:
我编写的代码与第 3 方网络服务集成。问题是服务的soap操作在测试和生产环境中不同,尽管这个URIs不重要,如果soap操作URI错误,主机返回400 - 错误的请求错误。 主机服务是用 Java 编写的。我们正在使用 C# Web 服务代理。
参考.cs
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://1.1.1.1:9080/wss/Ping", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("PingResp", Namespace="http://namespace/data")]
public PingResp Ping([System.Xml.Serialization.XmlElementAttribute("PingReq", Namespace="http://namespace/data")] PingReq PingReq) {
object[] results = this.Invoke("Ping", new object[] {
PingReq});
return ((PingResp)(results[0]));
}
对于生产环境,SoapAction 是:
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://2.2.2.2:9080/wss/Ping", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
有没有办法使这种动态化,即是否可以根据配置设置更改肥皂操作 URI?
我尝试过扩展SoapDocumentMethodAttribute 类,但它是密封的。
【问题讨论】:
标签: c# web-services