简体   繁体   English

如何获取SOAP标头为XML?

[英]How do I get the SOAP headers as XML?

How can I get the SOAP header of my web service function as xml? 如何获得Web服务功能的SOAP标头为xml?

I need an XML version of my working SOAP header to use as an example for someone with broken SOAP headers. 我需要一个工作SOAP头的XML版本,以作为SOAP头损坏的人的示例。 He's using a different programming language, but since the headers are sent in XML, we're hoping we can compare those easily. 他使用的是另一种编程语言,但是由于标头是以XML发送的,因此我们希望可以轻松比较它们。 I'm using C# and ToString() just gives me the name of the object. 我正在使用C#和ToString()只是给我对象的名称。 After googling, I tried Fiddler, but that didn't catch anything, and SOAP Extensions look way too complicated for what seems like a really simple task. 谷歌搜索之后,我尝试了Fiddler,但是没有找到任何东西,并且SOAP扩展对于看起来非常简单的任务而言似乎过于复杂。

There is no easy way to do this with ASMX web services. 对于ASMX Web服务,没有简单的方法可以做到这一点。 If you were using WCF, it would be a trivial matter of turning on message logging. 如果您使用的是WCF,则打开消息日志记录将变得很简单。

Fiddler should catch everything, and it's well worth learning how to use. Fiddler应该抓住一切,值得学习如何使用。 Be sure to look in the online documentation to learn how to capture traffic from localhost to localhost. 确保查看在线文档以了解如何捕获从本地主机到本地主机的流量。

The accepted answer to this question mentions that you can capture traffic to a web service using soapUI. 问题的可接受答案提到您可以使用soapUI捕获到Web服务的流量。 You can use it to act as a proxy or HTTP tunnel in order to capture messages sent to your web service. 您可以使用它充当代理或HTTP隧道,以捕获发送到Web服务的消息。 I think using it in HTTP Tunnel mode makes sense, because then you won't have to do anything with your client other than to point the URL to soapUI instead of your actual service. 我认为在HTTP隧道模式下使用它是有道理的,因为这样,您无需对客户端进行任何操作,只需将URL指向soapUI而不是实际的服务即可。

The soapUI website talks about the SOAP Monitor feature, though I don't think it offers a good explanation for setting up the HTTP tunnel. soapUI网站讨论了SOAP Monitor功能,尽管我认为它不为设置HTTP隧道提供很好的解释。

Here are the steps involved (based on soapUI 3.0.1): 这是涉及的步骤(基于soapUI 3.0.1):

  1. Open Soap UI 打开Soap UI
  2. create a New soapUI Project... 2.1 Give your project a name 2.2 Enter the path to your service's WSDL ( http://localhost/.../YourService.asmx?WSDL ) 创建一个新的soapUI项目... 2.1为您的项目命名2.2输入服务的WSDL的路径( http://localhost/.../YourService.asmx?WSDL
  3. Right-click on the project you just created 右键单击刚刚创建的项目
  4. Select "Launch SOAP Monitor" 选择“启动SOAP监视器”
  5. Choose "HTTP Tunnel" 选择“ HTTP隧道”
  6. Specify an unused port number for "Port". 为“端口”指定一个未使用的端口号。 The default will probably work. 默认值可能会起作用。
  7. Enter the URL to your web service in "Set endpoint for HTTP Tunnel" 在“设置HTTP隧道的终结点”中输入Web服务的URL。
  8. If you are using SSL, then you may need to fill in some of the other fields; 如果使用的是SSL,则可能需要填写其他一些字段。 otherwise, click OK 否则,请单击确定
  9. The HTTP tunnel is running, so now just reconfigure a client to use the HTTP tunnel instead of the actual web service. HTTP隧道正在运行,因此现在只需将客户端重新配置为使用HTTP隧道而不是实际的Web服务即可。 So if your actual service is " http://localhost:1234/YourService.asmx ", then reconfigure your client to use " http://localhost :{Port}/YourService.asmx" where {Port} is the number you entered in step #6. 因此,如果您的实际服务是“ http:// localhost:1234 / YourService.asmx ”,则将客户端重新配置为使用“ http:// localhost :{Port} /YourService.asmx”,其中{Port}是您输入的数字在步骤#6中
  10. Now just run your client normally. 现在,只需正常运行客户端即可。 You'll see the traffic logged in the soapUI interface. 您将在soapUI界面中看到记录的流量。 Select a message and click on the "Message Content" button at the bottom of the window to view the actual SOAP message. 选择一条消息,然后单击窗口底部的“消息内容”按钮以查看实际的SOAP消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM