camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From angeloNZ <angelo.ange...@nz.fujitsu.com>
Subject Re: SaxParseException when using @RecipientList and .beanRef()
Date Fri, 08 May 2009 04:03:07 GMT

I am having a hard time getting this working.  I managed to put the tracer
working and I can see that the message I'm sending is valid.  I think it's
in the response that I'm getting the "content not allowed in prolog" message
because now it's saying it's finding a character 'j' where '<' is expected.

com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'j' (code
106) in prolog; expected '<'
 at [row,col {unknown-source}]: [1,1]
	at
com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:623)


If I try to print out the response content from my custom marshaler class in
ServiceMix I'm getting a "premature end of file" which I think means I'm not
getting any response back.

I can see from the tracer that Camel was able to detect that my endpoint is
JBI and was able to create an endpoint for me:

jbi:service:http://com.fujitsu.nz/RSSProvider converted to endpoint:
Endpoint[service:http://com.fujitsu.nz/RSSProvider] by component:
org.apache.servicemix.camel.CamelJbiComponent@81c868

I have no idea where to look next.  There wouldn't be any difference in how
I define the endpoints if I'm using beanRef for JBI services right?  




Claus Ibsen-2 wrote:
> 
> On Wed, May 6, 2009 at 12:53 AM, angeloNZ <angelo.angeles@nz.fujitsu.com>
> wrote:
>>
>> Hi,
>>
>> I'm using Camel alongside ServiceMix to do content based routing.  I'm
>> trying out using the @RecipientList annotation in my code to do a dynamic
>> lookup of my intended endpoints from an external properties file.
>>
>> This is my camel method:
>>
>> @RecipientList
>>    public String getTarget(@XPath("//request") String requestType) {
>>          // do a lookup of the request value from the resource bundle
>>          log.debug("Request type received = " + requestType);
>>          String target = messageAccessor.getMessage(requestType);
>>
>>          if (target != null) {
>>                  target = JBI_SERVICE + target;
>>          }
>>
>>          log.debug("Target retrieved = " + target);
>>
>>          return target;
>>    }
>>
>> The parameter to getTarget is an XPath evaluated value whose value I set
>> inside a custom Http Marshaler class.  Basically, my marshaler class
>> creates
>> an on-the-fly xml body and sets it as the message body of the
>> MessageExchange class.  Excerpt from ServiceMix marshaler class:
>>
>> StringBuffer sb = new StringBuffer("<?xml version=\"1.0\"
>> encoding=\"UTF-8\"?>")
>>           .append("<user_credentials>")
>>           .append("<request>" + this.getRequestType() + "</request>")
>>           .append("</user_credentials>");
>>
>> String userCredentials = sb.toString();
>>        ByteArrayInputStream bais = new
>> ByteArrayInputStream(userCredentials.getBytes());
>>        BufferedInputStream bis = new BufferedInputStream(bais);
>>
>>        in.setContent(new StreamSource(bis));
>>        me.setMessage(in, "in");
>>
>> The value of the <request> element is what's being checked by my
>> getTarget()
>> method.  The problem I'm encountering is I always get a
>> "SaxParseException:
>> Content is not allowed in prolog" message doing this:
> This error is when the XML is not valid, eg the XML does not have a
> XML header, the one with the <?xml version ... ?>.
> 
> You can enable the tracer to see what your message looks like while
> its being routed in Camel
> http://camel.apache.org/tracer.html
> 
> 
>>
>> from(...).beanref("targetListService","getTarget");
>>
>> However, my old code doesn't have this problem:
>>
>> from(...)
>>        .choice()
>>           .when().xpath("//request = 'RSS'")
>>               .to("jbi:service:http://com.mycompany.nz/RSSProvider")
>>           .when().xpath("//request = 'REST'")
>> .to("jbi:service:http://com.mycompany.nzSaxonSoapBuilderService")
>>         .end();
>>
>> My log shows that I'm getting the endpoints correctly from my properties
>> file.  I'm just not sure what is causing the SaxParseException, surely I
>> should get the same error if I use my old code if my xml body is invalid
>> right?  Any help is much appreciated.
>> --
>> View this message in context:
>> http://www.nabble.com/SaxParseException-when-using-%40RecipientList-and-.beanRef%28%29-tp23397324p23397324.html
>> Sent from the Camel - Users (activemq) mailing list archive at
>> Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> Apache Camel Reference Card:
> http://refcardz.dzone.com/refcardz/enterprise-integration
> Interview with me:
> http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress
> 
> 

-- 
View this message in context: http://www.nabble.com/SaxParseException-when-using-%40RecipientList-and-.beanRef%28%29-tp23397324p23439672.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.


Mime
View raw message