這裏的交易:在Message.CreateMessage中,「action」參數的含義是什麼?
public static Message CreateMessage(
MessageVersion version,
MessageFault fault,
string action)
行動:如何應處理的消息的描述。
你們在那裏放什麼? 「小心輕放!!!」或「易碎」?它到底有什麼不同嗎?
這裏的交易:在Message.CreateMessage中,「action」參數的含義是什麼?
public static Message CreateMessage(
MessageVersion version,
MessageFault fault,
string action)
行動:如何應處理的消息的描述。
你們在那裏放什麼? 「小心輕放!!!」或「易碎」?它到底有什麼不同嗎?
「Action」是消息頭中的字符串之一。
例如,該呼叫
var m = Message.CreateMessage(MessageVersion.Default, "http://tempuri.org/MyMethod");
生成此消息
<s:Envelope
xmlns:a="http://www.w3.org/2005/08/addressing"
xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Header>
<a:Action s:mustUnderstand="1">http://tempuri.org/MyMethod</a:Action>
</s:Header> <s:Body />
</s:Envelope>
每個消息具有 「動作」 頭,並且每個WCF操作具有 「動作」 屬性。 WCF系統將在確定將每條消息分派給哪個操作時比較這些值。
通常情況下,您不是手動生成消息,因此您不必擔心這一點 - 它的所有操作都按默認值處理。
當你定義了服務合同,你可以一個動作字符串操作明確相關聯:
[ServiceContract]
interface MyService
{
[OperationContract(Action="http://tempuri.org/MyMethod")]
void ThisIsntReallyCalledMyMethod(string parameter1);
}
我asked a question about the SOAPAction recently: - 我認爲是SOAPAction頭是路由信息使用WSDL操作中,但我沒有設法找到任何東西,其中明確指出,@soapAction ATTRIB必須是含有中是唯一的操作(這似乎是一個理智的WSDL路由組件的先決條件......)
它被使用 - 對於SOAP 1.1,SOAPAction頭包含要調用的方法。這被轉移到SOAP 1.2的內容類型頭文件中,然後WS-Addressing再次將它移動到別的地方。只要不打擾使用SOAP,如果你想要任何理智的話:) – gbjbaanb 2012-10-25 16:17:18
這可能幫助:http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/faddaf03-17a2-4c3d-a0ea-88add3d88323 – Bernard 2010-08-30 18:26:39