camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From angeloNZ <angelo.ange...@nz.fujitsu.com>
Subject SaxParseException when using @RecipientList and .beanRef()
Date Tue, 05 May 2009 22:53:25 GMT

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:

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.


Mime
View raw message