SoapServer send response without envelope

做~自己de王妃 提交于 2019-12-24 04:21:50

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/9006169/soapserver-send-response-without-envelope

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!