0

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

Mike Atlas
  • 8,193
  • 4
  • 46
  • 62
capdragon
  • 14,565
  • 24
  • 107
  • 153

1 Answers1

2

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.

Johann Blais
  • 9,389
  • 6
  • 45
  • 65
  • +1 Thanks, this helps a lot, though, i would still like to know why "Generate Message Contracts" places the operation in the header and the other within the body? I would like to "Generate Message Contracts" but i need the operation call within the body so the service can understand it. – capdragon Mar 28 '11 at 13:05
  • Thanks, based on this question, please try to answer the following question: http://stackoverflow.com/questions/5475855/how-to-get-message-contract-to-send-soap-action-in-body-and-not-header – capdragon Mar 29 '11 at 16:35