Mytec
How to create custom network transport for JAX-WS
In this entry I will try to describe how to implement custom JAX-WS transport from some experience I got with JMS and TCP implementations.
Client side:
1) Implement your own transport pipe, which implements Pipe interface. Mainly you have to implement interface's method process(Packet), which should do actual work on serializing Packet and send it, then wait(or not) for reply packet, deserialize it and pass back it as return param.
2) To plug your transport pipe, you need to create own transport factory. It means its required to write a factory, which extends TransportPipeFactory and actually plugs transport pipe to ws pipeline. Probably it makes sence to check it current service requires exactly this transport to be plugged by checking ws address schema. If return null as pipe - then default (http) transport pipe will be tried to be pluged.
3) And last: to say JAX-WS client framework to use just created TransportPipeFactory - its required to supply configuration file, which should be located at classpath META-INF\services\com.sun.xml.ws.api.pipe.TransportPipeFactory this text file have to contain a line with full classname of custom transport pipe factory.
Server side:
1) For server side first its required to build adapters for provided webservices. Transport Adapter class should do all transport specific work to deserialize and serialize Packet and make it ready for processing by jax-ws service-side pipeline. Its useful to use Adapter.Toolkit for processing packets, as common transport resources, packet encoder, decoder could be stored to pool and reused. Basically Adapter should deserialize Packet from underlying transport, pass it to pipeline head, get reply packet from it and serialize it back to underlying transport. Transport specific Adapter could be constructed manually, with self written code, or as it is in JMSTransport example - DeploymentDescriptorParser was used, which originally located in http specific package, but obviously could be reused for other transports. This parser uses webservice description file (sun-jaxws.xml) to create adapters, its just required to provide some artifacts for that including DeploymentDescriptorParser.AdapterFactory implementation class, which is responsible to create Adapter instances.
2) Actually it could be 1st step:) Its required to implement incoming message listener. If its tcp - listen on tcp port, jms - listen on some queue or topic and based on some transport specific header or some other agreement decide, what is the correspondent adapter for that request and pass transport specific artifacts to adapter for feature processing, including sending actual reply.
Looking at client and server side custom transport implementation, it
seems to me, that client side is easier and more clear in
implementation, server's is not perfect and requires more work, also don't like too much my solution to use http specific util like DeploymentDescriptorParser. So hope soon with help of jax-ws team I will be able to come with better solution :)
Posted at 04:12PM Jun 01, 2006 by oleksiys in Web Services | Comments[3]
Posted by Arun Gupta's Blog on October 19, 2006 at 07:24 AM CEST #
Posted by Cialis. on April 16, 2007 at 05:24 AM CEST #
http://forum.java.sun.com/thread.jspa?threadID=5207086&tstart=0
SOAP/TCP, WSIT performance:
I just created a sample web service with a simple method which returns an array of doubles.
First try, array size: 10, and "allow tcp transport" on the server side and "automatically select optimal encoding..", "automatically select optimal transport.." on the client side. In average it took 5 msec per each call.
Second try, same as the first try, but TCP disabled on both of client and server and surprisingly it took the same time. Also I tried different array sizes and again the average call time was the same!
Apparently TCP, fast infoset had no effect!
Any comment?
Posted by 199.64.0.252 on August 17, 2007 at 09:49 PM CEST #