blob: d26e2004c0a47d4440057748a79e92c101db614c [file] [log] [blame]
<html>
<body>
<h1>TCP transport</h1>
<p>Axis2 supports TCP as a default transport, Axis2 has support for both send and receieve SOAP Messages.
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</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 classapth. 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.engageModule(new QName(Constants.MODULE_ADDRESSING));
call.setTransportInfo(Constants.TRANSPORT_TCP, Constants.TRANSPORT_TCP, false);
OMElement result =
(OMElement) call.invokeBlocking("echo", payload);
call.close();
</pre>
</source>
<p>The method to note is setTransportInfo that accepts sender transport, Listener transport and should the return path of the TCP Channel need to be used. It is good Idea to engage the addressing module to make the SOAP Message self 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 represntation 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 accsess 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 avalible.</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 the 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>
&lt;transportReceiver name="tcp" class="org.apache.axis2.transport.tcp.TCPServer"&gt;
&lt;parameter name="port" locked="xsd:false"&gt:6060&lt;/parameter&gt;
&lt;/transportReceiver&gt;
</pre>
</source>
<p>Following add the TCPtransport Sender</p>
<source><pre>&lt;transportSender name="tcp" class="org.apache.axis2.transport.tcp.TCPTransportSender"/&gt;
</pre></source>
</body>
</html>