Gobliins
Gobliins

Reputation: 4026

Web Service SOAP seperate xml file for each Request/Response?

i am fairly new to WebServices so i got the idea of defining Envelopes with Requests and Responses.

My question is, if every request / response should get its own envelope in a FooRequest.xml, FooResponse.xml. Or can there be multiple Requests/Responses in an envelope? And if so, is it good to do multiple Requests in one envelope?

Upvotes: 0

Views: 1278

Answers (2)

Garry
Garry

Reputation: 4533

I think, since SOAP request is XML document so you can have multiple Envelopes elements (it wont give you any error) but only the first one will processed and sent to the server.

And if there is only one request so there should only be one response associated with request.

You try himself using any UI tool, as I tried with SOAPUI:

screenshot from SOAPUI

As you can see that even if you have multiple envelopes but only the first one will be sent to the server and response is associated with request.

Upvotes: 1

Roman Vottner
Roman Vottner

Reputation: 12839

XML files must have exactly one root-element. In case of SOAP messages, that root element is the envelope. Therefore one message must exactly have one envelope.

According to the spec the envelope has one body and may have a header. The schema does not define any upper bounds for body and element, though the default value here is 1 to my knowledge.

The spec further states for a body element:

The element MUST be present in a SOAP message and MUST be an immediate child element of a SOAP Envelope element. It MUST directly follow the SOAP Header element if present. Otherwise it MUST be the first immediate child element of the SOAP Envelope element.

This restricts you from defining multiple header or body elements within the SOAP envelope. So, a message needs one SOAP envelope and one SOAP body element and may contain one SOAP header right before the SOAP body. SOAP header and SOAP body have to be child elements of the SOAP envelope.

As the spec allows multiple body-entries, it is theoretically possible to send multiple requests with one SOAP message. In practice I haven't seen more than one though. Therefore, including multiple body-entries may depend on the underlying framework you use. I guess using industry standards like Apache CXF and similar frameworks should support it.

Upvotes: 1

Related Questions