This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Web Services and the fly likes can a servlet have both soap request and simple request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "can a servlet have both soap request and simple request" Watch "can a servlet have both soap request and simple request" New topic
Author

can a servlet have both soap request and simple request

Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 418
I have to make a servlet which will take a request and then it has to check, whether the request has come in the form of soap message or a simple request and then do something accordingly.Please tell me how we can do this.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
Perhaps you could look at the request headers and forward the request to either a SOAP handling servlet or a simple request handling servlet. Do you have some particular SOAP toolkit in use already? What will be generating the client side request?

Bill
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
In the servlet's doPost method check the content type (ServletRequest.getContentType()). For a SOAP message this will be "text/xml", "application/xml" or "application/soap+xml". If it is one of those types use ServletRequestgetInputStream() or ServletRequest.getParameter("DATA") to access the request body. Then check whether it contains a SOAP envelope. Using XPath is probably the easiest way of accomplishing this.
Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 418
thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: can a servlet have both soap request and simple request