Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do SOAP Web services support only "POST" http method

I faced this question on one of interviews, so could you please tell whether SOAP Web services support only "POST" http method or there is some way to accept other methods on the server side?

like image 600
evgeniy44 Avatar asked Oct 13 '14 11:10

evgeniy44


People also ask

Does SOAP only use HTTP?

SOAP is actually agnostic of the underlying transport protocol and can be sent over almost any protocol such as HTTP, SMTP, TCP, or JMS. As was already mentioned, the SOAP message itself must be XML-formatted.

Does SOAP use HTTP or https?

SOAP may also be used over HTTPS (which is the same protocol as HTTP at the application level, but uses an encrypted transport protocol underneath) with either simple or mutual authentication; this is the advocated WS-I method to provide web service security as stated in the WS-I Basic Profile 1.1.

Does SOAP API use HTTP methods?

SOAP messages are formatted in XML and are typically sent using HTTP (hypertext transfer protocol).

Is a SOAP request an HTTP request?

Yes, Servlet request and Web service request both are normal HTTP request and yes, SOAP web service internally use HTTP POST. SOAP message mostly send data using XML format.


2 Answers

I always used POST but according to the W3C standard, SOAP supports both POST and GET methods.

Edit: After some research, it seems that it's not completely true, as you can see here. It is theoretically possible to use GET because POST and GET are methods of HTTP transport protocol and SOAP can be used over HTTP.

But as you know, GET includes the request in the query string. SOAP requests (XML messages) are usually too complex and verbose to be included in the query string, so almost every implementation (for example JAX-WS) supports only POST.

like image 103
Eaque Avatar answered Sep 20 '22 01:09

Eaque


Thread is three years old but I think that there will be still a lot of people who will give this same question to themselves and will find wrong answer in the web. The answer to the question is no, GET method can be used too.

According to SOAP specification, which can found here: https://www.w3.org/TR/2007/REC-soap12-part0-20070427/#transport both GET and POST methods can be used to exchange SOAP messages over http. The use of the HTTP POST method for conveying SOAP messages in the bodies of HTTP request uses a pattern called SOAP request-response message exchange pattern. In the case of HTTP GET a pattern is used called SOAP response message exchange pattern. The main difference of this two patterns is:

The first type of interaction allows for the use of data within the body of a HTTP POST to create or modify the state of a resource identified by the URI to which the HTTP request is destined. The second type of interaction pattern offers the ability to use a HTTP GET request to obtain a representation of a resource without altering its state in any way. In the first case, the SOAP-specific aspect of concern is that the body of the HTTP POST request is a SOAP message which has to be processed (per the SOAP processing model) as a part of the application-specific processing required to conform to the POST semantics. In the second case, the typical usage that is forseen is the case where the representation of the resource that is being requested is returned not as a HTML, or indeed a generic XML document, but as a SOAP message. That is, the HTTP content type header of the response message identifies it as being of media type "application/soap+xml"

So both GET and POST methods can be used. The other thing is that in practice mostly POST method is used.

The bad thing is that when comparing RESTful services with SOAP services, as an advantage of REST people are bringing caching, which is not available in SOAP, because SOAP uses only POST. This is totally wrong.

like image 35
Vahagn Nahapetyan Avatar answered Sep 23 '22 01:09

Vahagn Nahapetyan