You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ychawla <pr...@yahoo.com> on 2014/07/01 19:16:03 UTC
Getting entire Soap Message with header and body in Payload mode
Hello All,
We use payload mode to process our CXF messages. It is very convenient and
will properly process the Soap Headers, SAML assertions, WS-Security headers
etc.
I have a requirements to get the entire raw Soap message in my camel route
and call a processor with it. There are other ways to do this, but the
requirement explicitly states that the raw soap message is required.
How can I get the entire raw soap message in Payload mode? I guess I could
reconstruct it manually by looping through the soap headers and re-creating
the DOM but is there another way to get at it?
Thanks,
Yogesh
--
View this message in context: http://camel.465427.n5.nabble.com/Getting-entire-Soap-Message-with-header-and-body-in-Payload-mode-tp5753162.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Getting entire Soap Message with header and body in Payload
mode
Posted by ychawla <pr...@gmail.com>.
Hi Guys,
Thanks for the help. I found a CXF interceptor online based off of the
logging interceptor that gets the message:
public SoapMessageInterceptor ()
{
super(Phase.RECEIVE);
}
@Override
public void handleMessage ( SoapMessage message ) throws Fault
{
String entireSoapMessage = "";
try
{
// now get the request xml
InputStream is = message.getContent ( InputStream.class );
CachedOutputStream os = new CachedOutputStream ( );
IOUtils.copy ( is, os );
os.flush ( );
message.setContent ( InputStream.class, os.getInputStream ( )
);
is.close ( );
entireSoapMessage = IOUtils.toString ( os.getInputStream ( ));
log.debug ("The request is: " + entireSoapMessage);
os.close ( );
}
catch ( Exception ex )
{
ex.printStackTrace ( );
}
message.getExchange().put("entireSoapMessage", entireSoapMessage);
}
Then in your camel route, you can get that header where we stuffed the
entire soap message as follows:
Message cxfMessage =
exchange.getIn().getHeader(CxfConstants.CAMEL_CXF_MESSAGE, Message.class);
String entireSoapMessage = (String)cxfMessage.get("entireSoapMessage");
and then add the interceptor to your CXF bean:
<cxf:inInterceptors>
<ref bean="soapMessageInterceptor"/>
</cxf:inInterceptors>
Thanks,
Yogesh
--
View this message in context: http://camel.465427.n5.nabble.com/Getting-entire-Soap-Message-with-header-and-body-in-Payload-mode-tp5753162p5753732.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Getting entire Soap Message with header and body in Payload mode
Posted by Matt Sicker <bo...@gmail.com>.
For situations like this, I developed a simple Camel component that uses
the old SAAJ classes instead of JAX-WS. That way, you get full access to
the whole XML document. Combined with XSLTs to form the request documents
and working with overly complicated or non-standard SOAP services became
far easier!
On 11 July 2014 04:10, Aki Yoshida <el...@gmail.com> wrote:
> That would be one possibility but you would be losing the exact form
> (the serialised wire message isn't the same as the original wire
> message).
>
> If you really need to get a cloned wire message at your camel route,
> one option would be to write a CXF interceptor to capture the original
> message and pass it to the camel route as an additional runtime
> context object. Maybe, actually I think there is no other option.
>
> If a DOM object is acceptable, you can also write a CXF interceptor to
> grab it within CXF and pass it to camel.
>
> regards, aki
>
>
> 2014-07-01 19:16 GMT+02:00 ychawla <pr...@yahoo.com>:
> > Hello All,
> > We use payload mode to process our CXF messages. It is very convenient
> and
> > will properly process the Soap Headers, SAML assertions, WS-Security
> headers
> > etc.
> >
> > I have a requirements to get the entire raw Soap message in my camel
> route
> > and call a processor with it. There are other ways to do this, but the
> > requirement explicitly states that the raw soap message is required.
> >
> > How can I get the entire raw soap message in Payload mode? I guess I
> could
> > reconstruct it manually by looping through the soap headers and
> re-creating
> > the DOM but is there another way to get at it?
> >
> > Thanks,
> > Yogesh
> >
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/Getting-entire-Soap-Message-with-header-and-body-in-Payload-mode-tp5753162.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Matt Sicker <bo...@gmail.com>
Re: Getting entire Soap Message with header and body in Payload mode
Posted by Aki Yoshida <el...@gmail.com>.
That would be one possibility but you would be losing the exact form
(the serialised wire message isn't the same as the original wire
message).
If you really need to get a cloned wire message at your camel route,
one option would be to write a CXF interceptor to capture the original
message and pass it to the camel route as an additional runtime
context object. Maybe, actually I think there is no other option.
If a DOM object is acceptable, you can also write a CXF interceptor to
grab it within CXF and pass it to camel.
regards, aki
2014-07-01 19:16 GMT+02:00 ychawla <pr...@yahoo.com>:
> Hello All,
> We use payload mode to process our CXF messages. It is very convenient and
> will properly process the Soap Headers, SAML assertions, WS-Security headers
> etc.
>
> I have a requirements to get the entire raw Soap message in my camel route
> and call a processor with it. There are other ways to do this, but the
> requirement explicitly states that the raw soap message is required.
>
> How can I get the entire raw soap message in Payload mode? I guess I could
> reconstruct it manually by looping through the soap headers and re-creating
> the DOM but is there another way to get at it?
>
> Thanks,
> Yogesh
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Getting-entire-Soap-Message-with-header-and-body-in-Payload-mode-tp5753162.html
> Sent from the Camel - Users mailing list archive at Nabble.com.