Hi all,
new to WS. How do you extract the SOAP object from a HttpServletRequest.
Mat
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35258
7
posted
0
I think you have that the wrong way around. If you're dealing with SOAP, then most implementations are based on servlets, and will provide access to the HttpServletRequest object in some way. But that is not generally necessary, as SOAP operates on a higher level than HTTP.
I'm not sure what you mean by "SOAP object", though - SOAP is a protocol, which can be (and has been) implemented in any number of ways. What exactly are you trying to do?
if (!StringUtil.isEmpty(req.getServletPath())&&
(req.getServletPath().indexOf("/services")!=-1))
then a RequestDispatcher dispatcher.forward(request, response)
is done to pass the soap request to Axis2 engine.
Other requests that are not ws are asked to authenticate via SSO.
Each WS soap request contains a user id that needs to be logged.
Logging needs to be done before the dispatcher.forward statement.
How can I get hold of the user id
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12271
1
posted
0
If the ID you want to extract is in the SOAP formatted message that is the body of the resource, you have your work cut out for you.
The SOAP servelet is going to want to see an unaltered input stream that forms the SOAP message so your filter will have to:
1. capture the complete SOAP message as text
2. parse out the ID you want
3. create an custom class extension of HttpServletRequestWrapper than can take the complete SOAP message from 1. and form a new InputStream that can be handed to the SOAP servlet. In other words, the servlet gets your custom wrapper instead of the original HttpServletRequest object.
This usually works ok, but since I have called simulateLogin I get the following error:-
org.apache.axis2.AxisFault: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog at [row,col {unknown-source}]: [1,0] on server
Do I need to clone the HttpServletRequest going into simulateLogin due to it doing a read
I have tried writting the following to clone HttpServletRequest but this did not work
class CustomRequestWrapper implements Cloneable
{
private HttpServletRequest request=null;
public CustomRequestWrapper(HttpServletRequest request)
{this.request=request;}
public CustomRequestWrapper(){ }
public HttpServletRequest getHttpServletRequest(){
return request;
}
public Object clone()
{
CustomRequestWrapper clone = new CustomRequestWrapper();
clone.request=request;
return clone;
}
}
Any ideas
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35258
7
posted
0
You'll need to implement the full step #3 William mentions above. Just making a copy of the request object pointer accomplishes nothing.
Mat Anthony
Ranch Hand
Joined: May 21, 2008
Posts: 195
posted
0
Hi Bill/Ulf,
followed the above and get the following error:-
org.apache.axis2.AxisFault: java.lang.ClassCastException on server