-
1. Re: Best practise for accessing original message after transforming
kcbabo Feb 2, 2014 2:56 PM (in response to richardhands)If you want to capture the original message that came off the wire from the binding before transformation, then you have a couple of options. Both options involve making a copy of the content of the message and storing it as a context property.
1) Implement an exchange interceptor with a target of CONSUMER and capture the content in the before() callback.
2) Create a custom message composer which extends the message composer for the binding you are using. Capture the original content from the BindingData reference and then call super.compose() to continue processing.
Gotchas:
* If you are dealing with stream-based content, you need to make sure you replace the content after reading it. If you exhaust a stream in your copy logic then the original message content is no longer there. Here's an example of how you might do that.
* If you store the original message content as a context property, keep in mind where you will need to access the property. If you are making multiple invocations in your app and you need to inspect the original message in any of those invocations, then be sure to propagate the context property on each call.
-
2. Re: Best practise for accessing original message after transforming
richardhands Feb 3, 2014 5:14 AM (in response to kcbabo)Thanks Keith, i knew there had to be a fairly obvious answer :-)
-
3. Re: Best practise for accessing original message after transforming
richardhands Mar 7, 2014 5:28 AM (in response to richardhands)I think I may just have fallen foul of the second gotcha you listed above
* If you store the original message content as a context property, keep in mind where you will need to access the property. If you are making multiple invocations in your app and you need to inspect the original message in any of those invocations, then be sure to propagate the context property on each call.
due to some changes to the spec from the client, i now have an external soap binding, coming in through a transformer to a java bean component, and then invoking another java bean component. My interceptor fires on both 'befores' as i'd expect, and in the first bean component if i inject the context and interrogate it, that property is there. However, when i get to my second bean, it's not there on the context any more. Is this just a case that i need to change my second (and subsequent) bean service interfaces to take across the original message, or is there a 'better' way to keep it on the context so that i can pick it up when needed?