aspose file tools*
The moose likes Web Services and the fly likes How does the browser and web service communicate using SOAP? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "How does the browser and web service communicate using SOAP?" Watch "How does the browser and web service communicate using SOAP?" New topic
Author

How does the browser and web service communicate using SOAP?

Kelly Powell
Ranch Hand

Joined: Oct 29, 2010
Posts: 56
It is mentioned that web services communicate through SOAP. If I am going to call a web service through a browser (HTTP Get), then the browser must send a SOAP message to the web service. On which point does this message was converted to SOAP? Who is the one responsible for converting it to a SOAP message? If it is the browser, how did the browser knew that it must send its message as a SOAP message?

If it is okay, can you also provide me a detailed process on how the browser and the web service communicate. Thank you!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42946
    
  68
Your JavaScript code needs to create valid SOAP; that's not something that happens automatically. While there are probably libraries that help with that, nobody really uses SOAP from within a browser. Libraries such as Prototype and jQuery make it trivially easy to send REST requests that retrieve data via the JSON notation, so that's what's being used for browser-to-web service communication.

For Prototype, see http://www.prototypejs.org/learn/introduction-to-ajax and http://www.prototypejs.org/learn/json

(Also note that SOAP's popularity in general has taken a big hit in favor of REST in the last couple of years.)
Kelly Powell
Ranch Hand

Joined: Oct 29, 2010
Posts: 56
@Ulf Dittmer: Thanks for your clarification! I thought requests are converted to SOAP automatically before sending it to a web service.

So if I am using http ://address/webServiceName/method?var1=value to call a web service, does it mean that I am not using any SOAP to tranport my request? If yes, then how does the web service handle my request? What protocol/ format am I using? Am I using plain HTTP get to transport my request to the web service? I thought the request should be in SOAP format to be understood by the web service?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42946
    
  68
First off, web services can take different forms. SOAP is a popular one, as is REST. Both use HTTP as the transport protocol. The WebServicesFaq points to several articles that contrast these two styles.

So if I am using http ://address/webServiceName/method?var1=value to call a web service, does it mean that I am not using any SOAP to tranport my request?

If that's all you're sending, then yes - there's no SOAP. SOAP would be sent in the body of an HTTP request, and would typically not have parameters in the URL.

If yes, then how does the web service handle my request? What protocol/ format am I using? Am I using plain HTTP get to transport my request to the web service?

What you're using is closer to REST-type web services, where all parameters are transported as part of the URL (though, confusingly, not necessarily as URL parameters).
Kelly Powell
Ranch Hand

Joined: Oct 29, 2010
Posts: 56
First off, web services can take different forms. SOAP is a popular one, as is REST. Both use HTTP as the transport protocol. The WebServicesFaq points to several articles that contrast these two styles.

I see.

If that's all you're sending, then yes - there's no SOAP. SOAP would be sent in the body of an HTTP request, and would typically not have parameters in the URL.

So, since there is no SOAP, the body of my HTTP request does not contain anything?

@Ulf Dittmer: Thank you very much for answering my questions!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42946
    
  68
So, since there is no SOAP, the body of my HTTP request does not contain anything?

That depends on the HTTP method being used. If it's a GET, then the body is empty (the parameters would be part of the URL, as in the example you posted earlier). If it's a POST, then the parameters and/or other data would be in the body.
Kelly Powell
Ranch Hand

Joined: Oct 29, 2010
Posts: 56
@Ulf Dittmer: Thanks! I got it now.
 
 
subject: How does the browser and web service communicate using SOAP?