use of org.switchyard.common.camel.SwitchYardCamelContext in project quickstarts by jboss-switchyard.
the class OrderProcessor method process.
@Override
public void process(Exchange exchange) throws Exception {
ServiceDomain domain = ((SwitchYardCamelContext) exchange.getContext()).getServiceDomain();
String socketAddr = (String) domain.getProperty("soapClientPort");
String socketAddrFault = (String) domain.getProperty("httpPort");
Order order = exchange.getIn().getBody(Order.class);
System.out.println("Received Order " + order.getItem() + " with quantity " + order.getQuantity() + ".");
if (order.getItem().equals("Airbus")) {
throw new UnknownItem("Sorry, Airbus is no longer available with us!");
}
SOAPHeaderElement messageId = (SOAPHeaderElement) exchange.getIn().getHeaders().get("{http://www.w3.org/2005/08/addressing}MessageID");
if (messageId == null) {
messageId = (SOAPHeaderElement) exchange.getIn().getHeaders().get("{http://www.w3.org/2005/08/addressing}messageid");
}
exchange.getOut().getHeaders().put("{http://www.w3.org/2005/08/addressing}ReplyTo", "http://localhost:" + socketAddr + "/soap-addressing/client/ResponseService");
exchange.getOut().getHeaders().put("{http://www.w3.org/2005/08/addressing}RelatesTo", messageId.getValue());
exchange.getOut().getHeaders().put("{http://www.w3.org/2005/08/addressing}FaultTo", "http://localhost:" + socketAddrFault + "/soap-addressing/fault/FaultService");
exchange.getOut().setBody(order);
}
Aggregations