| <html> |
| <head> |
| <meta http-equiv="content-type" content=""> |
| <title>TCP transport</title> |
| </head> |
| |
| <body lang="en"> |
| <h1>TCP transport</h1> |
| |
| <p>Axis2 supports TCP as a transport. Axis2 has support for both send |
| and receive SOAP Messages via TCP. TCP transports do not have any Application level |
| Headers and the SOAP Message that sends should be self contained. This make |
| the interaction fast and simple. Yet the main limitation of the TCP transport |
| is absence of the request URI, and the Service dispatching should use a |
| alternative method. There is two main alternatives methods.</p> |
| <ol> |
| <li>Use the name space URI of the first child element for the |
| dispatching</li> |
| <li>Enable the WS-Addressing, in the case of Alpha release, Addressing |
| is default</li> |
| </ol> |
| |
| <p>When the TCP request is sent, it is users responsibility either to use |
| addressing or use alternative method.</p> |
| |
| <h2>How to start the TCPServer</h2> |
| |
| <p>The TCP server can be started by running the class |
| org.apache.axis2.transport.tcp.TCPServer with two parameters <a |
| href="faq.html#b5">repository</a> and port number as argument. This class |
| needed all the axis dependency jars in the classpath. New Services can be |
| added in the usual way by droping the archives to repository, read the <a |
| href="userguide.html">User Guide</a> for more information</p> |
| |
| <p>Alternatively the TCP Server can be run with tcp-server.bat/ tcp-server.sh |
| file in the bin directory of the Binary distribution of TCP Server.</p> |
| |
| <h2>How send SOAP Messages with TCP transport</h2> |
| |
| <p>The TCP transport can be enabled very easily from the call API, following |
| code segment demonstrate how it can be done.</p> |
| <source><pre>OMElement payload = ... |
| |
| org.apache.axis2.clientapi.Call call = new org.apache.axis2.clientapi.Call(serviceContext); |
| call.setTo(targetEPR); |
| call.setTransportInfo(Constants.TRANSPORT_TCP, Constants.TRANSPORT_TCP, false); |
| |
| OMElement result = |
| (OMElement) call.invokeBlocking("operation", payload); |
| call.close();</pre> |
| </source> |
| <p>The method to note is setTransportInfo that accepts sender transport, |
| Listener transport and return path of the TCP Channel need to be |
| used. Since the addressing is engage SOAP Message itself contained. Only other option |
| I can think of is to use the URI of |
| the first child of the SOAP Body to dispatch the service. The Parameter is of |
| the type <a href="faq.html#a2">OMElement</a>, the XML representation of |
| Axis2.</p> |
| |
| <h2>Sample</h2> |
| |
| <p>Sample for a TCP Client can be found from the |
| samples/userguide/src/userguide/clients/TCPClient.java in the binary |
| distribution, this access the same web service explained in the userguide. To |
| try the client first starts the TCPServer with the same repository used for |
| the userguide samples. Since sample is already deployed in the repository |
| while trying the userguide it will be automatically avaliable.</p> |
| |
| <h2>Advanced Topics</h2> |
| |
| <p>Axis2 TCP transport has two parts, a transport Listener for receiving the |
| Messages and transport Sender to send the SOAP Messages. Axis2 installation |
| has both the components built in to itself by default. In the axis2.xml |
| configuration file, two would look like follows.</p> |
| |
| <p>If the TCP server is started manually this configuration does not take |
| effect, this affect the transport Listeners starts by Axis2. (e.g. Listener |
| started by the Complete Async interaction)</p> |
| <source><pre><transportReceiver name="tcp" class="org.apache.axis2.transport.tcp.TCPServer"> |
| <parameter name="port" locked="xsd:false">6060</parameter> |
| </transportReceiver></pre> |
| </source> |
| <p>Following add the TCPTransport Sender</p> |
| <source><pre><transportSender name="tcp" class="org.apache.axis2.transport.tcp.TCPTransportSender"/></pre> |
| </source></body> |
| </html> |