Today, when doing projects, we need to use axis to integrate the SSH framework to create webservice, research for a day, encounter many problems and errors, write down the process and the problems encountered therein.
1. To deploy Axis2. Deployment Axis2 is very simple, copy Axis2.war to the Tomcat\webapps directory, restart Tomcat, and then open the Tomcat directory, you will find in WebApps more than one AXIS2 project name, This is the WebService service project we are going to release.
After the reboot the effect is as shown in the figure:
2. All the files under the axis2/web-inf/directory will be available under your own WEB project, remember to overwrite all (Axis2-web This folder contains Axis2 entire management interface, optional, but use the words, remember it is placed in and web-inf of the same directory), In fact, we are a bit like in the entire AXIS2 project to do two times development. (The first step is mainly the copy package file and Web.xml configuration file, pay attention to the web-inf, or there will be a bug).
After this step, the Web-inf effect looks like this: The test file under service is not to be ignored, as described below.
3. Pour the jar package you want into the folder under Web-inf (there may be an error that you cannot find Axisadminservle, and the workaround is: Next article, pending release)
4. Release the whole project to Tomcat, test start service There is no problem. (generally not a problem, all we're doing now is adding spring jar packs to the AXIS2 project and support for spring in the original Axis2 project Web.xml). Visit the next Http://
5. Write a webservice (is actually a normal Java class, and then invoke the service layer < Logic Layer > method).
Package com.hcj.webservice;
Import java.util.List;
Import Com.hcj.dto.User;
Import Com.hcj.service.UserService;
public class MyWebService {
//Here the UserService is defined as a logical layer of classes, used to invoke Dao's method, injected into the application with
private UserService UserService;
Public UserService Getuserservice () {return
userservice;
}
public void Setuserservice (UserService userservice) {
this.userservice = userservice;
}
Verify user name and password public
boolean check (String username) {return
userservice.isusernameexist (username);
}
Get all user Information public
list<user> Getalluser () {return
userservice.getalluser ();
}
}
6. Configure axis and WebService classes in Applicationcontext.xml
<!--Configure AXIS2 and spring's integrated-->
<bean id= "ApplicationContext"
class = " Org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder " />
<!--mywebservice UserService injection--> <bean id= "MyWebService" class= "Com.hcj.webservice.MyWebservice"
>
<property name= "UserService" ref= "UserService" ></property>
</bean>
7, under the web-inf/services/a new folder, this name can rise casually, we will do test bar, and then set up in web-inf/services/test/under Meta-inf This directory, and finally in web-inf/ services/test/meta-inf/set up the Services.xml,
The contents of the Services.xml file are:
<?xml version= "1.0" encoding= "UTF-8"?> <!--the name in this name is MyWebService for WebService--> "MyWebService" > <description>simple spring example</description><!--<beanmapping qname= "Myns:book" xmlns:myns= "Urn:bookservice" languagespecifictype= "Java:book class name"/>--><parameter " Serviceobjectsupplier "> Org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier & Lt;/parameter> <!--springbeanname for fixed, inside filling WebService class Bean ID (this is configured in application)--> <parameter " Springbeanname ">myWebService</parameter> <messageReceivers> <messagereceiver mep=" Http://ww
W.w3.org/2004/08/wsdl/in-only "class =" Org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver "/> <messagereceiver mep= "http://www.w3.org/2004/08/wsdl/in-out" class = "ORG.APACHE.AXIS2.RPC.RECEIVERS.R
Pcmessagereceiver "/> </messageReceivers> </service>
Here is the complete catalog view I added:
9. Restart Tomcat. Http://
Hope to help you.
Some of the problems of creating webservice through axis consolidation SSH Project:
WebService Client writing: http://blog.csdn.net/u011768325/article/details/45269909
Main reference: http://blog.csdn.net/xinhaoluan/article/details/3605234