Download Apache AXIS to implement SOAP (Simple Object Access Protocol). http://ws.apache.org/axis/
The most stable version is currently 1.1
SOAP is a lightweight protocol for exchange information in a dispersed or distributed environment. SOAP is based on XML, consisting of three parts: a must-have SOAP package, an optional SOAP head and a must-have SOAP body.
Usually, SOAP = HTTP RPC XML. That is, SOAP uses HTTP as the underlying communication protocol, as an interactive mode, XML as the format of data transmission.
Web Service develops the skills that need to be mastered: Java, thread, synchronization, ClassLoader, Error Exclude, NPE (NullPointerexception) and other common errors, and can handle, servlet, how to release web applications to application servers (Tomcat, etc.)
TCP / IP, SOCKET API, XML ... more scary! To learn: (1 Installation Configuration AXIS ~~ Install Tomcat 4.x or above version (4.X version with XML parser) ~~ Unzip the axis1.1.zip package, find the Axis folder under the WebApps directory Copy the AXIS folder to the WebApps folder in Tomcat. ~~ Put all the files in the web-inflib under the Axis directory in Tomcat Copy to Tomcat's CommONLib directory. (Where you want to add in AXIS JAR file, you have to copy a copy to Tomcat's commonlib directory). ~~ My Computer -> Properties -> Advanced -> Environment Variables -> System Variable Add: AXIS_HOME% Tomcat_Home% WebAppsaxis (Tomcat Directory) AXIS_LIB% AXIS_HOME% LIB AXISCLASSPATH% AXIS_LIB% AXIS.JAR;% AXIS_LIB% Commons-Discovery.jar;% AXIS_LIB% Commons-logging.jar;% AXIS_LIB% jaxrpc.jar;% AXIS_LIB% Saaj.jar;% AXIS_LIB% LOG4J-
1.2.8
.jar;% AXIS_LIB% XML-APIS.jar;% AXIS_LIB% XerceptImpl.jar Modify ClassPath, plus:% AXIS_LIB% AXIS.jar;% AXIS_LIB% Commons-Discovery.jar;% AXIS_LIB% commons-logging.jar ;% AXIS_LIB% jaxrpc.jar;% AXIS_LIB% saaj.jar;% AXIS_LIB% log4j-
1.2.8
.jar;% AXIS_LIB% XML-APIS.jar;% AXIS_LIB% XERCESIMPL.JAR Note Check if ClassPath is correct: (Some software set a classpath in the user variable area, affects, such as: Xmlspy) In the DOS mode : Echo% classpath% ~~ Check configuration: Start Tomcat, access http: // localhost: 8080 / axis /,
Verify whether Axis works: http: // localhost: 8080 / axis / happyaxis.jsp If normal display is normal.
In the figure, the last word "The Core Axis Libra ...." To ensure that Core Axis Libraries Are Present, if you have any core library is missing, find the corresponding JAR file on the appropriate link to which it provides, and COPY In the Axis folder web-inflib inside the tomcat directory, don't forget that Tomcat's own commonLib is also copy. Until all Core Library arepent. It's basically configured. Now let's start making an example of a bit of WEB SERVICE. Step by step :) Target: Simulate a bank deposit system, the specific implementation of the deposit is used as a service to provide AXIS to provide two service release methods, one is instant deployment, one is custom release ( Custom deployment. 1. Use instant release Java Web Service (JWS) "for instant release is one of the features of Axis, using instant release to enable users to provide the source code of the Java class providing service, you can quickly release it into a web service. Whenever the user calls this type of service, AXIS will automatically compile, even if the server is restarted, it is not necessary to do anything, using very simple and fast. "Using instant release first needs a Java source file that implements service functions, will Its extension is changed to .jws (Java Web Service Abbreviation) and then put the file in the WebAppsAxis directory below Tomcat. But JWS web service release is a very simple web service release method, you can't use the package in the page, and because the code is compiled in the runtime, you are also difficult to find the error. It is not good, but we still come to see an example: Everyone finds the Calculate.jws file under WebAppsaxis, and then opens. No need to compile. Publish: http: // localhost: 8080 / axis / distance .jws? WSDL If you see the following WSDL description means that you have been successful: How to use this service? Is there a file of a CalcClient.class in TomclassessampleSuserGuideExample2? This file is an example of the client of the Calculate provided by the corresponding AXIS. In the DOS mode, go to Tomcat 5.0WebappsaXisWeb-Infclasses directory: java samples.userGuide.example2.calcclient add 3 4 isn't you get 7? If you appear NodeFClass's error, use ECHO to check each environment variable. Generally is wrong here. The source code corresponding to Calculator is inside SamplesUserGuideExample2 inside the downloaded Axis.zip.
2. Using custom release Web Service Deployment Descriptor (WSDD) "Instant release is an exciting technology, it makes the development of web services so simple; however, it is not always the best choice, such as some applications The system is provided by the third party. We don't buy source code, only .class files, but we hope to release some of this application system into a web service, enable it to create a role in a larger range, this time is released Technology is powerful. In addition, instant issues are not flexible, and more service configuration cannot be made, which makes it unable to meet the needs of some specific systems. "Okay to us, I don't say anything good to make custom release. Everyone will look down, naturally, there will be experience :) First give our simulation bank access Java file: Account.java package com.duckur; public class? Acid {/ ******** *********************************************************** *** / * Get an account from the random number (one-time valid) * / public static int function (int) (java.lang.math.random () * 10000); // Simulation, everyone can read from the file Take data, or remove this Fund value from the database / ********************************************* ************************* * Check the validity of the input * / public boolean checkinput (int Money) // can only take the number {IF (Money> Fund ) {RETURN FALSE;} else {return true;}}
/ ************************************************** ************ / * Deposit * / public int Deposit (int Money) {fund? = Fund Money; returnif;
/ ************************************************** ************ / * withdrawal * / public int withdraw (int money) {if (checkinput (money)) {fund = fund;}
/ ************************************************** ************ / * Get the current account value * / public int getaccount () {return fund;}} then compile, the successful Class file should be placed under Tomcat WebAppsaxWeb-InfcomDuckur the following. Hereinafter, in the WebAppsAxisWeb-InfcomDuckur directory under Tomcat, the name, entry and other information of the new deploy.wsdd file description service:
The display of the WSDD file has a problem download. Which is the name of the service name is Account, Java: RPC indicates a Java RPC service, and the class for this processing is org.apache.axis.Providers.java.rpcProvider. "We are through one
The label tells the RPC service to call the class, and another
The label tells the engine that can call any public method in this class. You can also specify that those methods can be called by using the namespace or some method you can call. "Of course, you can also use AXIS for a client management tool -AdminClient to complete the custom release of the service. Not saying :) Then on DOS to this directory, java org.apache.axis.client.adminClient deploy.wsdd If there is: Processing File Deploy.wsdd
DoneProcessing
This indicates that the Capacity service custom release is completed. Ok, now you can view the WSDL described by http: // localhost: 8080 / axis / service / account? WSDL. Web Service is released now. This is called now. Here is the class and method you need to use by one of the most basic calls: (Remove the current amount) ... // Newly built a service object service service = new service (); ?? / / Call the CREATECALL () method of the service object Returns a command call call = (call) service.createcall () ;?
?
// sets the address of the target service endpoint.
Call.SettargetendPointAddress (New Java.Net.URL ("http: // localhost: 8080 / axis / service / lxaccount");
//? Sets the name of the operation to be invoked using this call instances. INVOKED. - THIS CALL INSTANCE
Call.SetoperationName ("getaccount"); // convenience method to invoke a // method with a default (empty) namespace integer myfund = (integer) Call.Invoke (new object [] {}; ... detailed function can Refer to the development of the API in DOCS in the downloaded Axis.zip. The following is a detailed code: You can execute after compiling. Lxclient.java import javax.swing. *; Import java.awt. *; Import java.awt.event. *;