THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
This class just extends servicemix DefaultComponent
Which is JBI spec compitable component. By extends extending servicemix DefaultComponent, we can only focus cxf specific issue for our cxf service engine since all JBI spec details is handled by servicemix DefaultComponent. Here we just init cxf bus when CxfSeComponent init.
...
- cxf server
- servicemix consumer
As cxf server, just init a dummy server without real service class. This cxf server init the proper transport(http or jms) from the service model which is built from the wsdl. Since there is no service class for this server, this server will do no real service invocation, just transform message format between soap binding and jbi binding.
For a request message, need transform soap message to jbi message, two main interceptors get involved
JbiInInterceptor
JbiInInterceptor mainly create JBI NormalizedMessage and copy headers and attachments from soap message to JBI message
JbiInWsdl1Interceptor
JbiInWsdl1Interceptor transform soap messasge to jbi message according to the service model
For a reponse message, need transform jbi message to soap message, also two main interceptors get involved
JbiOutInterceptor
JbiOutInterceptor mainly copy attachments and headers from jbi message to soap message
JbiOutWsdl1Interceptor
JbiOutWsdl1Interceptor transform jbi mesage to soap message based on the service model
As servicemix consumer, send jbi message which transformed from the soap message to NMR and need process the response jbi message from the NMR.
CxfBcConsumer use its own JbiInvokerInterceptor to wire these two role together.
Main part of JbiInvokerInterceptor
Also the code for processing response jbi message looks likeCode Block lang java ublic class JbiInvokerInterceptor extends AbstractPhaseInterceptor<Message> { public JbiInvokerInterceptor() { super(Phase.INVOKE); } public void handleMessage(final Message message) throws Fault { final Exchange cxfExchange = message.getExchange(); final Endpoint endpoint = cxfExchange.get(Endpoint.class); final Service service = endpoint.getService(); final Invoker invoker = service.getInvoker(); MessageExchange exchange = message .getContent(MessageExchange.class); ComponentContext context = message.getExchange().get( ComponentContext.class); CxfBcConsumer.this.configureExchangeTarget(exchange); CxfBcConsumer.this.messages.put(exchange.getExchangeId(), message); CxfBcConsumer.this.isOneway = message.getExchange().get( BindingOperationInfo.class).getOperationInfo().isOneWay(); message.getExchange().setOneWay(CxfBcConsumer.this.isOneway); try { if (CxfBcConsumer.this.synchronous && !CxfBcConsumer.this.isOneway) { message.getInterceptorChain().pause();//just pause the incoming intercepor chain of cxf server, the mesage transformation from soap to jbi is done now context.getDeliveryChannel().sendSync(exchange, 10000timeout*1000);//send exchange which contain jbi message to NMR process(exchange); } else { context.getDeliveryChannel().send(exchange); } } catch (Exception e) { throw new Fault(e); } } }
Code Block java lang public void process(MessageExchange exchange) throws Exception { Message message = messages.remove(exchange.getExchangeId()); message.getInterceptorChain().resume();//resume the cxf outgoing interceptor chain, will do the message transformation from jbi to soap if (exchange.getStatus() == ExchangeStatus.ACTIVE) { exchange.setStatus(ExchangeStatus.DONE); message.getExchange().get(ComponentContext.class) .getDeliveryChannel().send(exchange); } }
...