Have you tried Gert's suggestion below ?

On Fri, Aug 22, 2008 at 7:08 AM, Gert Vanthienen
<[EMAIL PROTECTED]>wrote:

> L.S.,
>
> The most likely explanation is that you the incoming MessageExchange uses
> streaming for the message body (e.g. with a StreamSource, StaxSource or the
> like).  However, the stream is being read when you call the new
> SourceTransformer()).toString(content);  At that moment, the String variable
> contains the message body, but the original stream itself has been closed.
>
> Later on in your code, you copy the message content from 'in' to 'out', but
> the in (and out) message content is the closed stream now, causing problems
> when you try to read this thing again.  The best way to solve this is by
> calling setContent() on the out message and passing in a new Source object
> (e.g. a new StringSource(body)) to make sure you have a re-readable message.
> Could you give that a try?
>
> Regards,
>
> Gert
>
>
>
> FreshAir wrote:
>
>>
>> Edell Nolan wrote:
>>
>>
>>> Hi,
>>>
>>> I have tried this and for me to get it to go through and work I needed to
>>> define a target namespace.
>>>
>>> e.g
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <e:Envelope xmlns:e="http://schemas.xmlsoap.org/soap/envelope/";
>>> xmlns="http://schemas.xmlsoap.org/soap/envelope/";>
>>>  <e:Body>
>>>   <test id="1">ok
>>>   </test>
>>>  </e:Body>
>>> </e:Envelope>
>>>
>>> Can you give this a try ?
>>>
>>> thanks, Edell.
>>>
>>> On Thu, Aug 21, 2008 at 2:35 AM, FreshAir <[EMAIL PROTECTED]>
>>> wrote:
>>>
>>>
>>>
>>>>
>>>> Edell Nolan wrote:
>>>>
>>>>
>>>>> Hi,
>>>>>
>>>>> I have tested this out and it works for me.
>>>>>
>>>>> I am just wondering how you send the actual message.
>>>>>
>>>>> I sent the request as follows from an onMessageExchange of a Service
>>>>>
>>>>>        QName cbrServiceName = new QName(SERVICE_NAMESPACE,
>>>>> "contentEnricher");
>>>>>        ServiceEndpoint se = getContext().getEndpoint(cbrServiceName,
>>>>> "enricherEndpoint");
>>>>>
>>>>>        InOnly eipInOnly =
>>>>> channel.createExchangeFactory().createInOnlyExchange();
>>>>>
>>>>>        eipInOnly.setEndpoint(se);
>>>>>        NormalizedMessage msg = eipInOnly.createMessage();
>>>>>        msg.setContent(setMessageContent());
>>>>>
>>>>>        eipInOnly.setMessage(msg, "in");
>>>>>        eipInOnly.setService(cbrServiceName);
>>>>>        channel.sendSync(eipInOnly);
>>>>>
>>>>>
>>>>>
>>>>> then setMessageContent is
>>>>>
>>>>>  private StringSource setupMsg() {
>>>>>      StringBuffer buf = new StringBuffer();
>>>>>      buf.append("<test id=\"1\">ok</test>");
>>>>>      return new StringSource(buf.toString());
>>>>>    }
>>>>>
>>>>> and it then goes through the additionalInformationExtracter and another
>>>>> service that I setup as the target and I do get the message content
>>>>>
>>>>>
>>>> from
>>>>
>>>>
>>>>> it.
>>>>>
>>>>> Edell.
>>>>>
>>>>>
>>>>> On Wed, Aug 20, 2008 at 8:27 AM, FreshAir <[EMAIL PROTECTED]>
>>>>>
>>>>>
>>>> wrote:
>>>>
>>>>
>>>>> Hi,
>>>>>> I tested the servicemix-eip, and its content-enricher part appears
>>>>>>
>>>>>>
>>>>> rather
>>>>
>>>>
>>>>> confusing.
>>>>>> The following is my xbean.xml using content-enricher:
>>>>>> <eip:content-enricher service="test:contentEnricher"
>>>>>>
>>>>>>
>>>>> endpoint="endpoint">
>>>>
>>>>
>>>>>  <eip:enricherTarget>
>>>>>>   <eip:exchange-target
>>>>>>
>>>>>>
>>>>> service="test:additionalInformationExtracter"/>
>>>>
>>>>
>>>>>  </eip:enricherTarget>
>>>>>>  <eip:target>
>>>>>>   <eip:exchange-target service="test:trace3" />
>>>>>>  </eip:target>
>>>>>> </eip:content-enricher>
>>>>>>
>>>>>> the exchange-target of enricherTarget is simply a servicemix-bea, the
>>>>>> onMessageExchange method of which is as follows:
>>>>>>
>>>>>>  public void onMessageExchange(MessageExchange exchange) throws
>>>>>> MessagingException {
>>>>>>       if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
>>>>>>
>>>>>>               NormalizedMessage message = exchange.getMessage("in");
>>>>>>                       Source content = message.getContent();
>>>>>>                       //process content according to your logic
>>>>>>                       //e.g. to access the message body as a String
>>>>>>
>>>>>>
>>>>> use
>>>>
>>>>
>>>>>                       try{
>>>>>>                       String body = (new
>>>>>> SourceTransformer()).toString(content);
>>>>>>
>>>>>>
>>>>> message.setContent(content);
>>>>
>>>>
>>>>>                       System.out.println("Routed to Enricher!");
>>>>>>                       System.out.println("received: " + body);
>>>>>>
>>>>>>                       exchange.setMessage(message, "out");
>>>>>>                       channel.send(exchange);
>>>>>>                       }catch(Exception e) {
>>>>>>                               e.printStackTrace();
>>>>>>                       }
>>>>>>       }
>>>>>>   }
>>>>>> As you see, it can not be simpler which just echo the message.
>>>>>> The target part is similar and equally simple. I used a http bc to
>>>>>>
>>>>>>
>>>>> post
>>>> a
>>>>
>>>>
>>>>> soap message to the content-enricher like this:
>>>>>>
>>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>> <e:Envelope xmlns:e="http://schemas.xmlsoap.org/soap/envelope/";>
>>>>>>  <e:Body>
>>>>>>  <test id="1">ok
>>>>>>  </test>
>>>>>>  </e:Body>
>>>>>> </e:Envelope>
>>>>>>
>>>>>> But it gave me the following error:
>>>>>>
>>>>>> Routed to Enricher!
>>>>>> received: <?xml version="1.0" encoding="UTF-8"?><test
>>>>>> xmlns:e="http://schemas.xm
>>>>>> lsoap.org/soap/envelope/" id="1">ok
>>>>>>  </test>
>>>>>> ERROR - EIPComponent                   - Error processing exchange
>>>>>> InOnly[
>>>>>>  id: ID:172.16.253.122-11bdeb9b38c-12:8
>>>>>>  status: Active
>>>>>>  role: provider
>>>>>>  service: {http://test}contentEnricher
>>>>>>  endpoint: endpoint
>>>>>>  operation: test
>>>>>>  in: <?xml version="1.0" encoding="UTF-8"?>
>>>>>> ]
>>>>>> java.lang.NullPointerException
>>>>>>       at org.apache.xerces.dom.CoreDocumentImpl.importNode(Unknown
>>>>>> Source)
>>>>>>       at org.apache.xerces.dom.CoreDocumentImpl.importNode(Unknown
>>>>>> Source)
>>>>>>       at
>>>>>> com.intervision.interesb.eip.patterns.ContentEnricher.combineToDOMDoc
>>>>>> ument(ContentEnricher.java:208)
>>>>>>       at
>>>>>> com.intervision.interesb.eip.patterns.ContentEnricher.process(Content
>>>>>> Enricher.java:156)
>>>>>>       at
>>>>>> com.intervision.interesb.common.AsyncBaseLifeCycle.doProcess(AsyncBas
>>>>>> eLifeCycle.java:526)
>>>>>>       at
>>>>>> com.intervision.interesb.common.AsyncBaseLifeCycle.processExchange(As
>>>>>> yncBaseLifeCycle.java:478)
>>>>>>       at
>>>>>> com.intervision.interesb.common.BaseLifeCycle.onMessageExchange(BaseL
>>>>>> ifeCycle.java:34)
>>>>>>       at
>>>>>> com.intervision.interesb.jbi.messaging.DeliveryChannelImpl.processInB
>>>>>> ound(DeliveryChannelImpl.java:598)
>>>>>>       at
>>>>>> com.intervision.interesb.jbi.nmr.flow.AbstractFlow.doRouting(Abstract
>>>>>> Flow.java:158)
>>>>>>       at
>>>>>> com.intervision.interesb.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlo
>>>>>> w.java:155)
>>>>>>       at
>>>>>> com.intervision.interesb.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.
>>>>>> java:122)
>>>>>>       at
>>>>>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
>>>>>> utor.java:886)
>>>>>>       at
>>>>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
>>>>>> .java:908)
>>>>>>       at java.lang.Thread.run(Thread.java:619)
>>>>>> WARN  - jetty                          - Nested in
>>>>>> javax.servlet.ServletExceptio
>>>>>> n: Failed to process request: java.lang.Exception:
>>>>>> java.lang.NullPointerExceptio
>>>>>> n:
>>>>>> java.lang.Exception: java.lang.NullPointerException
>>>>>>       at
>>>>>> com.intervision.interesb.http.processors.ConsumerProcessor.process(Co
>>>>>> nsumerProcessor.java:182)
>>>>>>       at
>>>>>> com.intervision.interesb.http.HttpBridgeServlet.doPost(HttpBridgeServ
>>>>>> let.java:59)
>>>>>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
>>>>>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
>>>>>>       at
>>>>>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487
>>>>>> )
>>>>>>       at
>>>>>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:3
>>>>>> 62)
>>>>>>       at
>>>>>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:7
>>>>>> 12)
>>>>>>       at
>>>>>> org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHand
>>>>>> lerCollection.java:211)
>>>>>>       at
>>>>>> org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.
>>>>>> java:114)
>>>>>>       at
>>>>>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:1
>>>>>> 39)
>>>>>>       at org.mortbay.jetty.Server.handle(Server.java:313)
>>>>>>       at
>>>>>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:50
>>>>>> 6)
>>>>>>       at
>>>>>> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:375)
>>>>>>       at
>>>>>> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.ja
>>>>>> va:396)
>>>>>>       at
>>>>>> org.mortbay.jetty.nio.SelectChannelConnector$RetryContinuation.run(Se
>>>>>> lectChannelConnector.java:511)
>>>>>>       at
>>>>>> org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool
>>>>>> .java:442)
>>>>>> Caused by: java.lang.NullPointerException
>>>>>>       at org.apache.xerces.dom.CoreDocumentImpl.importNode(Unknown
>>>>>> Source)
>>>>>>       at org.apache.xerces.dom.CoreDocumentImpl.importNode(Unknown
>>>>>> Source)
>>>>>>       at
>>>>>> com.intervision.interesb.eip.patterns.ContentEnricher.combineToDOMDoc
>>>>>> ument(ContentEnricher.java:208)
>>>>>>       at
>>>>>> com.intervision.interesb.eip.patterns.ContentEnricher.process(Content
>>>>>> Enricher.java:156)
>>>>>>       at
>>>>>> com.intervision.interesb.common.AsyncBaseLifeCycle.doProcess(AsyncBas
>>>>>> eLifeCycle.java:526)
>>>>>>       at
>>>>>> com.intervision.interesb.common.AsyncBaseLifeCycle.processExchange(As
>>>>>> yncBaseLifeCycle.java:478)
>>>>>>       at
>>>>>> com.intervision.interesb.common.BaseLifeCycle.onMessageExchange(BaseL
>>>>>> ifeCycle.java:34)
>>>>>>       at
>>>>>> com.intervision.interesb.jbi.messaging.DeliveryChannelImpl.processInB
>>>>>> ound(DeliveryChannelImpl.java:598)
>>>>>>       at
>>>>>> com.intervision.interesb.jbi.nmr.flow.AbstractFlow.doRouting(Abstract
>>>>>> Flow.java:158)
>>>>>>       at
>>>>>> com.intervision.interesb.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlo
>>>>>> w.java:155)
>>>>>>       at
>>>>>> com.intervision.interesb.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.
>>>>>> java:122)
>>>>>>       at
>>>>>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
>>>>>> utor.java:886)
>>>>>>       at
>>>>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
>>>>>> .java:908)
>>>>>>       at java.lang.Thread.run(Thread.java:619)
>>>>>> WARN  - jetty                          - /eip-enricher/
>>>>>> java.lang.Exception: java.lang.NullPointerException
>>>>>>       at
>>>>>> com.intervision.interesb.http.processors.ConsumerProcessor.process(Co
>>>>>> nsumerProcessor.java:182)
>>>>>>       at
>>>>>> com.intervision.interesb.http.HttpBridgeServlet.doPost(HttpBridgeServ
>>>>>> let.java:59)
>>>>>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
>>>>>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
>>>>>>       at
>>>>>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487
>>>>>> )
>>>>>>       at
>>>>>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:3
>>>>>> 62)
>>>>>>       at
>>>>>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:7
>>>>>> 12)
>>>>>>       at
>>>>>> org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHand
>>>>>> lerCollection.java:211)
>>>>>>       at
>>>>>> org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.
>>>>>> java:114)
>>>>>>       at
>>>>>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:1
>>>>>> 39)
>>>>>>       at org.mortbay.jetty.Server.handle(Server.java:313)
>>>>>>       at
>>>>>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:50
>>>>>> 6)
>>>>>>       at
>>>>>> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:375)
>>>>>>       at
>>>>>> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.ja
>>>>>> va:396)
>>>>>>       at
>>>>>> org.mortbay.jetty.nio.SelectChannelConnector$RetryContinuation.run(Se
>>>>>> lectChannelConnector.java:511)
>>>>>>       at
>>>>>> org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool
>>>>>> .java:442)
>>>>>> Caused by: java.lang.NullPointerException
>>>>>>       at org.apache.xerces.dom.CoreDocumentImpl.importNode(Unknown
>>>>>> Source)
>>>>>>       at org.apache.xerces.dom.CoreDocumentImpl.importNode(Unknown
>>>>>> Source)
>>>>>>       at
>>>>>> com.intervision.interesb.eip.patterns.ContentEnricher.combineToDOMDoc
>>>>>> ument(ContentEnricher.java:208)
>>>>>>       at
>>>>>> com.intervision.interesb.eip.patterns.ContentEnricher.process(Content
>>>>>> Enricher.java:156)
>>>>>>       at
>>>>>> com.intervision.interesb.common.AsyncBaseLifeCycle.doProcess(AsyncBas
>>>>>> eLifeCycle.java:526)
>>>>>>       at
>>>>>> com.intervision.interesb.common.AsyncBaseLifeCycle.processExchange(As
>>>>>> yncBaseLifeCycle.java:478)
>>>>>>       at
>>>>>> com.intervision.interesb.common.BaseLifeCycle.onMessageExchange(BaseL
>>>>>> ifeCycle.java:34)
>>>>>>       at
>>>>>> com.intervision.interesb.jbi.messaging.DeliveryChannelImpl.processInB
>>>>>> ound(DeliveryChannelImpl.java:598)
>>>>>>       at
>>>>>> com.intervision.interesb.jbi.nmr.flow.AbstractFlow.doRouting(Abstract
>>>>>> Flow.java:158)
>>>>>>       at
>>>>>> com.intervision.interesb.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlo
>>>>>> w.java:155)
>>>>>>       at
>>>>>> com.intervision.interesb.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.
>>>>>> java:122)
>>>>>>       at
>>>>>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
>>>>>> utor.java:886)
>>>>>>       at
>>>>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
>>>>>> .java:908)
>>>>>>       at java.lang.Thread.run(Thread.java:619)
>>>>>>
>>>>>> Obviously the enricher-target had recieved the message but when routed
>>>>>>
>>>>>>
>>>>> to
>>>>
>>>>
>>>>> the target, the "in" part of the message had mysteriously gone(that's
>>>>>>
>>>>>>
>>>>> why
>>>>
>>>>
>>>>> a
>>>>>> NullpointerException was invited).
>>>>>> Any suggestion would be greatly appreciated.
>>>>>> Thanks in advance!
>>>>>> --
>>>>>> View this message in context:
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>> http://www.nabble.com/Confused-about-the-EIPComponent-content-Enricher-tp19064169p19064169.html
>>>>
>>>>
>>>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>> Hi,
>>>> My http request part was like this,the xbean.xml which defines a http
>>>> bc:
>>>>  <http:endpoint service="test:http8"
>>>>                endpoint="endpoint"
>>>>                targetService="test:contentEnricher"
>>>>                role="consumer"
>>>>                locationURI="http://0.0.0.0:8192/eip-enricher/";
>>>>                defaultMep="http://www.w3.org/2004/08/wsdl/in-only";
>>>>                                soap="true"/>
>>>>
>>>> and I modified an example in servicemix3.2.1 distribution that is a
>>>> client.html to post request(as I attached).would you please tell me if I
>>>> missed something?
>>>> Thanks! http://www.nabble.com/file/p19081101/client-enricher.html
>>>> client-enricher.html
>>>> --
>>>> View this message in context:
>>>>
>>>> http://www.nabble.com/Confused-about-the-EIPComponent-content-Enricher-tp19064169p19081101.html
>>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>> Sir,
>> I don't know how you got it through, for me it is still giving errors like
>> there were no actual payload in the sent message by that http bc to the
>> contentEnricher as follows(note the "in" part):
>> Routed to Enricher!
>> received: <?xml version="1.0" encoding="UTF-8"?><test
>> xmlns="http://schemas.xmls
>> oap.org/soap/envelope/" xmlns:e="
>> http://schemas.xmlsoap.org/soap/envelope/";
>> id="
>> 1">ok
>>   </test>
>> ERROR - EIPComponent                   - Error processing exchange InOnly[
>>  id: ID:172.16.253.122-11be8193dc7-9:6
>>  status: Active
>>  role: provider
>>  service: {http://test}contentEnricher
>>  endpoint: endpoint
>>  operation: 
>> {http://schemas.xmlsoap.org/soap/envelope/}test<http://schemas.xmlsoap.org/soap/envelope/%7Dtest>
>>  in: <?xml version="1.0" encoding="UTF-8"?>
>> ]
>> java.lang.NullPointerException
>>        at org.apache.xerces.dom.CoreDocumentImpl.importNode(Unknown
>> Source)
>>        at org.apache.xerces.dom.CoreDocumentImpl.importNode(Unknown
>> Source)
>>        at
>> com.intervision.interesb.eip.patterns.ContentEnricher.combineToDOMDoc
>> ument(ContentEnricher.java:208)
>>        at
>> com.intervision.interesb.eip.patterns.ContentEnricher.process(Content
>> Enricher.java:156)
>> ...
>>
>> Is there any difference between defining a namespace and without one in
>> the
>> request xml?
>> Anyway, I think it is http bc that causes problem, since when I produce a
>> Inonly message in a servicemix-bean's onMessageExchangeListener and send
>> it
>> to that contentEnricher(defining QName), it works like:
>> Routed to Enricher!
>> received: <test id="1">ok</test>
>> Received exchange: InOnly[
>>  id: ID:172.16.253.122-11be8207141-13:2
>>  status: Active
>>  role: provider
>>  service: {http://test}trace3
>>  endpoint: endpoint
>>  in: <?xml version="1.0" encoding="UTF-8"?><enricher><request><test
>> id="1">ok</
>> test></request><result><test id="1">ok</test></result></enricher>
>> ]
>> here I dont enrich any content so it remains the same.
>> It is noticeable, however, that in the former the enricher bean recieved
>> something like: <?xml version="1.0" encoding="UTF-8"?><test xmlns="
>> http://schemas.xmls
>> oap.org/soap/envelope/" xmlns:e="
>> http://schemas.xmlsoap.org/soap/envelope/";
>> id="
>> 1">ok
>>   </test>
>> and for the latter:
>> <test id="1">ok</test>
>>
>> The non-http request is written as you told me in the last reply.
>> So I was indeed wondering what's wrong with my http-bc.
>> Thanks.
>>
>>
>
>

Reply via email to