C# HTTP 标头或 SOAP 标头中的 WCF Soap 操作?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2142207/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WCF Soap Actions in HTTP header or SOAP header?
提问by WayneC
I'm a little confused about how SOAPAction is implemented in WCF (and other web service frameworks for that matter).
我对 SOAPAction 如何在 WCF(以及其他与此相关的 Web 服务框架)中实现感到有些困惑。
In a test client, I have a Client Message Inspector configured to grab both the SOAP message and any HTTP headers that are being sent with the request. At least here in the client message inspector, the action shows up as an element in the SOAP Header:
在测试客户端中,我有一个客户端消息检查器配置为获取 SOAP 消息和随请求发送的任何 HTTP 标头。至少在客户端消息检查器中,该操作显示为 SOAP 标头中的一个元素:
<s:Header>
<Action ... >http://myurl.com/2009/11/MyService/MyMethod</Action>
However, if I view the request in Fiddler, the Action
element is missing and instead there is now an additional entry in the HTTP Headers:
但是,如果我在 Fiddler 中查看请求,Action
则缺少该元素,而现在 HTTP 标头中有一个附加条目:
SOAPAction: "http://myurl.com/2009/11/MyService/MyMethod"
Can anyone explain what the heck is going on??
谁能解释一下这是怎么回事??
Thanks!
谢谢!
采纳答案by gbjbaanb
This is a problem with WCF not following the standards.
这是 WCF 不遵循标准的问题。
SOAP 1.1 uses the SOAPAction header to decide what method to call, but this was a bit messy as the method name was embedded elsewhere in the message. SOAP 1.2 resolved this and added the action to content-type header, and deprecated the SOAPAction header (though its now an optional for those clients that still want to send it).
SOAP 1.1 使用 SOAPAction 头来决定调用什么方法,但这有点混乱,因为方法名称嵌入在消息的其他地方。SOAP 1.2 解决了这个问题,并将操作添加到 content-type 标头,并弃用了 SOAPAction 标头(尽管它现在对于那些仍然想要发送它的客户端来说是可选的)。
See an o'reillyblog page for some details.
有关详细信息,请参阅o'reilly博客页面。
回答by marc_s
Seems to me as if those two are equivalent, no? I guess Fiddler just interprets that SOAP header "", calling it "SOAPAction". The value appears to be the same, no?
在我看来,这两个是等价的,不是吗?我猜 Fiddler 只是解释了那个 SOAP 标头“”,称之为“SOAPAction”。值似乎相同,不是吗?
What you get from the Client Message Inspector is the raw XML data (the raw format of the SOAP message) as it travels across the copper wire (or fibre). What Fiddler gives you is a higher-level HTTP-oriented interpretation of that same XML message, I would say.
您从 Client Message Inspector 获得的是原始 XML 数据(SOAP 消息的原始格式),因为它穿过铜线(或光纤)。我会说,Fiddler 为您提供的是同一 XML 消息的更高级别的面向 HTTP 的解释。
Judging from other blog posts and articles I've found on Fiddler and SOAP (e.g. this blog post- check out the "Sample Capture" section towards the end), it almost seems to me as if Fiddler will strip out the SOAP headers and interpret / show them in a custom format, leaving just the SOAP body to be shown as body of the message being displayed.
从我在 Fiddler 和 SOAP 上找到的其他博客文章和文章来看(例如这篇博客文章- 查看最后的“示例捕获”部分),在我看来,Fiddler 几乎会去除 SOAP 标头并解释/ 以自定义格式显示它们,只留下 SOAP 正文显示为正在显示的消息正文。
Is there an actual technical problem? Or just a question of how to interpret the two formats?
是否存在实际的技术问题?或者只是如何解释这两种格式的问题?
回答by FelixB
Putting SOAP action in an HTTP header is part of SOA specification, and WCF just implements SOAP specification in this case.
将 SOAP 操作放在 HTTP 标头中是 SOA 规范的一部分,在这种情况下,WCF 只是实现了 SOAP 规范。
Read here: http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383528
在这里阅读:http: //www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383528
回答by John Saunders
Chances are that you're seeing the difference between SOAP 1.1 and SOAP 1.2.
您可能会看到 SOAP 1.1 和 SOAP 1.2 之间的区别。