blob: 32f699233c1ce0268b1eed9600db42aeb2395ef9 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../skin/tigris.css" type="text/css">
<link rel="stylesheet" href="../skin/mysite.css" type="text/css">
<link rel="stylesheet" href="../skin/site.css" type="text/css">
<link media="print" rel="stylesheet" href="../skin/print.css" type="text/css">
<title>Axis C++ Client User's Guide</title>
</head>
<body bgcolor="white" class="composite">
<div id="banner">
<table width="100%" cellpadding="8" cellspacing="0" summary="banner" border="0">
<tbody>
<tr>
<td align="left">
<div class="groupLogo">
<a href="http://ws.apache.org/"><img border="0" class="logoImage" alt="The Apache WebServices Project" src="../images/project-logo.jpg"></a>
</div>
</td><td align="right">
<div class="projectLogo">
<a href="http://ws.apache.org/axis/"><img border="0" class="logoImage" alt="The Apache Axis Project" src="../images/axis.jpg"></a>
</div>
</td><td valign="top" rowspan="2" align="right" class="search">
<form target="_blank" action="http://www.google.com/search" method="get">
<table summary="search" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#a5b6c6" colspan="3"><img height="10" width="1" alt="" src="../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td colspan="3"><img height="8" width="1" alt="" src="../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td><img height="1" width="1" alt="" src="../skin/images/spacer.gif" class="spacer"></td><td nowrap="nowrap"><input value="ws.apache.org" name="sitesearch" type="hidden"><input size="10" name="q" id="query" type="text"><img height="1" width="5" alt="" src="../skin/images/spacer.gif" class="spacer"><input name="Search" value="GO" type="submit">
<br>
Search WS</td><td><img height="1" width="1" alt="" src="../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td colspan="3"><img height="7" width="1" alt="" src="../skin/images/spacer.gif" class="spacer"></td>
</tr>
<tr>
<td class="bottom-left-thick"></td><td bgcolor="#a5b6c6"><img height="1" width="1" alt="" src="../skin/images/spacer.gif" class="spacer"></td><td class="bottom-right-thick"></td>
</tr>
</table>
</form>
</td>
</tr>
</tbody>
</table>
</div>
<table width="100%" cellpadding="0" cellspacing="0" border="0" summary="nav" id="breadcrumbs">
<tbody>
<tr class="status">
<td><a href="http://www.apache.org/">Apache</a> | <a href="http://ws.apache.org/">WS</a><a href=""></a></td><td id="tabs">
<div class="tab">
<span class="selectedTab"><a class="base-selected" href="../index.html">WebServices-Axis</a></span>
</div>
</td>
</tr>
</tbody>
</table>
<table id="main" width="100%" cellpadding="8" cellspacing="0" summary="" border="0">
<tbody>
<tr valign="top">
<td id="leftcol">
<div id="navcolumn">
<div class="menuBar">
<div class="menu">
<span class="menuLabel">Axis</span>
<div class="menuItem">
<a href="http://ws.apache.org/axis/index.html">Introduction</a>
</div>
<div class="menuItem">
<a href="http://ws.apache.org/axis/news.html">News</a>
</div>
<div class="menuItem">
<a href="http://wiki.apache.org/ws/FrontPage/Axis">FAQ/Wiki</a>
</div>
<div class="menu">
<span class="menuLabel">Get Involved</span>
<div class="menuItem">
<a href="http://ws.apache.org/axis/overview.html">Overview</a>
</div>
<div class="menuItem">
<a href="http://ws.apache.org/axis/cvs.html">CVS Repository</a>
</div>
<div class="menuItem">
<a href="http://ws.apache.org/axis/mail.html">Mailing Lists</a>
</div>
<div class="menuItem">
<a href="http://ws.apache.org/axis/ref.html">Reference Library</a>
</div>
<div class="menuItem">
<a href="http://ws.apache.org/axis/bugs.html">Bugs</a>
</div>
<div class="menuItem">
<a href="http://ws.apache.org/axis/howtobuild.html">HowToBuildSite</a>
</div>
</div>
<div class="menu">
<span class="menuLabel">Axis (Java)</span>
<div class="menuItem">
<a href="http://ws.apache.org/axis/java/index.html">Documentation</a>
</div>
<div class="menuItem">
<a href="http://ws.apache.org/axis/java/install.html">Installation</a>
</div>
<div class="menuItem">
<a href="http://ws.apache.org/axis/java/user-guide.html">User's Guide</a>
</div>
<div class="menuItem">
<a href="http://ws.apache.org/axis/java/developers-guide.html">Developer's Guide</a>
</div>
<div class="menuItem">
<a href="http://ws.apache.org/axis/java/integration-guide.html">Integration Guide</a>
</div>
<div class="menuItem">
<a href="http://ws.apache.org/axis/java/architecture-guide.html">Architecture Guide</a>
</div>
<div class="menuItem">
<a href="http://ws.apache.org/axis/java/reference.html">Reference Guide</a>
</div>
<div class="menuItem">
<a href="http://ws.apache.org/axis/java/reading.html">Reading Guide</a>
</div>
<div class="menuItem">
<a href="http://ws.apache.org/axis/java/requirements.html">Requirements</a>
</div>
</div>
<div class="menu">
<span class="menuLabel">Axis (C++)</span>
<div class="menuItem">
<a href="../cpp/index.html">Home</a>
</div>
<div class="menuItem">
<a href="../cpp/documentation.html">Documentation</a>
</div>
<div class="menuItem">
<a href="../cpp/download.html">Download</a>
</div>
<div class="menuItem">
<a href="http://wiki.apache.org/ws/FrontPage/AxisCPP">Wiki Pages</a>
</div>
<div class="menuItem">
<a href="../cpp/who.html">Who we are</a>
</div>
</div>
<div class="menu">
<span class="menuLabel">Downloads</span>
<div class="menuItem">
<a href="http://ws.apache.org/axis/releases.html">Releases</a>
</div>
<div class="menuItem">
<a href="http://ws.apache.org/axis/interim.html">Interim Drops</a>
</div>
<div class="menuItem">
<a href="http://cvs.apache.org/viewcvs/ws-axis/">Source Code</a>
</div>
</div>
<div class="menu">
<span class="menuLabel">Translation</span>
<div class="menuItem">
<a href="http://ws.apache.org/axis/ja/index.html">Japanese</a>
</div>
</div>
<div class="menu">
<span class="menuLabel">Related Projects</span>
<div class="menuItem">
<a href="http://ws.apache.org/wsif/">WSIF</a>
</div>
<div class="menuItem">
<a href="http://cvs.apache.org/viewcvs/*checkout*/ws-wsil/java/README.htm">WSIL</a>
</div>
<div class="menuItem">
<a href="http://www-124.ibm.com/developerworks/projects/wsdl4j/">WSDL4J</a>
</div>
<div class="menuItem">
<a href="http://www.uddi4j.org/">UDDI4J</a>
</div>
</div>
<div class="menu">
<span class="menuLabel">Misc</span>
<div class="menuItem">
<a href="http://ws.apache.org/axis/who.html">Who We Are</a>
</div>
<div class="menuItem">
<a href="http://ws.apache.org/axis/contact.html">Contact</a>
</div>
<div class="menuItem">
<a href="http://ws.apache.org/axis/legal.html">Legal</a>
</div>
<div class="menuItem">
<a href="http://ws.apache.org/axis/docs.html">Notes/Docs</a>
</div>
</div>
</div>
</div>
</div>
</td><td>
<div id="bodycol">
<div class="app">
<div align="center">
<h1>Axis C++ Client User's Guide</h1>
</div>
<div class="h3">
<div class="h3">
<h3>Contents</h3>
</div>
<a href="#Introduction">Introduction</a><a href="#Pre_reqs">
<br>Pre-requisites</a>
<br>
<a href="#Generating_and_using_client_stubs">Generating and using client -stubs</a>
<div class="h3">
<h3>Introduction</h3>
</div>
<p>
<a name="Introduction"></a>In order to use web services you need to create client-side stubs that help you to access the service You then use these stubs within your application.<br>If you are also responsible for writing the service you need to create the service skeletons and then complete them. This document explains how to use the Axis CPP tooling (WSDL2Ws) to generate and use the client code. If you want to learn how to create your web services please <a href="serveruser-guide.html">look here</a>.</p>
<div class="h3">
<h3>Pre-requisites</h3>
</div>
<p>
<a name="Pre_reqs"></a>WSDL2Ws is a 100% java tool and requires a version of Java to be on the machine that you create your stubs and skeletons on. The version of Java that is required is &gt;= 1.4<br>WSDL2Ws also has a number of pre-requisite jar files that need to be added to your classpath when you run the tooling<br>
<br>&lt;AxisCPP Install dir&gt;/lib/axis/wsdl2ws.jar: Contains the main WSDL2Ws code.<br>&lt;AxisCPP Install dir&gt;/lib/axisjava/axis.jar: Contains the Axis java code which WSDL2Ws is based on<br>&lt;AxisCPP Install dir&gt;/lib/axisjava/commons-discovery.jar:<br>&lt;AxisCPP Install dir&gt;/lib/axisjava/commons-logging.jar;<br>&lt;AxisCPP Install dir&gt;/lib/axisjava/jaxrpc.jar;<br>&lt;AxisCPP Install dir&gt;/lib/axisjava/saaj.jar;<br>&lt;AxisCPP Install dir&gt;/lib/axisjava/wsdl4j.jar<br>
<br>If you want to learn more about WSDL2Ws please see <a href="arch/WSDL2Ws.html">this reference</a> document.</p>
<div class="h3">
<h3>Generating and using client-side stubs</h3>
</div>
<p>
<a name="Generating_and_using_client_stubs"></a>AxisCPP has Java based tooling. If you supply the WSDL which describes your service then WSDL2Ws will produce client-side stubs for you. All you need to do is create your application that uses those stubs. Throughout this section we will use the Calculator service that comes with Axis as an example of how to use the tooling.</p>
<p>
<strong>Note:</strong> In order to run the application discussed below you need the "calculator" service deployed to a server. If you don't want to deploy the calculator service then you need to follow the instructions below but use your own WSDL files that describe your service. If you do want to deploy the calculator service for Apache web server or the simple_axis_server please <a href="serveruser-guide.html">go here</a>. Once you've deployed your service then come back to these instructions and run the calculator client..</p>
<div class="h4">
<h4>Generating Calculator client C++ classes</h4>
</div>
<p>Firstly copy the Calculator wsdl to the client samples directory e.g. (linux)</p>
<p>
<strong>cd &lt;Axis installation directory&gt;/samples/client/calculator</strong>
</p>
<p>
<strong>cp -f &lt;Axis installation directory&gt;/wsdls/Calculator.wsdl ./</strong>
</p>
<p>
<strong>IMPORTANT:</strong>In this example we are showing you how to use the WSDL2Ws tooling to generate the stubs using Calculator.wsdl. However, in the &lt;Axis installation directory&gt;/samples/client/calculator folder you will already find generated files. If you wish to use those without generating new ones you can do so. We recommend that you run the calculator sample with the already generated files firstly and later practice using the tooling with Calculator.wsdl.<br>
<br>Next you create the client-side stubs that represent the Calculator service.</p>
<p>
<strong>Note:</strong> Don't forget to add all of the <a href="#Pre-requisites">pre-requisite</a> jar files into your classpath</p>
<p>
<strong>java org.apache.axis.wsdl.wsdl2ws.WSDL2Ws Calculator.wsdl -lc++ -sclient</strong>
</p>
<p>
<strong>
<br>Note:</strong> If you specify <strong>-o&lt;target directory&gt;</strong> you will have source generated inside the specific folder instead of the current folder where the tool is run.<br>
<br>You now have the client-side stubs generated for you. You now need to create a client that uses those stubs. This class contains a main method in which Calculator instance is created and its methods are called.</p>
<p>
<strong>#include "Calculator.h"</strong>
<br>
<strong>#include&lt;stdio.h&gt;</strong>
<br>
<strong>int main()</strong>
<br>
<strong>&nbsp;{</strong>
<br>
<strong>&nbsp;&nbsp;Calculator c;</strong>
<br>
<strong>&nbsp;&nbsp;int intOut;</strong>
<br>
<strong>&nbsp;&nbsp;c.add(20, 40, intOut);</strong>
<br>
<strong>&nbsp;&nbsp;printf("result is = %d\n", intOut);</strong>
<br>
<strong>&nbsp;&nbsp;return 0;</strong>
<br>
<strong>&nbsp;}</strong>
</p>
<p>Now build your client application with your compiler of choice (in this example we have used g++ on a linux system)<br>
<br>
<strong>cd &lt;Axis installation directory&gt;/samples/client/calculator</strong>
<br>
</p>
<strong>g++ *.cpp -I&lt;Axis installation directory&gt;/include -L&lt;Axis installation directory&gt;/lib -ldl -laxiscpp_client -ocalculator</strong>
<br>
<p>
<br>
<strong>Note:</strong>In order to run your application you need the calculator service deployed to a server. In order to do that for Apache web server or the simple_axis_server please <a href="serveruser-guide.html">go here</a>. Once you've deployed your service then come back to these instructions and run the calculator service.<br>
<br>In this instance we have deployed the service to localhost. and are asking the calculator service to add 10 and 5 for us.<br>
<br>Running the calculator sample (linux)<br>
<strong>./calculator add 10 5 http://localhost/axis/Calculator</strong>
</p>
<p>Now that you've done the sample here you can go on and create your own services and clients using your own service definitions files (WSDL's).<br>
<br>Thankyou for using Axis CPP :-)</p>
<div id="pdf" align="right">
<a href="clientuser-guide.pdf"><img alt="PDF" src="../skin/images/pdfdoc.gif" class="skin"><br>
PDF</a>
</div>
</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
<div id="footer">
<table summary="footer" cellspacing="0" cellpadding="4" width="100%" border="0">
<tbody>
<tr>
<td colspan="2">
<div align="center">
<div class="copyright">
Copyright &copy; 2000-2005&nbsp;The Apache Software Foundation. All rights reserved.
</div>
</div>
</td>
</tr>
<tr>
<td align="left"></td><td align="right">
<div align="right">
<div class="credit"></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>