In order to deploy a service to a JBI container, it is necessary to package all of the relevant files into a service assembly file. The service assembly is essentially an aggregation of one or more service units.
Figure 4.2, “Example of a JBI Service Assembly”
shows an overview of the service assembly archive used for the current demonstration. The archive is packaged as a .zip file and consists of two service units and a deployment descriptor, jbi.xml.
The service assembly deployment descriptor, jbi.xml, consists of a sequence of service unit descriptions. For each service unit, the descriptor specifies the constituent files and indicates which target JBI component the service should be deployed into. In the current scenario, two service units are provided, as follows:
Greeter service unit—deployed into the CXF service engine, and
binding-su service
unit—deployed into the ServiceMix SOAP+HTTP binding component.
The service unit for the Greeter service contains the following parts:
jbi.xml deployment
descriptor—this deployment descriptor is consumed by the CXF service engine, which is responsible for instantiating and activating the Greeter service.
Greeter service implementation—the class files that implement the Greeter service, including WSDL stub code.
WSDL contract—the server-side copy of the contract is defined to use the xformat binding and the jbi transport, which are designed to receive and send messages in normalized message format.
The xformat binding is a special binding type that marshals request and reply messages in the normalized message format. Example 4.1, “xformat Binding Element for the Greeter
Service”
shows the xformat binding used for the Greeter service deployed in the CXF service engine.
Example 4.1. xformat Binding Element for the Greeter Service
<wsdl:definitions name="HelloWorld"
targetNamespace="http://apache.org/hello_world"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://apache.org/hello_world"
xmlns:x1="http://apache.org/hello_world/types"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xformat="http://cxf.apache.org/bindings/xformat"
xmlns:jbi="http://apache.org/transport/jbi">
...
<wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter">
<xformat:binding />
<wsdl:operation name="sayHi">
<wsdl:input name="sayHiRequest" />
<wsdl:output name="sayHiResponse" />
</wsdl:operation>
<wsdl:operation name="greetMe">
<wsdl:input name="greetMeRequest" />
<wsdl:output name="greetMeResponse" />
</wsdl:operation>
<wsdl:operation name="greetMeOneWay">
<wsdl:input name="greetMeOneWayRequest" />
</wsdl:operation>
<wsdl:operation name="pingMe">
<wsdl:input />
<wsdl:output />
<wsdl:fault name="pingMeFault" />
</wsdl:operation>
</wsdl:binding>
The jbi transport is responsible for interfacing with the NMR, passing messages back and forth in normalized message format. Example 4.2, “jbi Endpoint for the Greeter Service”
shows the definition of the jbi endpoint for the Greeter service.
Example 4.2. jbi Endpoint for the Greeter Service
<wsdl:service name="HelloWorldService">
<wsdl:port binding="tns:Greeter_SOAPBinding" name="SoapPort">
<jbi:address location="http://localhost:9000/SoapContext/SoapPort"/>
</wsdl:port>
</wsdl:service>
The service unit for the SOAP+HTTP binding contains a single file, xbean.xml, which configures a SOAP/HTTP endpoint that exposes the Greeter service to external consumers.
Example 4.3, “Configuration of the SOAP+HTTP Binding
Component”
shows the contents of the xbean.xml file which configures the SOAP+HTTP binding to open a HTTP listening port and route incoming requests to the Greeter service.
Example 4.3. Configuration of the SOAP+HTTP Binding Component
<beans xmlns:http="http://servicemix.apache.org/http/1.0"
xmlns:demo="urn:servicemix:soap-binding"
xmlns:sns1="http://apache.org/hello_world">
<http:endpoint service="sns1:HelloWorldService"
endpoint="SoapPort"
interfaceName="sns1:Greeter"
role="consumer"
locationURI="http://localhost:9000/"
defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
soapVersion="1.1"
soap="true"
/>
</beans>