【发布时间】:2014-02-13 16:32:34
【问题描述】:
我正在向网络服务发送请求。我正在使用提琴手来监控结果。我确实在提琴手中看到了来自网络服务的响应。但在我的 .net 代码中总是为 null。
var svc = new ESB.publishPolicyServices();
publishPolicyResponse response = svc.publishPolicyData(req);
响应始终为空。我正在考虑,可能它没有将原始响应 xml 转换为 publishPolicyResponse 类型。这就是为什么我没有得到它。
这是 hte web 服务端的错误还是我的 .net 代码?如果您需要更多代码来找出问题所在,请告诉我。
更新:
这是我从提琴手那里得到的响应 xml。
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<message>success</message>
</soapenv:Body>
</soapenv:Envelope>
这是 wsdl 中的响应类型。
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.18060")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://www.xmlns.abc.com/abc/services/publishPolicyData/envelope/1.0")]
public partial class publishPolicyResponse {
private string messageField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string message {
get {
return this.messageField;
}
set {
this.messageField = value;
}
}
}
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("publishPolicyData", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("publishPolicyResponse", Namespace="http://www.xmlns.abc.com/abc/services/publishPolicyData/envelope/1.0")]
public publishPolicyResponse publishPolicyData([System.Xml.Serialization.XmlElementAttribute(Namespace="http://www.xmlns.abc.com/abc/services/publishPolicyData/envelope/1.0")] publishPolicyRequest publishPolicyRequest) {
object[] results = this.Invoke("publishPolicyData", new object[] {
publishPolicyRequest});
return ((publishPolicyResponse)(results[0]));
}
【问题讨论】:
-
let me know if you need more codes to figure out what the problem is.我们愿意。如果其他一切正常,您提供的小块应该可以工作。我在想,也许您必须在客户端应用程序中更新 WS 的代理定义? -
抱歉,不知道我还应该包括什么。
-
从代码上看不像,但你确定某些事情没有异步完成吗?
-
下载并安装soapui会发生什么?通过它测试网络服务,您可以确定问题是您的客户端代码还是网络服务?
-
您是否有权访问 Web 服务的源代码,以便在需要时对其进行调试?您的代码是否在上面的 try/catch 语句中发布?如果 Web 服务调用不在 try/catch 块中,是否会失败。试图确保你没有吞下异常
标签: c# web-services c#-4.0