L.S.,

This is probably being caused by a stream-based message that is being
sent into the router.  In ServiceMix, we prefer using streams wherever
possible because it dramatically improves esb throughput.  There's one
drawback however: a stream can only be read once.

Before you added the content-based router logic, your Camel route
wasn't reading the stream so the message stream was arriving at the
cxf bc provider endpoint unread.  Now, with the content-based router,
the Camel route reads the stream to determine where to route the
message.  Camel has a feature called stream caching
(http://camel.apache.org/stream-caching.html) to handle these use
cases.  If you enable this feature on your routes, the stream will be
read and cached before starting the processing.  Another way to solve
this is by adding a convertBody(String.class) right after the from()
method call, to ensure we're sending a String instead of a stream.

For Camel 2.x and ServiceMix 4.1, we plan to move this logic into the
servicemix-camel endpoint, so it will automatically convert to a
re-readable type unless you explicitly tell it to keep the stream --
for now though, you'll have to go with one of the two workarounds I
mentioned before.

Regards,

Gert Vanthienen
------------------------
Open Source SOA: http://fusesource.com
Blog: http://gertvanthienen.blogspot.com/



2009/9/25 angel.ortiz <[email protected]>:
>
> Hi,
>
> I was able to transform the SOAP request into JBI. Now my message can be
> evaluated by my camel flow:
>
> Predicate isRequestA = body().contains("ServiceName1");
> Predicate isRequestB = body().contains("ServiceName2");
> Predicate isRequestC = body().contains("ServiceName3");
>
> errorHandler(deadLetterChannel().maximumRedeliveries(0));
>
> from("jetty:http://localhost:9080/research_msp/VirtualService";)
>        .to("log:IN")
>        .process(new SOAPRequestTransformProcessor())
>        .to("log:TRANSFORMED")
>        .tryBlock()
>
>        .choice()
>
>        .when(isRequestA)
>        .to("log:REQUEST_A")
>        
> .to("jbi:service:http://path.to.service/ServiceName1//ServiceName1WSDL";)
>        .to("log:RESULT1")
>
>        .when(isRequestB)
>        .to("log:REQUEST_B")
>        
> .to("jbi:service:http://path.to.service/ServiceName2//ServiceName2WSDL";)
>        .to("log:RESULT2")
>
>        .when(isRequestC)
>        .to("log:REQUEST_C")
>        
> .to("jbi:service:http://path.to.service/ServiceName3//ServiceName3WSDL";)
>        .to("log:RESULT3")
>
>        .otherwise()
>        .to("log:NOT_SUPPORTED")
>        .throwFault(new IllegalArgumentException("The requested operation is 
> not
> supported."))
>
>        .exception(Exception.class)
>        .to("log:ERROR")
>        .throwFault(new Exception("An unexpected error occurred"))
>
>        .end();
>
> Now I have a really dumb error here that I haven't figured out yet... The
> thing is, when I send a SOAP request to my jetty endpoint it is read and
> transformed correctly. In my test the predicate isRequestB  evaluates to
> true and in the ServiceMix screen I can see the following:
>
> ...
> INFO  - REQUEST_B               -
> Exchange[BodyType:org.apache.camel.converter.stream.StreamCacheConverter.InputStreamCache,
> Body:<jbi:message xmlns="http://java.sun.com/xml/ns/jbi";
> xmlns:jbi="http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper";><jbi:part><sons:displayInformation
> xmlns:sons="http://path.to.service/InformationService/";><approver>000000001</approver></sons:displayInformation></jbi:part></jbi:message>
> ]
> [Fatal Error] :-1:-1: Premature end of file.
> [Fatal Error] :-1:-1: Premature end of file.
> ERROR - CxfBcComponent                 - Error processing exchange InOut[
>  id: ID:127.0.0.1-123ee902cef-3:0
>  status: Active
>  role: provider
>  service: {http://path.to.service/ServiceName2/}ServiceName2WSDL
>  endpoint: ServiceName2WSDLSOAP
>  operation: {http://path.to.service/ServiceName2WSDL/}displayInformation
>  in: Unable to display: org.xml.sax.SAXParseException: Premature end of
> file.
> ]
> javax.xml.transform.TransformerException: org.xml.sax.SAXParseException:
> Premature end of file.
>        at
> org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:501)
>        at
> org.apache.servicemix.cxfbc.CxfBcProvider.convertMessageToInputStream(CxfBcProvider.java:691)
>        at
> org.apache.servicemix.cxfbc.CxfBcProvider.process(CxfBcProvider.java:232)
>        at
> org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:627)
>        at
> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:581)
>        at
> org.apache.servicemix.common.AsyncBaseLifeCycle.onMessageExchange(AsyncBaseLifeCycle.java:535)
>        at
> org.apache.servicemix.common.SyncLifeCycleWrapper.onMessageExchange(SyncLifeCycleWrapper.java:60)
>        at
> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:623)
>        at
> org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:172)
>        at
> org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:168)
>        at
> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
>        at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
>        at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
>        at java.lang.Thread.run(Thread.java:595)
> Caused by: org.xml.sax.SAXParseException: Premature end of file.
>        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>        at
> org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)
>        ... 13 more
>
> What I understand from the above exception is that there is something wrong
> with the XML being sent to the jbi service. Maybe is not even sending
> anything... not sure.
>
> Any ideas on this one?
>
> Angel
>
>
> willem.jiang wrote:
>>
>> Hi,
>> You may need to take the operation name out of the soap message, and put
>> it as the value of jbi:message type attribute.
>>
>> Here is an example
>> <jbi:message xmlns:jbi="http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper";
>> xmlns:msg="http://cxf.component.camel.apache.org"; type="msg:echo">
>> <jbi:part>
>> <ns1:echo xmlns:ns1="http://cxf.component.camel.apache.org";>
>> <arg0 xmlns="http://cxf.component.camel.apache.org";>Hello
>> World!</arg0></ns1:echo>
>> </jbi:part>
>> </jbi:message>
>>
>> Willem
>>
>
> --
> View this message in context: 
> http://www.nabble.com/Web-Services-Virtualization-using-ServiceMix-tp25514386p25604927.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>

Reply via email to