cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Manoj Jain <manoj.kumar.jain...@gmail.com>
Subject Re: Not able to extract soapBody
Date Tue, 26 Jan 2016 12:20:13 GMT
Andrei,

Thank you for your response.   I need more help.

I  have build application with wsdl-first. Application works.

My requirements is for some of the web methods (e.g. sayHello method), I
need to do  pre-processing and post processing of SoapMessge.

So when the stub of SayHello is invoked, I want to extract SoapEnvelop,
send it to remote pre-processing engine and finally return the response of
sayHello.

The way I wanted to do this was  extract current message  using

Message message = PhaseInterceptorChain.getCurrentMessage();

and from message extract the SoapEnvelop. But the problem is SoapBody is
null.

Request, if you suggest solution which fits to my requirements.


Reagrds
Manoj Jain




















On Tue, Jan 26, 2016 at 2:14 AM, Andrei Shakirin <ashakirin@talend.com>
wrote:

> Hi,
>
> The easiest way to access SoapBody is implementing Provider<SOAPMessage>
> interface:
> http://cxf.apache.org/docs/provider-services.html
>
> CXF delivers samples illustrating this approach:
> https://github.com/apache/cxf/blob/master/distribution/src/main/release/samples/jaxws_dispatch_provider/src/main/java/demo/hwDispatch/server/GreeterSoapMessageProvider.java
>
> Regards,
> Andrei.
>
> > -----Original Message-----
> > From: Manoj Jain [mailto:manoj.kumar.jainman@gmail.com]
> > Sent: Sonntag, 24. Januar 2016 11:06
> > To: users@cxf.apache.org
> > Subject: Not able to extract soapBody
> >
> > Hi,
> >
> > I have a use case where I have to extract the SoapBody without invoking
> > interceptors.
> >
> >
> > I am trying following code to extract the body.  I am able to retrieve
> headers
> > and other information , But the SoapBody is  returning null.
> >
> > Please suggest the way I can do  extract full soap envelop  without
> writing
> > soap inceptors.
> >
> >
> > public static void marshal() {
> > Message message = PhaseInterceptorChain.getCurrentMessage();
> > LOGGER.debug("MANOj Invoking handleMessage on interceptor Chain END
> > " ); //FIRST method - Failed no SoapBody InputStream is =
> > message.getExchange().getBinding().createMessage().getContent(InputStre
> > am.class);
> > try{
> > Message msg = message.getExchange().getInMessage().
> > InputStream is = msg.getContent(InputStream.class);
> > String soapBody = IOUtils.toString(is);
> > LOGGER.debug("SOAPBody body ="+soapBody); } catch (IOException e1) { //
> > TODO Auto-generated catch block e1.printStackTrace(); }
> >
> >
> > //Second method - Failed no SoapBody
> >         SoapMessage soapMessage = (SoapMessage) message;
> >
> >         SOAPMessage doc = message.getContent(SOAPMessage.class);
> >
> >         SOAPBody body;
> > try {
> > body = doc.getSOAPBody();
> > System.out.println("MANOj SOAPBody body ="+body.toString()); } catch
> > (SOAPException e) {
> > e.printStackTrace()
> > System.out.println("MANOj SOAPBody body = FAILED"); }  }
> >
> >
> >
> >
> > }
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message