开发者

Difference between Service References "Generate Message Contracts" ON and OFF

开发者 https://www.devze.com 2023-02-20 01:34 出处:网络
So i noticed if i \"Generate Message Contracts\" then my SOAP envelope has the operation in the header:

So i noticed if i "Generate Message Contracts" then my SOAP envelope has the operation in the header:

<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>

And the code is much cleaner and makes more sense (BUT DOES NOT WORK on the vendors remote Java based web service):

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

On the othe开发者_如何学Gor hand, if i leave it off the SOAP Envelope has the operation in the body as it should (works on the vendor):

<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>

But the code doesn't make as much sense:

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

Can someone give me a good explanation as to what is going on here? Why is this?


The Generate Message Contract option allows the proxy generator to create message contracts based on the service definition. It is useful when you want to access the SOAP structure of the messages.

The difference is that the message contract implies that the client knows about the message definition beforehand, hence the mustUnderstand attribute.

0

精彩评论

暂无评论...
验证码 换一张
取 消