2

我有一个基于 SOAP 的 Web 服务,带有关联的 reference.cs 文件(不是 WCF)。服务返回无效响应。reference.cs 文件有一个我想进入的 testRequest 方法。我对服务的控制有限,所以我想用我自己的测试响应覆盖 results[0] 行,以尝试确定响应无效的确切原因。但是,我不能进入 testRequest。为什么不?结果[0]到底是什么?我尝试使用字符串中的 Soap XML 自己进行转换,但我收到一条消息说我无法从字符串转换到该对象。如果它不是字符串,那么此时的结果 [0] 是什么?

    [System.Web.Services.Protocols.SoapHeaderAttribute("SecurityValue")]
    [System.Web.Services.Protocols.SoapHeaderAttribute("MessageHeaderValue")]
    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
    [return: System.Xml.Serialization.XmlElementAttribute("TestResponse", Namespace="http:/test/Services")]
    public TestResponse testRequest([System.Xml.Serialization.XmlElementAttribute("TestRequest", Namespace="http://Test.com/TestServices")] TestRequestTestRequest1) {
        object[] results = this.Invoke("TestRequest", new object[] {
                    TestRequest1});
        return ((TestResponse)(results[0]));
    }

更新 #1 您可以通过转到工具 => 选项 => 调试 => 常规并取消选中“仅启用我的代码”来进入 response.cs。问题是请求到达了我的电脑,但在 this.Invoke 被调用之后“结果”变量为空。我现在的问题是如何拦截 this.Invoke 正在进行的调用并插入我自己的响应。我没有开发人员访问实际服务的权限。也许我需要编写一个测试服务......

4

1 回答 1

1

我创建了一个测试服务,它只返回一个硬编码的 SOAP 响应。这有助于我诊断响应问题。问题最终是缺少命名空间

于 2012-10-29T12:00:04.483 回答