|
Page Edited :
SM :
servicemix-cxf-se
servicemix-cxf-se has been edited by Lars Heinemann (Aug 14, 2008). Content:servicemix-cxf-seServiceMix CXF SE component is a JBI Service Engine exposing (annotated) POJO as services on the JBI Bus. Features:
InstallationInstalling the servicemix-cxf-se component can be done in several ways:
Note that when using ant tasks, the component is not started, you will have to start it manually using ant tasks or a console. DeploymentYou can deploy Service Units containing a file named xbean.xml for activating consumer and provider endpoints. This xml file should respect the given syntax <beans xmlns:cxfse="http://servicemix.apache.org/cxfse/1.0"> ... </beans> Any numbers of endpoints can be specified in the xbean.xml file.
Accessing the JBI busThe prefered way to access the JBI bus is by retrieving a ComponentContext implementation. private javax.jbi.component.ComponentContext context; public void setContext(javax.jbi.component.ComponentContext context) { this.context = context; } By this way, the ComponentContext inject into your POJO automatically Note that only sendSync is allowed for active JBI exchanges (but you have to use send for DONE or ERROR status exchanges). You can also use the client api: public void myMethod() { ServiceMixClient client = new ServiceMixClientFacade(this.context); QName service = new QName("http://servicemix.org/cheese/", "receiver"); EndpointResolver resolver = client.createResolverForService(service); client.send(resolver, null, null, "<hello>world</hello>"); } You can find a whole context injection test case here Lightweight modeThe servicemix-cxf-se component can also be configured in a spring/xbean configuration file, for use in an embedded ServiceMix. <sm:activationSpec> <sm:component> <cxfse:component> <cxfse:endpoints> <cxfse:endpoint> <cxfse:pojo> <bean class="org.apache.cxf.calculator.CalculatorImpl"/> </cxfse:pojo> </cxfse:endpoint> </cxfse:endpoints> </cxfse:component> </sm:component> </sm:activationSpec>
ProxiesYou can create java proxies for JBI endpoints, provided that they expose a WSDL. The basic configuration is the following: <cxfse:proxy service="calculator:CalculatorService" context="#context" type="org.apache.cxf.calculator.CalculatorPortType" />
You can use it from one of you client bean, or from inside another component, and call the JBI endpoint as a plain Java object. From a cxfse Service Unit, it could be used as following: <cxfse:endpoint> <cxfse:pojo> <bean class="org.apache.servicemix.cxfse.GreeterImplForClientProxy"> <property name="calculator"> <cxfse:proxy service="calculator:CalculatorService" context="#context" type="org.apache.cxf.calculator.CalculatorPortType" /> </property> </bean> </cxfse:pojo> </cxfse:endpoint> private CalculatorPortType calculator; public void setCalculator(CalculatorPortType calculator) { this.calculator = calculator; } public CalculatorPortType getCalculator() { return calculator; } public void myMethod() { int ret = 0; try { ret = getCalculator().add(1, 2); } catch (Exception e) { e.printStackTrace(); } ... } You can find a complete proxy test case here MTOM supportMTOM is a way to handle large amounts of binary data in your services. Unlike attachments, the XML infoset stays the same. MTOM just "optimizes" any base64Binary data you have in your messages. When MTOM is turned on, this base64 data gets sent as a binary attachment saving time and space. MTOM support can be turned on using: <cxfse:endpoint mtomEnabled="true" ... />
MTOM is supported for the following classes:
If you have a bean with the following method: public String echo(String msg, DataHandler binary) { ... } you will be able to call it using the following requests: <echo xmlns:xop='http://www.w3.org/2004/08/xop/include'> <msg>hello world</msg> <binary> <xop:Include href=''/> </binary> </echo> provided that the JBI message contains an attachment named "binary". You can find a complete MTOM test case here Interceptors ConfigurationSince cxfse is using Apache CXF <cxfse:endpoint> <cxfse:pojo> <bean class="org.apache.cxf.calculator.CalculatorImpl"> </bean> </cxfse:pojo> <cxfse:inInterceptors> <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/> </cxfse:inInterceptors> <cxfse:outInterceptors> <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/> </cxfse:outInterceptors> <cxfse:inFaultInterceptors> <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/> </cxfse:inFaultInterceptors> <cxfse:outFaultInterceptors> <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/> </cxfse:outFaultInterceptors> </cxfse:endpoint> Can find document for CXF interceptors here |
Unsubscribe or edit your notifications preferences
