Building and Deploying Axis C++
Getting a cvs checkout
Getting necessary third party software
Installing Apache and Expat
Setting up the build environment and building
Axis
Deploying Axis in Apache
Deploying a web service in Axis C++
Generating Serverside Skeletons/ wrappers and client
side stubs
Using eclipse to build and run WSDL2Ws
Building and running WSDL2Ws on the command line
Building and Deploying the web service
Building and deploying the provided interop web services samples
Building and deploying the provided interop client applications
Consuming the web service with Axis C++ client
Coding and Running the client
Creating and Building your own transport layer
Creating and Building your own parser
Before you follow this guide, make sure that you have followed the Windows User Guide also knows how to use binaries
Visit http://ws.apache.org/ Click on “axis” and then on “CVS Repository”
to find details on accessing the CVS Repository. It will have instructions
similar to the following.
“Anyone can checkout source code from our anonymous CVS server. To do so,
simply use the following commands (if you are using a GUI CVS client,
configure it appropriately):
cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic login
password: anoncvs
cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic checkout ws-axis
The examples given below will be based on these lines of instructions.
To use the command line cvs client go to http://www.cvshome.org, click on the
"CVS Downloads" link. In the resulting page there will be a link named
"historical download pages", under the heading "CVS downloads", where you can
download the cvs binaries for Windows. Download the Windows cvs binaries.
Extract the cvs binaries from the downloaded zip file. There will be a
“cvs.exe” file when this is extracted. Set the PATH environment variable to
where “cvs.exe” is.
You would have to do the following to get a checkout from the command line
cvs client.
cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic login
Now you will be prompted for the password. Enter the password.
password: anoncvs
Now enter the following cvs command to checkout the axis Repository.
cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic checkout ws-axis
The checkout of the repository will be created in the current directory in a
folder named “ws-axis”
The checked out folder ws-axis will be referred to as [CHECKOUT_HOME] from
this point on.
Expat XML Parser
You can get expat binaries from the url http://sourceforge.net/projects/expat/
This documentation was tested with the expat 1.95.7 which is
distributed as expat_win32bin_1_95_7.exe.
(Axis Cpp Developers can use either Xerces-c or the Expat XML Parsers to build the Axis Cpp. The Source in CVS supports expat out of the box.)
Apache Web Server
Download the Apache web server from www.apache.org. Currently Axis supports apache 1.3.x and 2.X. This documentation was tested with Apache 1.3.28 and Apache 2.0.44.
Expat
Run the file expat_win32bin_1_95_7.exe . The folder to which Expat is unzipped will be referred to as [EXPAT_EXTRACT] from this point onwards.
Apache
Install the Apache web server. By default Apache 1.3.X is installed in "C:\Program Files\Apache Group\Apache" and Apache 2.X in "C:\Program Files\Apache Group\Apache2". These locations will be referred to as [APACHE_HOME] from this point onwards.
1)Copy [EXPAT_EXTRACT]\source\lib\expat.h from expat binary distribution to [CHECKOUT_HOME]\c\include\expat\ directory
2) Copy [EXPAT_EXTRACT]\lib\libexpat.lib to [CHECKOUT_HOME]\c\lib\expat\ directory.
3)Copy libexpat.dll file from [EXPAT_EXTRACT]\Libs to %AXIS_HOME%/libs/
For apache 1.3.X:
1)Copy the include files in "[APACHE_HOME]\include" directory to
"[CHECKOUT_HOME] \c\include\apache1_3\"
2) Copy the ApacheCore.lib file from [APACHE_HOME]\libexec
to [CHECKOUT_HOME]\c\lib\apache1_3.
For apache 2.X:
1)Copy the include files in "[APACHE_HOME]\include" directory to
"[CHECKOUT_HOME]\c\include\apache2_0\"
2) Copy the following lib files libapr.lib, libhttpd.lib files from
"[APACHE_HOME]\lib" to "[CHECKOUT_HOME]\c\lib\apache2_0".
Building the AxisServer and AxisClient dlls
Build the AxisServer and AxisClient projects.(Click on file in Visual C++ ,open Visual C++ Distribution workspace (Distribution.dsw) at [CHECKOUT_HOME]\c\vc\. In the workspace window, File View, right click on the AxisServer project and AxisClient project ).Which will build the AxisServer_D.dll and AxisClient_D.dll
Building Apache Modules (Apache 1.3.X and Apache 2.X)
In Visual C++ (The version used for this documentation was Visual C++ 6.0)
click on file ,open Visual C++ Distribution workspace (Distribution.dsw) at
[CHECKOUT_HOME]\c\vc\.
In the workspace window, File View, right click on either the project "Apache1_3Module files" or
"Apache2_0Module files" and click on the "Set as Active Project" to make it the Active
Project.
Again in Visual C++ right click on either the project "Apache1_3Module" or
"Apache2_0Module" in the workspace window, File View, and then click on Settings on
the popup menu. Select the link tab. Select General from the Category drop
down list. In the Output file name text box put the value
[APACHE_HOME]\modules\mod_axis.dll and click OK.(To build a Apache Module AxisServer.lib should be in the settings Link tab )
Build either Apache1_3Module or Apache2_0Module project.
In Visual C++ right click on either the project "Apache1_3Module" or
"Apache2_0Module" in the workspace window, File View and click "build (selection only)"
to build mod_axis.dll for Apache1_3Module or mod_axis2.dll for Apache2_0Module.
(From here onwards we will refer to these modules as APACHE_MODULE. Replace it
with the correct module for the Apache server version that you have installed). Then build SimpleAxisServer.
Axis Transport Library
In VC++ distribution workspace build AxisTransport project.Then AxisTransport.dll will be built.
Xerces Parser Library and Expat Parser Library
In VC++ distribution workspace build either AxisXMLParserXerces project or AxisXMLParserExpat project. Then AxisXMLParser.dll will be built.
Building AxisTransport_D.dll and AxisXMLParser_D.dll
Build the AxisTransport and AxisXMLParser projects. Which will build the AxisTransport_D.dll and AxisXMLParser_D.dll in [CHECKOUT_HOME]\c\bin.
1) Create a directory structure called "Axis" inside [APACHE_HOME] as
follows.
(Instead, you can copy the folder [CHECKOUT_HOME]\c\deploy to [APACHE_HOME] and rename it to
"Axis" and you will find some of the files that you are asked to create in this guide,
already existing in that folder)
Axis
|__ libs ( Copy [EXPAT_EXTRACT]\Libs\libexpat.dll and paste it inside)
|__ logs (log files are located here)
|__ conf (server.wsdd file is located here)
|__ webservices (The place to put webservice dlls)
|__ wsdls (The directory for the wsdl files of the deployed web services)
2)Set an environment variable named AXIS_HOME and give [APACHE_HOME]\Axis as
the value.
i)You will find AxisServer.dll and APACHE_MODULE in [CHECKOUT_HOME]\c\bin directory.
ii)Copy APACHE_MODULE to [APACHE_HOME]\modules directory of your apache installation.
iii)Copy AxisServer_D.dll to any location specified by your PATH environment variable
iv)Copy AxisTransport_D.dll to any location specified by your PATH environment variable
v)Copy AxisXMLParser_D.dll to any location specified by your PATH environment variable
NOTE:Usually it is a best practice to copy AxisServer_D.dll ,AxisTransport_D.dll and AxisXMLParser_D.dll to [AXIS_HOME]\libs\ directory and add that directory to your PATH environment variable.
2) Set the "PATH" environment variable to the following directories.
[APACHE_HOME]
[APACHE_HOME]\Axis\libs
3) Change the apache configuration file [APACHE_HOME]\conf\httpd.conf to
include the following lines at the bottom.
LoadModule axis_module modules/APACHE_MODULE
<Location /axis>
SetHandler axis
</Location>
4)create a file in [APACHE_HOME]\Axis named "axiscpp.conf" which should
contain the following lines.
LogPath:XXXX
WSDDFilePath:YYYY
Transport_http:ZZZZ (Not necessary)
XMLParser:WWWW
Where XXXX will be the path to a file named AxisLog (The log file)and YYYY
will be the path to the server.wsdd file.ZZZZ will be the path to AxisTransport_D.dll if it's a HTTP(if the selected transport is SMTP then should give that path.WWWW will be the path to AxisXMLParser_D.dll
i.e.
LogPath:[APACHE_HOME]\Axis\logs\AxisLog.log
WSDDFilePath:[APACHE_HOME]\Axis\conf\server.wsdd
Transport_http:[APACHE_HOME]\Axis\libs\AxisTransport_D.dll
XMLParser:[APACHE_HOME]\Axis\libs\AxisXMLParser_D.dll
Note:If the AxisTransport_D.dll and AxisXMLParser_D.dll paths are not given in axiscpp.conf then the hardcoded values will be used.For that set the path of these two in the PATH environment variable or copy them to the same location as the Client.exe.
6)Select start->programs->Apache HTTP server->Control Apache
Server->stop to stop the apache server
(This is because apache will be started automatically by the installation
program)
Open up a DOS terminal and give the command "apache -k start" to start
apache (If Apache 2.0 server does not seem to respond when started this way, try "apache -X").
open a browser and verify whether you can browse http://localhost/ (or give
the machines ip as http://xxx.xxx.xxx.xxx/). If apache is running you will
see the Apache start page in the browser.
In the checked out source code there is a
"wsdl2ws" (i.e. wsdl-to-web
services) written in java that generates server side Skeletons/wrappers and
client side stubs using a given WSDL file. This Section describes how this is
done.
To build and run the java tool this section uses the eclipse platform. For
this documentation eclipse 2.1.0 was used and the jdk version used was
j2sdk1.4.1_01. You will not be able to build the java tool with jdk versions
below 1.4.0.
1)Start the eclipse platform IDE.
Go to File->New->Project.
Select java in the "New Project" dialog and click "Next".
In the "New" dialog that appears give a project Name (e.g. test). In the "New
dialog" keep the "use default" Tick Box checked.
Note down the path in the "Directory" Text Box. This location will be
referred to as [SKELSTUB_HOME] from this point onwards. Click "Next".
Another dialog named "New” will appear. Select the “Source” tab. Select the
project that you created (i.e. test).
Click on “Add Folder…”. In the “Source Folder Selection” dialog that appears
select the project that you created (i.e. test) and click “Create New
Folder…”. In the “New Folder” dialog that appears give a folder name as “src”
and click “OK”. Click “OK” in the “Source Folder Selection” dialog. Click
“Yes” on the confirmation message box that pops up.
Click “Libraries” in the “New” dialog. Click “Add External JARs…”. In the
“JAR Selection” dialog that appears browse to [CHECKOUT_HOME]\
\lib\axisjava and select the following JARs.
axis.jar
commons-discovery.jar
commons-logging.jar
jaxrpc.jar
saaj.jar
wsdl4j.jar
xml-apis.jar
Click “Open”.
Click “Finish” on the “New” dialog.
2) Copy the “org” folder inside [CHECKOUT_HOME]\c\src\wsdl to
[SKELSTUB_HOME]\src. The “org” folder contains the package structure for the
WSDL2Ws java tool.
3) Go to eclipse and right click on the “Package Explorer” window and click
on “Refresh” in the popup menu that appears. Now you should be able to see
the source that was copied, in the “Package Explorer” window. By now eclipse
would have built the WSDL2Ws tool.
For this demonstration we will use a Calculator web service and the WSDL file
for that web service is located at [CHECKOUT_HOME]\c\samples\server\simple.
Copy the Calculator.wsdl to [SKELSTUB_HOME]
In eclipse go to “Run->Run…”.
In the Java Application item select the New_Configuration.Then select the “Main” tab. In “Project” text box give the
name of the project you created (i.e. test).
In the “Main Class” text box give the class as
“org.apache.axis.wsdl.wsdl2ws.WSDL2Ws”.
Select the “Arguments” tab.
In the “Program Arguments” text box give the following argument.
“Calculator.wsdl -o./ServerOut -lc++ -sserver”.
NOTE: These are the arguments for the java tool WSDL2Ws. The usage of the
WSDL2Ws is as follows.
Java org.apache.axis.wsdl.wsdl2ws.WSDL2Ws <wsdl file> -o<output
directory>
-l<c|c++> -s<(server|client)>.
Also note that there cannot be any spaces after a switch (i.e. -o, -l).
Click “Run”.
Now the Skeletons/Wrappers will be generated and you will see messages in the
eclipse console displaying the generated files. The generated
Skeletons/Wrappers will be created in a folder named
[SKELSTUB_HOME]\ServerOut as given in the arguments when you run the tool.
Similarly to generate the client stubs use the following arguments in eclipse
and run.
“Calculator.wsdl -o./ClientOut -lc++ -sclient”.
The generated Stubs will be created in a folder named
[SKELSTUB_HOME]\ClientOut.
For building WSDL2Ws java tool on the command line you require jdk1.4 or
above.
To build WSDL2Ws java tool you should set the CLASSPATH Environment Variable
to point to the following jar files.Create a New Folder called wsdl2wsTool\lib and put those jars in it. You can find
these jars in [CHECKOUT_HOME]\lib\axisjava.
axis.jar
commons-discovery.jar
commons-logging.jar
jaxrpc.jar
saaj.jar
wsdl4j.jar
xml-apis.jar
Open a command window.
Change directory to [CHECKOUT_HOME]\c\src\wsdl.
We will refer to this directory as [SKELSTUB_HOME] as we did during generating Skeletons/Wrappers and Stubs with eclipse.
Run the following command to build the java tool.
javac -sourcepath . org\apache\axis\wsdl\wsdl2ws\WSDL2Ws*.java
NOTE: Notice the spaces between the "dot" after the -sourcepath switch
If the command finishes without any output then the java tool has been
built.
Now copy the Calculator.wsdl file in [CHECKOUT_HOME]\c\samples\server\simple,
which we use in this example to [SKELSTUB_HOME]
Now run the following command to generate the server side skeletons and
wrappers in the same [SKELSTUB_HOME].
Java -classpath .;%classpath% org.apache.axis.wsdl.wsdl2ws.WSDL2Ws Calculator.wsdl -o./ServerOut -lc++ -sserver
You must give the class path exactly as above in that order.
If the tool is successful the tool will display the files it has
generated. The skeletons and stubs will be generated in
[SKELSTUB_HOME]\ServerOut.
Run the following command to generate the client stubs.
Java -classpath %classpath%;. org.apache.axis.wsdl.wsdl2ws.WSDL2Ws
Calculator.wsdl -o./ClientOut -lc++ -sclient
The generated client stubs will be in [SKELSTUB_HOME]\ClientOut
1) If you have followed the above instructions you should have been able to generate the Server
side Skeletons and Wrappers for the Calculator.wsdl
2) Start Visual C++.
3) Go to File->New…
4) Select the “Projects” tab.
5) Select “Win 32 Dynamic-Link Library”.
6) Give a project name (e.g. ws1), give some folder (say "deployws") as the "location" for the project, select the "create new workspace" radio button, and click “OK”.When this procedure is followed the "ws1" project files are created in a folder named "ws1" inside the "deployws" folder.
7) In the dialog that appears select “An empty DLL project” click “Finish” and then “OK”.
8) Right click on the project that you created (i.e. ws1) and click “Add
Files to Project…” on the menu that appears. In the “Insert Files into
Project” dialog select the generated .cpp and .h files in
[SKELSTUB_HOME]\ServerOut and click “OK”.
9) Right click on the project (i.e. ws1)again and click on “Settings…” on
the menu that appears. Click the C/C++ tab and select “Preprocessor” from the
“Category” Drop down list.
Add Axis include directory [CHECKOUT_HOME]c\include\ to the project In the
“Additional include directories”
10)Now business logic should be
added to the generated Skeletons. The Skeletons in this case are Calculator.h
and Calculator.cpp
11) We shall implement two methods available in Calculator.cpp as follows.
int Calculator::add(int Value0, int Value1)
{
return Value0+Value1; //business logic
}
int Calculator::subtract(int Value0, int Value1)
{
return Value0-Value1; //business logic
}
12) Right click on the project (i.e. ws1) and click “Build” on the menu that
appears. Visual C++ should be able to build the project without any errors
now.
13) The ws1.dll will be built in "ws1\Debug" by Visual
C++
14) Place the built ws1.dll file in [APACHE_HOME]\Axis\webservices
15) In addition to this you have to create sever.wsdd file in
[APACHE_HOME]\Axis\conf
The server.wsdd file for this example is
given below
<deployment> <service name="Calculator"> <parameter name="className" value="[APACHE_HOME]\Axis\webservices\ws1.dll"/> <parameter name="allowedMethods" value="subtract add "/> </service> </deployment>
In this file [APACHE_HOME] should be replaced with the actual value of
[APACHE_HOME] (i.e. For this case "C:\Program Files\Apache Group\Apache" for
apache 1.3.x and "C:\Program Files\Apache Group\Apache2" for apache 2.x)
Description of the server.wsdd file
The service element specifies the service name.
<service name="Calculator">
In this parameter element we specify the parameter className and it’s value,
the location of the webservice dll.
<parameter name="className" value="C:\Program Files\Apache
Group\Apache\Axis\webservices\ws1.dll"/>
In this parameter element we specify the parameter allowedMethods and its
value, the methods exposed by the web service (i.e. subtract and add).
Note: A trailing space should be put after every allowed method.
<parameter name="allowedMethods" value="subtract add "/>
16) Now start the Apache web server by typing “apache -k start”. If the Apache server is
running type “apache -k restart”
17) Now type http://localhost/axis/ in a browser and you will see the
“Welcome to Axis C++” page with a listing of deployed services and Calculator service .
1) If you have followed the above instructions you should have been able to generate the Server
side Skeletons and Wrappers for the Calculator.wsdl.
2) Start Visual C++.
3) Go to File->New…
4) Select the “Projects” tab
5) Select “Win 32 Console Application”
6) Give a project name (e.g. calclient) and click “OK”.
Give a project name (e.g. calclient), give some folder (say "wsclient") as the "location" for the project, select the "create new workspace" radio button, and click “OK”.When this procedure is followed the "calclient" project files are created in a folder named "calclient" inside the "wsclient" folder.
7) In the dialog that appears select “An empty project” click “Finish” and
then “OK”.
8) Right click on the project that you created (i.e. ws1) and click “Add
Files to Project…” on the menu that appears.Then Add the generated .cpp and .h files from the [SKELSTUB_HOME]\ClientOut to the project and click “OK”.
9) Right click on the project (i.e. calclient) again and click on
“Settings…” on the menu that appears. Click the “C/C++” tab and select
“Preprocessor” from the “Category” Drop down list.
In the “Additional include directories” give [CHECKOUT_HOME]c\include as the include path.
10) Click the “Link” tab and select “Input” from the “Category” Drop down
list.
Add AxisClient.lib to the “Object/library modules” and in the “Additional library path” give the path.
AxisClient.lib can be found in [CHECKOUT_HOME]\c\bin once you build the AxisClient,AxisTransport,AxisXMLParserXerces or AxisXMLParserExpat projects
of the "Distribution" VC workspace.
Now the client should be coded. Basically this will be a main method. We
will write the main method in the file Calculator.cpp of the VC project "calclient". This is the stub
generated by the java tool in the stub generation step.
Add the following main method to Calculator.cpp
void main() { Calculator cal; int result = cal.add(22, 33); printf("The result is : %d", result); }
It is better to have the path to your AxisXMLParser.dll and AxisTransport.dll in axiscpp.conf or have the dlls where the client exe is.
Right click on the project and click “Build” on the menu that appears.
When the XMLParser is running these steps occur.
1. Locate Parser dll.
2. Create Parser instance by CreateInstance() method.
3. Give the stream to parser by setInputStream() method.
4. Call next() method multiple times.
5. getStatus() to see if the streams are properly passed.
6. Destroy parser object by DestroyInstance().
If Visual C++ complains about missing libs go to Build->Rebuild All (Do
make sure that the apache server is stopped). Now the client exe is built.
Start the Apache server by typing apache -k start and run the exe from Visual C++ by
going to Build->Execute calclient.exe. If all went well now you should see the SOAP Request,
SOAP Response and the result printed by calclient.exe.
1) Open the Visual C++ workspace (interoptests.dsw) at [CHECKOUT_HOME]\c\vc\samples\server\interoptests\ and do a batch build of all projects.
2) You will find the built dynamic libraries at [CHECKOUT_HOME]\c\bin directory. Following are the built DLLs.
base.dll
cbase.dll
cGroupB.dll
doclitbase.dll
doclitgroupB.dll
groupB.dll
3)copy these dlls to [APACHE_HOME]\Axis\webservices
4)Add the required entries to the server.wsdd file in [APACHE_HOME]\Axis\conf to deploy these
interop services.
You can find the required entries in the [CHECKOUT_HOME]\c\deploy\conf\server.wsdd_win file.
You will need to modify the "value" of the "classname" parameter of each service to to point to
the relevant web service dll given above in [APACHE_HOME]\Axis\webservices.
1) Open the Visual C++ workspace (interoptests.dsw) at [CHECKOUT_HOME]\c\vc\samples\client\interoptests\ and do a batch build of all projects.
2) You need to build the AxisClient project in the "Distribution" workspace at [CHECKOUT_HOME]\c\vc\, because you need the AxisClient.lib to complile client applications and AxisClient.dll to run them.
3) You will find the built console applications and AxisClient.dll at [CHECKOUT_HOME]\c\bin directory. Following are the built .exe files.
base.exe
cbase.exe
cgroupB.exe
doclitbase.exe
doclitgroupB.exe
groupB.exe
4) In order to run these samples you should have AxisClient.dll in the PATH environment variable or in the same directory where the .exe is.
When creating your own transport layer refer SoapTransport.h header file for API.To see an example implementation refer AxisTransport.h and AxisTransport.cpp
Implement SoapTransport.h interface according to rules described in the header file.
Transport layer is built separately from Axis. Then Axis loads transport dynamic library through following export functions which you also have to implement.
CreateInstance (SoapTransport *pOut)- Used by Axis to create an instance of your transport class
DestroyInstance (SoapTransport *pIn) - Used by Axis to destroy the created transport class instance
Compile your transport code and build a dynamic library. Add the name of your transport library to axis configuration file (axiscpp.conf) so that Axis can find your library at runtime.
Note:Implement XMLParser.h interface according to rules described there.
When creating your own parser refer XMLParser.h header file for API. To see an example implementation refer SoapParserExpat.h,SoapParserExpat.cpp, SoapParserXerces.h and SoapParserXerces.cpp.
Axis loads the parser dynamic library through following export functions which you also have to implement.
CreateInstance() - Used by Axis to create an instance of your parser class
DestroyInstance() - Used by Axis to destroy the created parser class instance
Compile your parser code and build a dynamic library. Add the name of your parser library to Axis configuration file (axiscpp.conf) so that Axis can find your library at runtime