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:[email protected]] > Sent: Sonntag, 24. Januar 2016 11:06 > To: [email protected] > 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"); } } > > > > > }
