capdragon
capdragon

Reputation: 14899

How to get message contract to send soap action in body and not header

When i use the "/messageContract" in my svcutil command, my soap message sends the action or operation in the header of the soap envelope and not the body. The remote endpoint is a vendor's Java based service which i have no control over.

I need the action to to be sent in the body but still use "/messageContract".

Does anyone know how to achieve this?

SOAP envelope WITH "/messageContract"

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

SOAP envelope WITHOUT "/messageContract"

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

my svcutil command:

svcutil /target:code http://localhost/sarpilot/xml/mywisdl.wsdl /messageContract /out:WebService.cs /config:WebService.config

Upvotes: 3

Views: 3800

Answers (1)

Mike Atlas
Mike Atlas

Reputation: 8231

Are truly sure your target (Java-based) web service requires a Microsoft-based namespace element in the SOAP body instead of the SOAP header? That seems bogus to me.

<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">GetCapabilities</Action>

Most web services only need the Action in the HTTP header, not as part of the SOAP body:

POST /StockQuote HTTP/1.1
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn
SOAPAction: "http://electrocommerce.org/abc#MyMessage"

<SOAP-ENV:Envelope...

Can you provide a raw, working SOAP request (including HTTP headers) for comparison? You can test it out independent from .NET by using this little web-page based client: Simplest SOAP example using Javascript. I assume from your other posting here which shows a "working" request that you really don't need the Microsoft Action element in your SOAP body.

Upvotes: 3

Related Questions