First, write the Java file of WebService
Create a new Java project in Eclipse, and then create a new Java class, which I name here: Manageruserservice.java, source code:
PackageCom.hoo.service;Importjava.util.ArrayList;ImportJava.util.HashMap;Importjava.util.List;ImportJava.util.Map;ImportJava.util.Random;ImportCom.hoo.entity.User; Public classManageruserservice { Publicuser edituser (user user) {User.setid (NewRandom (). Nextint (100)); returnuser; } PublicList<user> Getusers (intj) {List<User> users =NewArraylist<user>(); for(inti = 0; I < J; i++) {User User=NewUser (); User.setaddress ("China"); User.setemail ("[Email protected]"); User.setname ("Hoojo"); User.setid (22 +i); Users.add (user); } returnusers; } PublicMap<string, User> Getuser4map (intj) {Map<string, user> users =NewHashmap<string, user>(); for(inti = 0; I < J; i++) {User User=NewUser (); User.setaddress ("China"); User.setemail ("[Email protected]"); User.setname ("Amy"); User.setid (22 +i); Users.put ("user#" +i, user); } returnusers; } PublicUser[] Getuser4array (intj) {user[] users=NewUser[j]; for(inti = 0; I < J; i++) {User User=NewUser (); User.setaddress ("China"); User.setemail ("[Email protected]"); User.setname ("Tom"); User.setid (22 +i); Users[i]=user; } returnusers; }}
Click on the project folder right-->new->other:
Select Axis2 Service archiver, click Next
Then click Browser to select your current project's classes directory, typically the Eclipse workspace\ project name \ Bin, which can only be selected at this level
Click Next
Without WSDL, select the first item, click Next, and then next
Without setting service.xml, direct next
6, the most critical step, fill in the name of the webservice, enter the class path, generally the package name + class name, click Load you can see the current class method
Select the method to be published as WebService, next
Set the name of the Aar file and keep the directory
Click Finish, you can see the prompt successfully, indicating that the package was successful.
8. You can see the Manangeruserservice.aar file in the output path.
Below we access this address in the browser: http://localhost:8080/axis2/
Click Admin this link, you can see to enter the user name and password, user name and password in
Tomcat_home\webapps\axis2\web-inf\conf under the axis2.xml can be found in
<parameter name= "UserName" >admin</parameter>
<parameter name= "Password" >axis2</parameter>
Enter the password to enter the administration page to see
Below is a description of the functions commonly used above
Upload service is, of course, uploading AAR files.
Available Service is to view the currently available service details
Available service groups is a service group
Global chains is a globally available chain
Operation specific chains is a specific operation of the chain
Deactivate Service is canceling a service
Activate Service is resending service
Edit parameters is a parameter that modifies the WebService class
We use the Upload service tool here, and then choose the one we just used to generate the Aar file with the Axis2 tool.
In fact this step we can copy the Manageruserservice.aar file directly to
Tomcat-home\webapps\axis2\web-inf\services under this directory.
Then click on the available service to see the Manageruserservice service.
This WebService access method and the 0 configuration release WebService are the same effect