• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
ad dab
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic