1 Reply Latest reply on Jan 20, 2011 8:07 PM by Freeman(Yue) Fang

    HTTP SU request parameters consume....

    sandeep ch Newbie

      0 down vote favorite

            

       

      Hi ,

       

      Below is the code snippet for the Http Camel SU for consume Http messages. Can you pls advise what is wrong with SMSProcessor component?

       

      I am getting "cannot cast apache.servicemix.jbi.jaxp.StringSource to apache.servicemix.jbi.jaxp.StringSource"....

       

       

      import javax.jbi.messaging.MessageExchange; import javax.jbi.messaging.NormalizedMessage; import javax.servlet.http.HttpServletRequest;

       

      import org.apache.servicemix.common.EndpointComponentContext; import org.apache.servicemix.http.endpoints.DefaultHttpConsumerMarshaler; import org.apache.servicemix.jbi.jaxp.StringSource;

       

      public class HttpMarshaller extends DefaultHttpConsumerMarshaler{

       

      public MessageExchange createExchange(HttpServletRequest request,

              javax.jbi.component.ComponentContext context) throws Exception {

          // TODO Auto-generated method stub

       

              String mobile = request.getParameter("mobile");

              String smsTxt = request.getParameter("smsTxt");

           //  String message = request.getParameter("msg");

              MessageExchange exchange = ((EndpointComponentContext) context).getDeliveryChannel().createExchangeFactory().createExchange(getDefaultMep());

              NormalizedMessage in = exchange.createMessage();

              String xmlContext = mobile","smsTxt;

              System.out.println("xmlContext---"+xmlContext);

              in.setContent(new StringSource(xmlContext));

              exchange.setMessage(in,"in");

              return exchange;

      }

       

      }

       

      import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.servicemix.jbi.jaxp.StringSource;

       

      /** * @author * */ public class SMSProcessor implements Processor {

       

      /* (non-Javadoc)

       

      • @see org.apache.camel.Processor#process(org.apache.camel.Exchange)

      */

      public void process(Exchange exchange) throws Exception {

          System.out.println("SMSProcessor");

          StringSource text = ((StringSource)exchange.getIn().getBody());

          System.out.println("text"+text.getText());

      }

       

      }