Ниже приведен фрагмент кода для Http Camel SU для использования http-сообщений. Подскажите, пожалуйста, что не так с SMSProcessor
компонентом?
Я получаю: cannot cast apache.servicemix.jbi.jaxp.StringSource to apache.servicemix.jbi.jaxp.StringSource"
Переплет:
<beans xmlns:http="http://servicemix.apache.org/http/1.0"
xmlns:b="http://rhinopay.com/bridge">
<http:consumer service="b:http"
endpoint="endpoint"
targetService="b:pipeline"
locationURI="http://localhost:8192/rhinopay/"
defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
marshaler="#myMarshaler"
/>
<bean id="myMarshaler" class="marshaller.HttpMarshaller"/>
</beans>
HttpMarshaller:
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;
}
}
SMSProcessor:
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.servicemix.jbi.jaxp.StringSource;
public class SMSProcessor implements Processor {
/*
* @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());
}
}