JiBX/WS is a web services stack build around JiBX data binding, currently in beta release. It supports both SOAP and POX (Plain Old XML) web services, and comes with high-efficiency TCP socket connection support in addition to the more-conventional HTTP connections. JiBX/WS also supports XBIS XML encoding as a high-performance alternative to text XML (currently only usable when both client and server are running on JiBX/WS). JiBX/WS currently does not support code generation, instead using the type of object passed on a client call to determine the service operation being invoked, and calling directly to the appropriate method of a configured service implementation class on the server. JiBX/WS setupYou need to download and install (by simply expanding the download file to a directory on your system) the JiBX/WS distribution before you can try out the JiBX/WS service example. To work with the current 0.9 release of JiBX/WS, you also need to add a version of the Apache Commons Logging jar to your JiBX/WS lib directory. You can get this jar by downloading it directly, or if you've installed Axis2 just copy the jar (named commons-logging-#.jar, where the '#' represents a version number) from the Axis2 lib directory. Build the service implementationAfter you've installed JiBX/WS (and added the Commons Logging jar, if necessary), you next need to configure the supplied web service build. First edit the build.properties file in the webservice/jibxws directory of your JiBX OTA distribution and set the path to your JiBX/WS installation (again using doubled '\' directory separator characters on Windows, or Unix/Linux-style '/' directory separator characters, as with the other .properties files). Next edit the air-service.properties file in the webservice/jibxws/config directory to set the path to the directory containing the documents you want to use as response messages (which can just be the directory containing the OTA sample documents). If you're going to be deploying the service war on a different host system, or on a port other than 8080, you also need to edit the air-client.properties file in the same directory and change the service endpoint address (see the next section for details of the settings in this file). Next open a console to the webservice/jibxws directory and type Once you've deployed the .war to your web server, you can try it out using the supplied
client by typing Trying protocol, transport, and encoding variationsThe JiBX/WS implementation of the example service supports a variety of options. The settings in the webservice/jibxws/config/air-client.properties file controls which options are used by the client in connecting to the server. Here's the file as supplied: # name of binding to be used org.ota.ws.AirServiceClient.binding=binding # name of package containing binding org.ota.ws.AirServiceClient.package=org.ota # service endpoint address (for TCP, use endpoint 8123 for SOAP and 8124 for POX) org.ota.ws.AirServiceClient.endpoint=http://localhost:8080/AirService/soap/air-service #org.ota.ws.AirServiceClient.endpoint=http://localhost:8080/AirService/pox/air-service #org.ota.ws.AirServiceClient.endpoint=tcp://localhost:8123 #org.ota.ws.AirServiceClient.endpoint=tcp://localhost:8124 # protocol to use for requests org.ota.ws.AirServiceClient.protocol=SOAP1.1 #org.ota.ws.AirServiceClient.protocol=POX # request media type org.ota.ws.AirServiceClient.request=xml #org.ota.ws.AirServiceClient.request=x-xbis # response media type(s) org.ota.ws.AirServiceClient.response=xml #org.ota.ws.AirServiceClient.response=x-xbis,xml The .properties file format uses '#' as a comment marker for lines, so only the lines which do not start with a '#' are actually active in the configuration. This allows the configuration settings required for different variations to all be simultaneously present in the file. To change a setting to one of the other provided alternatives, just add a '#' at the start of the current active setting line and remove the '#' from the start of the one you want to use. The variations you can try are of three types. First is the service endpoint, which also identifies the type of transport to be used. Second is the protocol to be used for exchanging XML messages (which also effects the service endpoint). Third is the media type (or encoding) used for request and response XML messages. HTTP variationsThe When changing the endpoint setting between SOAP and POX, you also
need to set the XBIS encoding for XML can be separately enabled for each message direction. The
TCP variationsWith TCP transport, separate ports are used for the SOAP and POX service endpoints.
These different ports are controlled by command line arguments passed to the TCP server
built into JiBX/WS. Using the supplied build.xml, the server is run with this
target, which must be run (by typing <!-- Run the TCP server --> <target name="start-tcp"> <java classname="org.jibx.ws.tcp.server.TcpServer" fork="true"> <classpath path="${build-server}/bin"/> <classpath refid="jibxws-classpath"/> <classpath refid="jibx-classpath"/> <classpath refid="model-classpath"/> <arg value="${basedir}/config/air-service.xml=8123" /> <arg value="${basedir}/config/air-service-pox.xml=8124" /> </java> </target> The arguments passed to the TCP server each give a service configuration and the port number at which that configuration is to be deployed. These service configuration files, webservice/jibxws/config/air-service.xml and webservice/jibxws/config/air-service-pox.xml, are also used for HTTP endpoings. In the HTTP case, the files are included in the .war WEB-INF directory and referenced from the web.xml file. As with HTTP services, besides changing the path to use the appropriate endpoint for
SOAP or POX over TCP, you also need to set the Again as with HTTP, XBIS encoding for XML can be separately enabled for each message
direction. The Implementation codeThe JiBX/WS client implementation code is in the webservice/jibxws/client/src
directory. Unlike the Axis2 version of the code, which uses a service-specific stub class
generated from the WSDL service definition, the JiBX/WS version just creates a generic
// create the appropriate type of client Protocol protocol = ProtocolDirectory.getProtocol(getRequiredProperty(PROTOCOL_KEY, props)); MessageOptions options = new MessageOptions(); options.setOutMediaTypeCode(getRequiredProperty(REQUEST_TYPE_KEY, props)); options.setInMediaTypeCodes(splitString(getRequiredProperty(RESPONSE_TYPE_KEY, props))); Client client = protocol.createClient(getRequiredProperty(ENDPOINT_KEY, props), factory, options); // to just create a SOAP client using only XML media type, replace the above // with the following // Client client = new SoapClient(getRequiredProperty(ENDPOINT_KEY, props), factory); // process each command line parameter as document path for (int i = 0; i < args.length; i++) { String path = args[i]; try { // read input document and send to server IUnmarshallingContext uctx = factory.createUnmarshallingContext(); Object req = uctx.unmarshalDocument(new FileInputStream(path), null); Object rsp = client.call(req); ... The code at the top creates the The JiBX/WS server implementation code is in the webservice/jibxws/server/src directory. This code is just a simple implementation of the service methods, with no special JiBX/WS hooks. The service configuration files used by JiBX (in this case, webservice/jibxws/config/air-service.xml and webservice/jibxws/config/air-service-pox.xml) specify the service class and operation methods. JiBX/WS advantagesThe main advantages of JiBX/WS are performance and flexibility. Compared to Axis2 and other Java web service frameworks, JiBX/WS is generally about twice as fast in the basic XML/SOAP processing when using plain text XML. Using XBIS encoding makes it even faster, and also cuts the data size to about half of the text XML size. This makes it a very efficient data transfer stack, especially when using TCP transport. Of course, you need to be using JiBX/WS on both client and server in order to take advantage of XBIS encoding and TCP transport (since neither is supported by other web services stacks in a compatible manner). This makes these features most relevant to use within a single organization, or with an established group of partners who can all agree on using JiBX/WS. In other situations you can still use JiBX/WS for standard XML/SOAP services over HTTP transport, to take advantage of the basic JiBX/WS performance advantage. If clients are also using JiBX/WS they can request XBIS responses for even better responses, while maintaining full compatibility with other stacks. You can even mix approaches, for example by activating a TCP/POX service endpoint for internal use within an organization, an HTTP/SOAP endpoint for access to the same service from other SOAP stacks, and an HTTP/POX endpoint for use by clients that just want to work directly with XML without the SOAP wrapper (and without having to go through a SOAP web services stack). |