...
Code Block |
---|
|
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 mode
The servicemix-cxf-se component can also be configured in a spring/xbean configuration file, for use in an embedded ServiceMix.
Here is an example of such a configuration:
Code Block |
---|
|
<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>
|
Wiki Markup |
---|
{snippet:id=lightweight|lang=xml|url=servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/resources/org/apache/servicemix/jsr181/spring.xml} |
Warning |
---|
title | Classpath issues when embedding servicemix-jsr181 cxf-se component |
---|
|
When using the servicemix.xml configuration file to create jsr181 cxfse endpoints, you must include the servicemix-jsr181cxfse-xxx.jar in your classpath. You will find this file inside the component installer (./components/servicemix-jsr181cxfse-xxx.zip). Failing this, an IllegalArgumentException will be thrown with the following message: Component name: xxxxxx is bound to an object which is not a JBI component, it is of type: javax.xml.namespace.QName or aanother exception with |
...
The basic configuration is the following:
Code Block |
---|
|
<cxfse:proxy service="calculator:CalculatorService" context="#context" type="org.apache.cxf.calculator.CalculatorPortType" />
|
Wiki Markup |
---|
{snippet:id=proxy|lang=xml|url=servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/resources/org/apache/servicemix/jsr181/spring.xml} |
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 jsr181 cxfse Service Unit, it could be used as following:
Wiki Markup |
---|
{snippet:id=proxy|lang=xml|url=servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/resources/proxy/xbean.xml} |
Code Block |
---|
|
private EchoCalculatorPortType echocalculator;
public void setEchosetCalculator(EchoCalculatorPortType echocalculator) {
this.echocalculator = echocalculator;
}
public CalculatorPortType getCalculator() {
return calculator;
}
public void myMethod() {
int ret = 0;
try {
String result = echo.echo("world"); ret = getCalculator().add(1, 2);
} catch (Exception e) {
e.printStackTrace();
}
...
}
|
MTOM support
MTOM 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.
...