代码之家  ›  专栏  ›  技术社区  ›  Be Kind To New Users

用C语言记录Soap消息#

  •  2
  • Be Kind To New Users  · 技术社区  · 6 年前

    我有一个C#console程序,它向SOAP服务发出请求。

    SOAP消息的这个接口是用 Microsoft.VSDesigner, Version 4.0.30319.42000. 通过以下步骤:

    1. 选择“添加服务引用”
    2. 选择高级
    3. 添加Web引用
    4. 命名服务
    5. 单击“添加引用”。

    此时,我已经生成了调用服务的代码。

    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.xxxxx.com/VerifyInsurance", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
    [return: System.Xml.Serialization.XmlElementAttribute("CoverageResponseDocument", Namespace="http://www.xxxxx.com/CoverageVerification/")]
    
    public CoverageResponseDocument VerifyInsurance([System.Xml.Serialization.XmlElementAttribute(Namespace="http://www.xxxxx.com/CoverageVerification/")] CoverageRequest CoverageRequest) 
    {
        object[] results = this.Invoke("VerifyInsurance", new object[] {
                        CoverageRequest});
        return ((CoverageResponseDocument)(results[0]));
    }
    

    通过更改代码或更改配置。

    我是一个长期的开发人员,但新的visualstudio,所以我会很感激一个答案,使用我在屏幕上看到的术语。

    1 回复  |  直到 6 年前
        1
  •  1
  •   MBB    6 年前

    嗨,有几点需要注意(虽然我接受这样一个事实:我无法更改代码来记录请求和响应,但下面是我检查过的几个其他选项,您可以尝试)-

    服务参考 并应用了诊断功能,能够将原始请求响应记录在日志文件中—您可以阅读有关跟踪的内容 here-

    1. 如果您有权访问web服务代码,那么就可以编写Soap扩展。

    所以soapextension是

    使用创建的XML Web服务的SOAP扩展的基类 ASP.NET.

    here -

    1. 另一种方法是 fiddler 在visualstudio外部监视http和https的通信量

    还有另一个线索,所以它谈论同样的。请看一看。

    Getting RAW Soap Data from a Web Reference Client running in ASP.net

    下面的讨论更多的是使用SOAP代理 . 添加web引用是引用客户端代理的旧方法。如果没有理由只使用web引用,那么使用服务引用而不是web引用。您可以在下面的线程中找到关于同一主题的更多详细信息。

    https://stackoverflow.com/questions/2158106/web-reference-vs-service-reference?answertab=active#tab-top