File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes javax.xml.ws webserviceprovider how to get POST parameters? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "javax.xml.ws webserviceprovider how to get POST parameters?" Watch "javax.xml.ws webserviceprovider how to get POST parameters?" New topic
Author

javax.xml.ws webserviceprovider how to get POST parameters?

ad dab
Greenhorn

Joined: Jun 17, 2009
Posts: 4
hi
I have created a RESTful webservice using javax.xml.ws. Webservice works fine with get parameters or as http:xyz/num1/12/num2/23

Problem is when i do request.getParameter("num1") and data is posted with method "POST" i dont see any parameter named num1

Any help?

I can post code if required

thanks
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hello!
As far as I understand you are trying to get path information from the HTTP request string.
If this is the case, then you can do as follows:
1. Call getMessageContext() on the WebServiceContext that was injected into your endpoint class.
2. Call get on the message context retrieved in step 1 using the key MessageContext.PATH_INFO.

See the interface javax.xml.ws.handler.MessageContext for other data that can be retrieved from the MessageContext.
Best wishes!
ad dab
Greenhorn

Joined: Jun 17, 2009
Posts: 4
hi
Thanks for responding.

When we are sending parameters as GET i.e. with query string service works fine.
When parameters are sent as POST method request.getParameter("paramname") returns null.

here is what i do
------------------
HttpServletRequest req = (HttpServletRequest) mc.get(MessageContext.SERVLET_REQUEST);
String xy = req.getParameter("num1");

this works when num1 is sent as get parameter


thanks
abhay
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
If you retrieve the value for MessageContext.QUERY_STRING from the MessageContext, do you see the parameters in the query string?
Best wishes!
ad dab
Greenhorn

Joined: Jun 17, 2009
Posts: 4
Code snippet
Query comes as null when its post

MessageContext mc = wsContext.getMessageContext();
String query = (String) mc.get(MessageContext.QUERY_STRING);
String path = (String) mc.get(MessageContext.PATH_INFO);
HttpServletRequest req = (HttpServletRequest) mc.get(MessageContext.SERVLET_REQUEST);
System.out.println("Query"+query+"");
return createSource(source,req);

Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi again!
I'll have to write some code to try this out, or, if you do not mind, take a closer look at your code.
ad dab
Greenhorn

Joined: Jun 17, 2009
Posts: 4
hi

Thanks for following up.

I did take a look and did search on google too. In fact couple of the developers from our team have same issue.

I will take a look again. If you find something please let me know .. Thanks for your help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javax.xml.ws webserviceprovider how to get POST parameters?
 
Similar Threads
CXF 2.2 @FormParam - Not working?
POST method parameters
Switch Case Problem
How to execute the mathematical string equation?
Problem Using toString method from a different class