This article, through a series of experimental steps, shows you how to use the client written by gSOAP, through two-way certificate authentication, access to the Web services built by TOMCAT7 and Axis2. The full text http://www.aliyun.com/zixun/aggregation/32779.html "> step-by-step, divides into several stages to unfold gradually, each stage related attention matter and has encountered some questions also records for the reader reference."
Let's briefly introduce the tools that need to be prepared.
Server: Built by TOMCAT7+AXIS2 client: Certificate generated by the gSOAP tool: Using OpenSSL and JDK Keytool make other: If you experiment under Windows operating systems, the c++/c++ code might also require some integrated development environments, such as Visual c++2010 or Codeblocks+mingw. The compilation of Java code may use eclipse.
In addition, for the convenience of narration, the wording of the following text also makes some conventions:
The installation path for the TOMCAT7 is recorded as:<tomcat_home> the decompression path for the gSOAP compressed package as:<gsoap_home> the OpenSSL installation path will be recorded as:<openssl_home> based on The HTTP Web service URL is recorded as:<service_http> the HTTPS Web service URL as:<service_https>
Build HTTP based Web services
Get your Java code ready.
Here you write a very simple Java code for the SayHello function, the incoming argument is a string, and the return value is "Hello" plus the passed-in string. It is sufficient to publish the Web service later, as shown in Listing 1:
Listing 1. SayHello Source
public class simpleservice{public string SayHello (string name) {return "Hello, +name}}}
Compile with eclipse or JDK's own Javac command-line tool to generate Simpleservice.class files.
Deployment Services
Use the Simpleservice.class file to quickly publish an HTTP based Web service, as follows:
Download the WAR (Web Archive) distribution from the official website of Axis2, for example: Axis2-1.6.2-war.zip extract axis2-1.6.2-war.zip files and obtain Axis2.war files; Axis2.war files are placed under <tomcat_home>\webapps, and startup Tomcat7,axis2.war automatically uncompress the Axis2 directory; place Simpleservice.class in < Tomcat_home>\webapps\axis2\web-inf\pojo.
In this way, a simple Web Service release is complete.
The method of verification is also very simple, open the browser on the Publishing Service computer, view the URL http://127.0.0.1:8080/axis2/services/SimpleService?wsdl, if you can display the contents of the XML structure, the success of the publication.
Of course, you can access the service through other computers on the LAN, if you can't access it, you need to see whether the IP address and port are correct, whether the firewall is properly configured or closed.
In the following article we will write this HTTP based Web service URL as <service_http>.
It is worth mentioning that the Web services we publish here are carried out through the thermal deployment (Hotdeployment) features provided by AXIS2. Open the Axis2.xml file under <tomcat_home>\webapps\axis2\web-inf\conf, and we can see that axis2 the hot deployment switch is turned on by default Hotdeployment, as shown in Figure 1.
Figure 1. AXIS2 Thermal Deployment Switch
In addition, the Pojo deployment directory can be modified as shown in Figure 2:
Figure 2. Axis2 Pojo Deployment Path