Creation of an Axis Web Service and a gSOAP client
http://www.dfki.de/~sberg/smartweb/sysgroup/Axis_gSoap_Development.html
- Linux platform
- C(++) Compiler
- gSOAP 2.7.0 [download]
- Apache Axis 1.3 [download]
- Java jdk 1.5
- Tomcat 5.5.9 (This tutorial assumes, that the Tomcat server runs on Port 8080.)
1) Create a WSDL file
The WSDL file <TextService.wsdl> can be generated by hand or utilizing tools for the generation of WSDL files.
2) Build the server-side classes
command: java org.apache.axis.wsdl.WSDL2Java --server-side --skeletonDeploy true TextService.wsdl
The optional setting 'skeletonDeploy true' causes the automatical generation of skeleton classes for each in the header file defined method. The skeleton routines can be readily used to implement one or more of the remote methods in a new SOAP Web Service.
The server-side classes (skeleton and service) are saved in the directory, specified by the namespace. The example Web Services with Apache Axis explaines the creation and deployment of a service more precisely.
3) Implementation of a Web Service
The methods of the automatically created class TextServiceSoapBindingImpl.java must be implemented.
1) Create a header file
Use the WSDL parser wsdl2h to create the header file <gSoapTextClient.h>. Therefore it is necessary to call the WSDL file of the created Axis Web Service, which is located at the Tomcat Web server.
command: wsdl2h -o gSoapTextClient.h http://localhost:8080/axis/services/TextService?wsdl
The method processData must be changed in that effect, that the parameters are pointers.
[ processData(std:string *request, std:string *response)]
2) Build the necessary stub and skeleton classes
The implementation of a SOAP client application needs a stub routine for each remote method. This classes are automatically generated by the stub and skeleton compiler soapcpp2.
command: soapcpp2 -I/<gsoap-path> gSoapTextClient.h
3) Implementation of the client class
#include gSoapTextClient.nsmap ... // service address const char server[] = "http://localhost:8080/axis/services/TextService"; main() { struct soap soap; soap_init(&soap); // read input ifstream infile ... // remote call int responseflag = soap_call___ns1__processData(&soap, server, "", requestData, &responseData); ... }
4) Compile the client class
command:
g++ -Wno-deprecated -I/<gsoap-path> -o gSoapTextClient gSoapTextClient.cpp soapC.cpp soapClient.cpp <gsoap-path>/stdsoap2.cpp
5) Start the gSOAP client
To start the gSOAP client, the object file must be called.
command: gSoapTextClient -i ExampleOutput_RDF