res_this
asked on
How do i get the Soap envelope from a Axis webservice call
Hi ,
I am generating a wsdl through Axis and calling its method using Java Stub.I want to be able to be able to retrive the SoapEnvelope generated from the method call and parse it.Is there any API to do this?
I am generating a wsdl through Axis and calling its method using Java Stub.I want to be able to be able to retrive the SoapEnvelope generated from the method call and parse it.Is there any API to do this?
ASKER
Hi,
Thanks , but method call is going through the AxisServlet's doPost methood and through rpc to the webservice method.I am not using stubs .I tried to redirect to a custom servlet class which extends AxisServlet and could get hold of the request object.I need to pass one of the arguments in the request header to my webservice method.I had read about using MessageContext's SOAPMessage header object to pass parameters , but not sure Can you help with this regard
Thanks , but method call is going through the AxisServlet's doPost methood and through rpc to the webservice method.I am not using stubs .I tried to redirect to a custom servlet class which extends AxisServlet and could get hold of the request object.I need to pass one of the arguments in the request header to my webservice method.I had read about using MessageContext's SOAPMessage header object to pass parameters , but not sure Can you help with this regard
>>.I need to pass one of the arguments in the request header to my webservice method
can you clarify this?
All I want to know is weather you want to add SOAP Header? or HTTP Header?
I am also wondering why is that you are extending a axis servlet?
First can you please tell are you coding for webservice implementation or the webservice client implementation?
can you clarify this?
All I want to know is weather you want to add SOAP Header? or HTTP Header?
I am also wondering why is that you are extending a axis servlet?
First can you please tell are you coding for webservice implementation or the webservice client implementation?
ASKER
i am calling a webservice method say testmethod(x,y,z).When the Axis Servlet intercepts this method call from the webservice caller,the request object has a value in its header say m=n which I have to access inside my webservice method testmethod..When i print the incoming request inputstream(whose code i have attached below), i get the following
<?xml version="1.0" encoding="UTF-8"?><SOAP-EN V:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:c2o="http://optinuity.com/c2o" xmlns:wsa="http://schemas.xmlsoap.org/ws/2003/03/addressing" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Hea der><wsa:m ID>9a7ca1d c-5879-4c2 f-927c-c67 f8b462cb5< /wsa:mID>< wsa:ReplyT o>http://testbox:8080/itpam/soap</wsa:Re plyTo><wsa :Action>te stMethod</ wsa:Action ><wsa:Refe renceParam eters><c2o :ReplyMeth od>AsyncSo apResponse </c2o:Repl yMethod></ wsa:Refere nceParamet ers></SOAP -ENV:Heade r><SOAP-EN V:Body><te stMethod xmlns="urn:usmRequestServi ce">
<sessionID/>
<x>10001</x>
<y>1</y>
<z>10102</z>
</testMethod></SOAP-ENV:Bo dy></SOAP- ENV:Envelo pe>
I need to access the mID value inside the testmethod webservicecall.That's the reason I extending the Axis Servlet to get hold of the request header info.
<?xml version="1.0" encoding="UTF-8"?><SOAP-EN
<sessionID/>
<x>10001</x>
<y>1</y>
<z>10102</z>
</testMethod></SOAP-ENV:Bo
I need to access the mID value inside the testmethod webservicecall.That's the reason I extending the Axis Servlet to get hold of the request header info.
public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response){
try{
System.out.println(request.getHeaderNames());
// Traverse the HTTP headers and show them on the screen
for(Enumeration enumr = request.getHeaderNames(); enumr.hasMoreElements(); ) {
String header = (String)enumr.nextElement();
String value = request.getHeader(header);
System.out.println(" "+header+" = "+value);
}
super.doPost(request,response);
}
catch(Exception e){
e.printStackTrace();
}
}
>> String value = request.getHeader(header);
According me this only give access to HTTP Header and not the SOap Header,
Can you show me the code where you are actrually making the request to the web service.
According me this only give access to HTTP Header and not the SOap Header,
Can you show me the code where you are actrually making the request to the web service.
if you ask ideally you need to do something like this, create a soap client (stub) using axis and then invoke the methods of this stub (operations) via your servlet and then u can use my previous apporach, else u can try a direct client call some thing like this https://www.experts-exchange.com/questions/23396120/SOAP-client-with-AXIS-having-trouble-hitting-NET-Based-SOAP-Servers.html
ASKER
Hi all,
Thanks for the comments.The webservice call is made by a 3rd party component.According to my previous comment, the request inputstream does contain the soap envelope information.However, i was able to get this working , by adding the following code in my webservice method.
MessageContext mc = MessageContext.getCurrentC ontext();
MimeHeaders mh=mc.getRequestMessage(). getMimeHea ders();
String[] mhStr = mh.getHeader("mID");
log.info("Message ID"+mhStr[0]);
This is working fine.Is there any problem with this approach
Thanks for the comments.The webservice call is made by a 3rd party component.According to my previous comment, the request inputstream does contain the soap envelope information.However, i was able to get this working , by adding the following code in my webservice method.
MessageContext mc = MessageContext.getCurrentC
MimeHeaders mh=mc.getRequestMessage().
String[] mhStr = mh.getHeader("mID");
log.info("Message ID"+mhStr[0]);
This is working fine.Is there any problem with this approach
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In you xxxxxSoapBindingStub class in the particular method where u wanna capture req/res xml just add the following lines after the invoke() call.
Here is a sample from my helloService which takes a name.
Open in new window