You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Sergey Pulyaev <Se...@intego-group.com> on 2008/06/04 09:00:46 UTC

How to retreive XML request

I use Jetty6 as container and I want to retrieve the XML request as string if I have exception during the web service run...

Is it possible?

 

I tried to use 

((HttpServletRequest) getMessageContext().get(AbstractHTTPDestination.HTTP_REQUEST)) .getInputStream()

But I'm failed to get information.

 

I tried to get the XML document but it contains just soap message with clean 

            Message inMessage = msgContext.getWrappedMessage().getExchange().getInMessage();

            xmlRes = XmlUtils.formatXMLDocument(inMessage.getContent(org.w3c.dom.Node.class), true);

 

But it returns just that:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.pc2.takecharge.com/">

   <soapenv:Header/>

   <soapenv:Body/>

</soapenv:Envelope>

 

Is there any possibility to get the whole xml of soap request?

 

Best regards

                Sergey


--------
This data is for general information only and shall not be used to produce documents of any kind without same being submitted to, reviewed by, and approved by Intego in writing. All data is subject to change. User assumes all liability relating to the use of this data and agrees to release, indemnify, and hold harmless Intego from any and all claims relating said use. User is responsible to check for any viruses before use. 

Re: How to retreive XML request

Posted by Daniel Kulp <dk...@apache.org>.

Short of using an Interceptor/Handler, I'm not sure if you can.   The  
input stream is definitely completely consumed so there wouldn't be  
data from that.     My first thought was to configure the  
SAAJInInterceptor onto the input chain.   That gets you part way as it  
would construct an SAAJ model for the SOAP message.   However, you  
have to delve into some CXF proprietary things to get it:

((WrappedMessageContext 
)getMessageContext()).getWrappedMessage().getContent(SOAPMessage.class);


The only other option would be to write your own interceptors.   You  
could subclass the SAAJInIntereptor (or write an interceptor that runs  
immediately after it), that would just do:

message.put("SAAJ", message.getContext(SOAPMessage.class));
to copy the SAAJ model into the properties where you could then do:
getMessageContext().get("SAAJ");

Dan




On Jun 4, 2008, at 3:00 AM, Sergey Pulyaev wrote:

> I use Jetty6 as container and I want to retrieve the XML request as  
> string if I have exception during the web service run...
>
> Is it possible?
>
>
>
> I tried to use
>
> ((HttpServletRequest)  
> getMessageContext 
> ().get(AbstractHTTPDestination.HTTP_REQUEST)) .getInputStream()
>
> But I'm failed to get information.
>
>
>
> I tried to get the XML document but it contains just soap message  
> with clean
>
>             Message inMessage =  
> msgContext.getWrappedMessage().getExchange().getInMessage();
>
>             xmlRes =  
> XmlUtils 
> .formatXMLDocument(inMessage.getContent(org.w3c.dom.Node.class),  
> true);
>
>
>
> But it returns just that:
>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/ 
> " xmlns:ws="http://ws.pc2.takecharge.com/">
>
>    <soapenv:Header/>
>
>    <soapenv:Body/>
>
> </soapenv:Envelope>
>
>
>
> Is there any possibility to get the whole xml of soap request?
>
>
>
> Best regards
>
>                 Sergey
>
>
> --------
> This data is for general information only and shall not be used to  
> produce documents of any kind without same being submitted to,  
> reviewed by, and approved by Intego in writing. All data is subject  
> to change. User assumes all liability relating to the use of this  
> data and agrees to release, indemnify, and hold harmless Intego from  
> any and all claims relating said use. User is responsible to check  
> for any viruses before use.

---
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog





RE: How to retreive XML request

Posted by Sergey Pulyaev <Se...@intego-group.com>.
Thanks,
I use HTTPAnalyser for this, but the main goal is to store this request
in Log4J log file near the exception trace to reproduce the request in
development environment.
So - I need to get this data in java code.

Regards, 
Sergey

-----Original Message-----
From: Thorsten Kraus [mailto:TK-Spam@gmx.de] 
Sent: Wednesday, June 04, 2008 10:49 AM
To: users@cxf.apache.org
Subject: Re: How to retreive XML request

Hi Sergey ,

you can use a network protocoll analyzer such as wireshark 
(http://www.wireshark.org/) to analyse your network traffic. This 
traffic includes all the request/response things between your server and

client. B "following the tcp stream", you can wach the full request. 
Another advantage of this approach is the fact that your don't need to 
code anything to retrieve the information.

Regards,
TMK

Sergey Pulyaev schrieb:
> I use Jetty6 as container and I want to retrieve the XML request as
string if I have exception during the web service run...
>
> Is it possible?
>
>  
>
> I tried to use 
>
> ((HttpServletRequest)
getMessageContext().get(AbstractHTTPDestination.HTTP_REQUEST))
.getInputStream()
>
> But I'm failed to get information.
>
>  
>
> I tried to get the XML document but it contains just soap message with
clean 
>
>             Message inMessage =
msgContext.getWrappedMessage().getExchange().getInMessage();
>
>             xmlRes =
XmlUtils.formatXMLDocument(inMessage.getContent(org.w3c.dom.Node.class),
true);
>
>  
>
> But it returns just that:
>
> <soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ws="http://ws.pc2.takecharge.com/">
>
>    <soapenv:Header/>
>
>    <soapenv:Body/>
>
> </soapenv:Envelope>
>
>  
>
> Is there any possibility to get the whole xml of soap request?
>
>  
>
> Best regards
>
>                 Sergey 
>
>   


--------
This data is for general information only and shall not be used to produce documents of any kind without same being submitted to, reviewed by, and approved by Intego in writing. All data is subject to change. User assumes all liability relating to the use of this data and agrees to release, indemnify, and hold harmless Intego from any and all claims relating said use. User is responsible to check for any viruses before use. 

Re: How to retreive XML request

Posted by Thorsten Kraus <TK...@gmx.de>.
Hi Sergey ,

you can use a network protocoll analyzer such as wireshark 
(http://www.wireshark.org/) to analyse your network traffic. This 
traffic includes all the request/response things between your server and 
client. B "following the tcp stream", you can wach the full request. 
Another advantage of this approach is the fact that your don't need to 
code anything to retrieve the information.

Regards,
TMK

Sergey Pulyaev schrieb:
> I use Jetty6 as container and I want to retrieve the XML request as string if I have exception during the web service run...
>
> Is it possible?
>
>  
>
> I tried to use 
>
> ((HttpServletRequest) getMessageContext().get(AbstractHTTPDestination.HTTP_REQUEST)) .getInputStream()
>
> But I'm failed to get information.
>
>  
>
> I tried to get the XML document but it contains just soap message with clean 
>
>             Message inMessage = msgContext.getWrappedMessage().getExchange().getInMessage();
>
>             xmlRes = XmlUtils.formatXMLDocument(inMessage.getContent(org.w3c.dom.Node.class), true);
>
>  
>
> But it returns just that:
>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.pc2.takecharge.com/">
>
>    <soapenv:Header/>
>
>    <soapenv:Body/>
>
> </soapenv:Envelope>
>
>  
>
> Is there any possibility to get the whole xml of soap request?
>
>  
>
> Best regards
>
>                 Sergey
>
>
> --------
> This data is for general information only and shall not be used to produce documents of any kind without same being submitted to, reviewed by, and approved by Intego in writing. All data is subject to change. User assumes all liability relating to the use of this data and agrees to release, indemnify, and hold harmless Intego from any and all claims relating said use. User is responsible to check for any viruses before use. 
>
>