blob: a2b9962da5666d92ac6cfb932cbcab1c4c89a0f9 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Axis2 Transports - </title>
<style type="text/css" media="all">
@import url("./css/maven-base.css");
@import url("./css/maven-theme.css");
@import url("./css/site.css");
</style>
<link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body class="composite">
<div id="banner">
<a href="../transports" id="bannerLeft">
</a>
<a href="http://www.apache.org" id="bannerRight">
<img src="images/asfLogo.jpg" alt="" />
</a>
<div class="clear">
<hr/>
</div>
</div>
<div id="breadcrumbs">
<div class="xleft">
Last Published: 07 Dec 2009
</div>
<div class="xright"> <a href="http://www.apache.org/" class="externalLink">Apache</a>
|
<a href="../../">WebServices</a>
|
<a href="../">Commons</a>
|
<a href="../../axis2/">Axis2</a>
|
<a href="http://synapse.apache.org/" class="externalLink">Synapse</a>
</div>
<div class="clear">
<hr/>
</div>
</div>
<div id="leftColumn">
<div id="navcolumn">
<h5>Axis2 Transports</h5>
<ul>
<li class="none">
<a href="index.html">About</a>
</li>
<li class="expanded">
<a href="download_index.html">Downloads</a>
<ul>
<li class="none">
<a href="download.cgi">Releases</a>
</li>
<li class="none">
<a href="source-repository.html">Source Code</a>
</li>
</ul>
</li>
<li class="expanded">
<a href="docs_index.html">Documentation</a>
<ul>
<li class="none">
<a href="jms.html">JMS Transport</a>
</li>
<li class="none">
<a href="mail.html">Mail Transport</a>
</li>
<li class="none">
<strong>TCP Transport</strong>
</li>
<li class="none">
<a href="sms.html">SMS Transport</a>
</li>
<li class="none">
<a href="apidocs/index.html">Java Doc</a>
</li>
</ul>
</li>
<li class="expanded">
<a href="project-info.html">Project Information</a>
<ul>
<li class="none">
<a href="mail-lists.html">Mailing Lists</a>
</li>
<li class="none">
<a href="building.html">Building</a>
</li>
<li class="none">
<a href="issue-tracking.html">Issue Tracking</a>
</li>
<li class="none">
<a href="dependencies.html">Dependencies</a>
</li>
<li class="none">
<a href="dependency-convergence.html">Dependency Convergence</a>
</li>
<li class="none">
<a href="dependency-management.html">Dependency Management</a>
</li>
<li class="none">
<a href="plugins.html">Plugins</a>
</li>
<li class="none">
<a href="plugin-management.html">Plugin Management</a>
</li>
<li class="none">
<a href="team-list.html">Project Team</a>
</li>
<li class="none">
<a href="project-summary.html">Project Summary</a>
</li>
</ul>
</li>
</ul>
<a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
<img alt="Built by Maven" src="./images/logos/maven-feather.png"></img>
</a>
</div>
</div>
<div id="bodyColumn">
<div id="contentBox">
<div class="section"><h2>TCP Transport</h2>
<p>This document explains how to send and receive SOAP messages via TCP in Axis2.</p>
<div class="section"><h3><a name="Content">Content</a></h3>
<ul><li><a href="#Content">Content</a></li>
<li><a href="#Introduction">Introduction</a></li>
<li><a href="#How_to_Start_the_TCPServer">How to Start the TCPServer</a></li>
<li><a href="#How_to_Send_SOAP_Messages_Using_TCP_Transport">How to Send SOAP Messages Using TCP Transport</a></li>
<li><a href="#Samples">Samples</a></li>
<li><a href="#Transport_Components">Transport Components</a></li>
</ul>
</div>
<div class="section"><h3><a name="Introduction">Introduction</a></h3>
<p>Axis2 supports TCP as a transport. It supports both sending and receiving SOAP messages via TCP. A TCP transport does not have any application level headers and the SOAP message that is sent should be self-contained. This makes the interaction fast and simple. However, since there are no application headers, it does not have the privilege of having a request URI, and Service dispatching should be done by an alternative method. Thus, RequestURIBasedDispatcher cannot be used. The following are the two main alternatives available for dispatching in the Axis2 environment:</p>
<ol type="1"><li>Use the name space URI of the first child element of SOAPBody. (SOAPMessageBodyBasedDispatcher).</li>
<li>Enable WS-Addressing. In the case of version 1.1 and 1.1.1 releases Addressing is default (SOAPActionBasedDispatcher).</li>
</ol>
<p>When the TCP request is sent, it is the user's responsibility to use either Addressing or the SOAP body base mechanism.</p>
</div>
<div class="section"><h3><a name="How_to_Start_the_TCPServer">How to Start the TCPServer</a></h3>
<p>The TCP server can be started by running the class org.apache.axis2.transport.tcp.TCPServer with two parameters - repository and port number, as arguments. This class needs all the Axis dependency JARs in the classpath. New services can be added in the usual way by dropping the archives to the repository.</p>
</div>
<div class="section"><h3><a name="How_to_Send_SOAP_Messages_Using_TCP_Transport">How to Send SOAP Messages Using TCP Transport</a></h3>
<p>TCP transport can be enabled easily from the call API. The following code segment demonstrates how this can be done.</p>
<div class="source"><pre>OMElement payload = ...
ServiceClient serviceClient = new ServiceClient();
Options options = new Options();
options.setTo(targetEPR);
options.useSeparateListener(false);
serviceClient.setOptions(options);
OMElement response = serviceClient.sendReceive(payload);</pre>
</div>
<p>The transport that should be invoked is inferred from the targetEPR (tcp://...). In this case it is TCP and the listener is also TCP. The SOAP message has to be self contained in order to use Addressing. The other option is to use the URI of the first child of the SOAP Body to dispatch the service. The parameter is of the type OMElement, the XML representation of Axis2.</p>
</div>
<div class="section"><h3><a name="Samples">Samples</a></h3>
<p>A sample for a TCP Client can be found from the samples/userguide/src/userguide/clients/TCPClient.java in the binary distribution. This accesses the same Web service explained in the Axis2 Advanced User's Guide. The client first starts the TCPServer with the same repository used for the Axis2 Advanced User's Guide samples. Since the sample is already deployed in the repository, as per the userguide, it will be automatically available.</p>
<p>In order to run the TCPClient.java, addressing should be engaged both in the client and server sides. On the client side, you can engage addressing by copying the addressing-@axis2_version@.mar (AXIS2_HOME/repository/module) to AXIS2_HOME/lib directory.</p>
</div>
<div class="section"><h3><a name="Transport_Components">Transport Components</a></h3>
<p>The Axis2 TCP transport has two components, a transport Listener for receiving the messages and a transport Sender to send the SOAP Messages. The Axis2 installation has both the components built into itself by default. In the axis2.xml configuration file, the two TCP transport components can be configured as shown below.</p>
<p>The following XML lines initialize the TCPTransport Receiver:</p>
<div class="source"><pre>&lt;transportReceiver name=&quot;tcp&quot; class=&quot;org.apache.axis2.transport.tcp.TCPServer&quot;&gt;
&lt;parameter name=&quot;port&quot;&gt;6060&lt;/parameter&gt;
&lt;/transportReceiver&gt;</pre>
</div>
<p>The following XML lines add the TCPTransport Sender:</p>
<div class="source"><pre>&lt;transportSender name=&quot;tcp&quot; class=&quot;org.apache.axis2.transport.tcp.TCPTransportSender&quot;/&gt;</pre>
</div>
<p>Note: If the TCP server is started manually, this configuration does not take effect. In return, this affects the transport Listener's start by Axis2. (e.g. Listener started by the Complete Async interaction)</p>
</div>
</div>
</div>
</div>
<div class="clear">
<hr/>
</div>
<div id="footer">
<div class="xright">&#169;
2004-2009
The Apache Software Foundation
</div>
<div class="clear">
<hr/>
</div>
</div>
</body>
</html>