2011-03-25 37 views
0

所以我發現,如果我「生成消息協定」,那麼我的SOAP信封頭中的操作:差異「生成消息協定」 ON和OFF

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
<s:Header> 
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">GetCapabilities</Action> 
</s:Header> 
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"></s:Body> 
</s:Envelope> 

和代碼是更清潔和更有意義(但不會對供應商工作的遠程基於Java的Web服務):

Client client = new Client(); 
GetCapabilitiesResponse response = client.GetCapabilities(new GetCapabilitiesRequest()); 
litCapabilities.Text = response.Capabilities.version; 
client.Close(); 

在另一方面,如果我離開它關閉了SOAP信封在體內運行,因爲它應該( 作品於供應商):

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
<s:Header></s:Header> 
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
<GetCapabilities xmlns="http://www.opengis.net/cat/csw/2.0.2"></GetCapabilities> 
</s:Body> 
</s:Envelope> 

但代碼不會作出太大的意義:

Client client = new Client(); 
CapabilitiesType response = client.GetCapabilities(new GetCapabilitiesType1()); 
litCapabilities.Text = response.version; 
client.Close(); 

有人可以給我一個很好的解釋爲這到底是怎麼回事呢?爲什麼是這樣?

回答

2

生成消息合約選項允許代理生成器根據服務定義創建消息合約。當你想要訪問消息的SOAP結構時,這很有用。

區別在於消息契約意味着客戶端事先知道消息定義,因此必須瞭解mustUnderstand屬性。

+0

+1謝謝,這有助於很多,但我仍然想知道爲什麼「生成郵件合同」將操作放在標題中而另一個放在正文中?我想「生成消息合約」,但我需要在本體內進行操作調用,以便服務可以理解它。 – capdragon 2011-03-28 13:05:37

+0

謝謝,基於這個問題,請嘗試回答以下問題:http://stackoverflow.com/questions/5475855/how-to-get-message-contract-to-send-soap-action-in-body-和未標頭 – capdragon 2011-03-29 16:35:26