2

I would like to send a soap response which is pure xml i.e without a soap envelope. This is my current response

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/">
   <SOAP-ENV:Body>
      <ns1:getMemberResponse>
         <User>
            <ValidationErrors/>
            <IsDeleted>false</IsDeleted>
            <ID>1691</ID>......

However, this is the response I would like to send

<User xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <ValidationErrors />
  <IsDeleted>false</IsDeleted>
  <ID>1691</ID>.....

Does anyone have any suggestions?

Many thanks in advance

mikedhart
  • 413
  • 2
  • 4
  • 14
  • If you remove the soap envelop, your response is not a soap-response and the caller, which uses a soap client to invoke your server, will not understand the response. If you don't need the soap envelop, just rid off the soap's stuff and use a rest-like request – Francesco Laurita Jan 25 '12 at 16:56
  • Thanks for your response @Francesco. The caller in this case is a .NET application. Are you suggesting that I should just print out the XML? – mikedhart Jan 25 '12 at 17:07
  • No, If the caller uses a soap-request, than you have to reply with a soap-response. Maybe I don't understand why you need to rid off the soap envelope around your response. – Francesco Laurita Jan 25 '12 at 17:14

1 Answers1

8

SOAP is a protocol and as such defines the format of communication (which includes a message composed of an Envelope, Body and optional Header).

If you just send the response back with no Envelope, you are breaking the protocol. Your clients (who are expecting a properly formatted SOAP response) will fail.

If you use a SOAP web service then you must send the Envelope.

If this is cumbersome for you and you are only interested in the payload, then maybe a RESTful web service would be more appropriate instead of a SOAP one? It is for you to decide given your particular situation.

Community
  • 1
  • 1
Bogdan
  • 23,890
  • 3
  • 69
  • 61