Recently in the research integration Spring Framework and AXIS2 release WebService service, because I also learned Java soon, in order to facilitate later viewing, here to record the release process.
The required toolkit, Spring.jar and Axis2 link address is Http://pan.baidu.com/s/1gdgVBoB, where the release service only requires two packages, Spring-framework-3.2.1.release-dist.zip and Axis2-1.6.2-war.zip. First unzip the Axis2-1.6.2-war.zip, get the Axis2.war file, put in the Tomcat WebApps directory, start Tomcat, enter HTTP://IP in the browser: port number/axis2/appears
Description Axis2 run successfully, a directory called Axis2 is generated in the WebApps. Then create a new Web project in MyEclipse, here I named Wjwebservice, project directory structure
Unzip the two packages above, put all of the jar packages into the Webroot/web-inf/lib directory, create a new conf and modules directory under the Web-inf directory, and the Tomcat webapps/axis2/ The files in the Conf and modules directories under Web-inf are poured into the new conf and modules in the Web project respectively. New services Directory, new test (this directory name can be picked up) directory, new Meta-inf directory, new Services.xml.
To create a new HelloWorld interface in Com.wj.service, the code is:
Package Com.wj.service; Public Interface HelloWorld { public string Greeting (string name); Public void print ();}
In Com.wj.service, the new Helloworldimpl class implements the HelloWorld interface with the code:
Package Com.wj.service; Public class Implements helloworld{ public string Greeting (string name) { return name+ "Hello" world! " ; } Public void print () { System.out.println ("hi!" ); }}
In Com.wj.service, create a new WebService JavaBean object HelloWorldService class with the following code:
PackageCom.wj.service; Public classHelloWorldService { PublicHelloWorld HelloWorld; PublicHelloWorld Gethelloworld () {returnHelloWorld; } Public voidSethelloworld (HelloWorld HelloWorld) { This. HelloWorld =HelloWorld; } Publicstring saygreeting (string name) {returnhelloworld.greeting (name); } Public voidSayprint () {helloworld.print (); }}
To configure Spring Applicationcontext.xml:
<?xml version= "1.0" encoding= "UTF-8"? ><beans xmlns= "Http://www.springframework.org/schema/beans"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"XMLNS:AOP= "HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP"Xmlns:tx= "Http://www.springframework.org/schema/tx"xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http//WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOPhttp://www.springframework.org/schema/aop/spring-aop-2.0.xsdhttp//Www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-2.0.xsd"><bean id= "ApplicationContext"class= "Org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder"/> <bean id= "Helloworldimpl"class= "Com.wj.service.HelloWorldImpl" > </bean> <bean id= "HelloWorldService"class= "Com.wj.service.HelloWorldService" > <property name= "HelloWorld" ref= "Helloworldimpl" ></property> </bean></beans>
Configure Web. XML:
<?xml version= "1.0" encoding= "UTF-8"? ><web-app version= "2.5"xmlns= "Http://java.sun.com/xml/ns/javaee"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd "><!--register Axis2 servlet--<servlet> <servlet-name>AxisServlet</servlet-name> <servlet-class>org.apache.axis2.transport.http.axisservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>AxisServlet</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping> <!--load Spring configuration Files--<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationcontext.xml& Lt;/param-value> </context-param> <!--add Spring Listener--<listener> <listene R-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> < Welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list></web-app >
Configuration services.xml:
<?xml version= "1.0" encoding= "UTF-8"? ><service name= "Helloworldwebservice" targetnamespace= "http// www.wujianjun.org "> <description>simple spring example</description> <parameter name=" Ser Viceobjectsupplier "> Org.apache.axis2.extensions.spring.receivers.SpringAppCo Ntextawareobjectsupplier </parameter> <parameter name= "Springbeanname" >helloworldservic e</parameter> <messageReceivers> <messagereceiver mep= "http://www.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.RPCMessageReceiver"/> </messagereceivers></service
Browser input: Http://IP: Port/Project name/services/services.xml the configured service name? WSDL generates WSDL file
To this WebService Service release is complete.
Spring and Axis2 Consolidated release WebService