Hi
thanks for the pointer, but it did not seem to help fro some reason, the
content of the message is always null i seems. This is how it looks in my
code
//Get the stream
InputStream is = arg0.getContent(InputStream.class);
CachedOutputStream bos = null;
if (is != null) {
bos = new CachedOutputStream();
//Copy it to the cachedoutput stream
IOUtils.copy(is, bos);
log.info("Set the new content ");
}
//Get the content for the body
log.info("body info {}", getBodyElement(arg0));
bos.flush();
is.close();
// Set the new content
arg0.setContent(InputStream.class, bos.getInputStream());
bos.close();
I'm I doing anything wrong here? Tried to place the point where I extract
the body almost everywhere in my code, but nothing seems to help. If I
remove the getBodyElement call everything works fine.
Håkon
2009/10/27 Freeman Fang <[email protected]>
> Hi,
>
> I think the error comes from that the inputstream of message is not
> re-readable, so if you want to read the message content yourself, ensure
> that you already copy the inputstream and save it before hand, something
> like
>
> InputStream is = message.getContent(InputStream.class);
> if (is != null) {
> CachedOutputStream bos = new CachedOutputStream();
> try {
> IOUtils.copy(is, bos);
>
> bos.flush();
> is.close();
>
> message.setContent(InputStream.class, bos.getInputStream());
>
>
> bos.close();
> } catch (IOException e) {
> throw new Fault(e);
> }
> }
>
> You can take a look at LoggingInInterceptor[1] as an example, this
> interceptor just print out the message content when receive it and will not
> affect other process afterwords, it's should be similar as your requirement
> [1]
> https://svn.apache.org/repos/asf/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
>
> Freeman
>
>
> On 2009-10-27, at 上午12:12, Håkon Sagehaug wrote:
>
> hi,
>>
>> I copied the method and i was able to extract the message, but then I got
>> a
>> new exception, this one
>>
>> ERROR - CxfBcComponent - Error processing exchange InOut[
>> id: ID:129.177.20.229-12490bff30f-2:27
>> status: Active
>> role: provider
>> interface: {http://www.bccs.uib.no/EchoService.wsdl}EchoServicePortType
>> service:
>> {http://www.bccs.uib.no/EchoService.wsdl}EchoService<http://www.bccs.uib.no/EchoService.wsdl%7DEchoService>
>> endpoint: EchoServiceProxy
>> operation:
>> {http://www.bccs.uib.no/EchoService.wsdl}SayHi<http://www.bccs.uib.no/EchoService.wsdl%7DSayHi>
>> in: null
>> ]
>>
>>
>> I guess the message for outgoing for some reason is null, so I looked at
>> [1]
>> some more and added this to my code
>>
>> Document messageDocument = DomUtil.createDocument();
>>
>> Element soapEnv = DomUtil.createElement(messageDocument,
>> new QName(soapVersion.getEnvelope().getNamespaceURI(),
>> soapVersion.getEnvelope().getLocalPart(),
>> soapVersion.getPrefix()));
>> Element soapBody = DomUtil.createElement(soapEnv, new QName(
>> soapVersion.getBody().getNamespaceURI(), soapVersion
>> .getBody().getLocalPart(), soapVersion
>> .getPrefix()));
>> soapEnv.appendChild(soapBody);
>> Element body = getBodyElement(arg0);
>>
>> soapBody.appendChild(soapBody.getOwnerDocument().importNode(
>> body, true));
>>
>> arg0.setContent(Source.class, new DOMSource(messageDocument));
>>
>> But this gives also gives me an error,
>>
>> INFO - PhaseInterceptorChain - Interceptor has thrown exception,
>> unwinding now null
>>
>> Not sure what to do, I've tried changing the Phase I have my Interceptor,
>> first I had it in Phase.READ, and tried some others but no luck.
>>
>> Any tips on how to solve it??
>>
>> cheers, Håkon
>>
>> 2009/10/26 Freeman Fang <[email protected]>
>>
>> Hi,
>>>
>>> You can take a look at JbiInWsdl1Interceptor.getBodyElement() [1] as an
>>> example.
>>> [1]
>>>
>>> https://svn.apache.org/repos/asf/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java
>>>
>>> Freeman
>>>
>>>
>>> On 2009-10-26, at 下午10:09, Håkon Sagehaug wrote:
>>>
>>> Hi all,
>>>
>>>>
>>>> I know this is not a specific servicemix question, but hopefully someone
>>>> can
>>>> answer it. I'm having cxf-bc that proxy out a web service, and having a
>>>> interceptor in he xbean configuration for looking for a pattern in the
>>>> soap
>>>> message. I can extract the soap header in the soap envelope fine, but I
>>>> couldn't figure out how to extract the soap body. So does anyone have a
>>>> tip
>>>> how to easily extracting the soap body inside the cxf interceptor?
>>>>
>>>> cheers, Håkon
>>>>
>>>> --
>>>> Håkon Sagehaug, Scientific Programmer
>>>> Parallab, Bergen Center for Computational Science (BCCS)
>>>> UNIFOB AS (University of Bergen Research Company)
>>>>
>>>>
>>>
>>> --
>>> Freeman Fang
>>> ------------------------
>>> Open Source SOA: http://fusesource.com
>>>
>>>
>>>
>>
>> --
>> Håkon Sagehaug, Scientific Programmer
>> Parallab, Bergen Center for Computational Science (BCCS)
>> UNIFOB AS (University of Bergen Research Company)
>>
>
>
> --
> Freeman Fang
> ------------------------
> Open Source SOA: http://fusesource.com
>
>
--
Håkon Sagehaug, Scientific Programmer
Parallab, Bergen Center for Computational Science (BCCS)
UNIFOB AS (University of Bergen Research Company)