Axis Development WebService
Several recent projects have involved the application of different technical platforms in different fields, so the WebService technology is adopted in the interface part of each system to realize the business docking of different systems.
As we use the Java-EE platform, the following focuses on using axis to develop and deploy WebService applications on the Java EE platform.
The following is an example of a user login to introduce the development process.
1. Axis Development package download.
An item of Apache, please download (abbreviated)
2. method of writing
Package ZPF;
Import java.util.*;
Import java.io.*;
public class Ssowebservice
{
/**
Login and get user information
*/
public boolean login (string loginID, string password) {
Boolean ret=false;
if (Loginid.equals ("ZPF") &&password.equals ("123"))
ret= true;
Else
Ret=false;
return ret;
}
/**
Get all Department information
*/
Public ZPF. Departmentinfo[] Getalldepts () {
ZPF. Department dept=new ZPF. Department ();
ZPF. Departmentinfo[] Ret=dept.getalldepartment ();
return ret;
}
}
Http://localhost:8080/kmwhc/services/SSOWebservice
Compile, pass, not be tired of stating
3. Modify Web.xml
Add the following code
<listener>
<listener-class>org.apache.axis.transport.http.AxisHTTPSessionListener</listener-class>
</listener>
<servlet>
<servlet-name>AxisServlet</servlet-name>
<display-name>apache-axis servlet</display-name>
<servlet-class>
Org.apache.axis.transport.http.AxisServlet
</servlet-class>
</servlet>
<servlet>
<servlet-name>AdminServlet</servlet-name>
<display-name>axis Admin servlet</display-name>
<servlet-class>
Org.apache.axis.transport.http.AdminServlet
</servlet-class>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet>
<servlet-name>SOAPMonitorService</servlet-name>
<display-name>SOAPMonitorService</display-name>
<servlet-class>
Org.apache.axis.monitor.SOAPMonitorService
</servlet-class>
<init-param>
<param-name>SOAPMonitorPort</param-name>
<param-value>5001</param-value>
</init-param>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/servlet/AxisServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>*.jws</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SOAPMonitorService</servlet-name>
<url-pattern>/SOAPMonitor</url-pattern>
</servlet-mapping>
<!--Uncomment this if you want the admin servlet-->
<!--currently the havent settled on a media type for WSDL;
http://www.w3.org/TR/2003/WD-wsdl12-20030303/#ietf-draft
For now we go with the basic ' it ' s XML ' response-->
<mime-mapping>
<extension>wsdl</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xsd</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
4. The Distribution Department
(1) Web-inf to establish the file SERVER-CONFIG.WSDD
(2) The contents of the document are as follows:
The blue section defines the name of the service, the class method used.
The red section defines the custom type of the return value used by the method of the service.
<?xml version= "1.0" encoding= "gb2312"?>
<deployment xmlns= "http://xml.apache.org/axis/wsdd/" xmlns:java= "Http://xml.apache.org/axis/wsdd/providers/java" >
<globalConfiguration>
<parameter name= "AdminPassword" value= "admin"/>
<parameter name= "Enablenamespaceprefixoptimization" value= "true"/>
<parameter name= "attachments. Directory "value=" d:/jakarta-tomcat-5.0.28/webapps/axis/web-inf/attachments "/>
<parameter name= "Disableprettyxml" value= "true"/>
<parameter name= "attachments.implementation" value= "Org.apache.axis.attachments.AttachmentsImpl"/>
<parameter name= "Sendxsitypes" value= "true"/>
<parameter name= "Sendmultirefs" value= "true"/>
<parameter name= "Sendxmldeclaration" value= "true"/>