Spring Integrated AXIS2 (minimal configuration) example

Source: Internet
Author: User
Tags wsdl

http://blog.csdn.net/xinhaoluan/article/details/3605234

Environment configuration:

spring-framework-3.2.7

axis2-1.6.2

tomcat-7.0.64

Implementation steps:

1.eclipse New Dynamic Web project, this example project is named: Ws-sample

2. Adding Lib Spring-framework and Axis2 to the project

3. Write the Test service:

Ihello.java (interface)

 Package com.lichmama.ws.demo.intf;  Public Interface Ihello {    public  string SayHello (string name);}

Helloimpl.java (Class)

 PackageCom.lichmama.ws.demo.service;ImportOrg.springframework.stereotype.Service;ImportCom.lichmama.ws.demo.intf.IHello; @Service ("HelloService") Public classHelloimplImplementsIhello {@Override Publicstring SayHello (string name) {if(Name = =NULL) || (Name = = "") ) {Name= "Anonymous"; }        return"Hello," +name; }    }

3. New spring configuration file/web-inf/applicationcontext.xml:

<?XML version= "1.0" encoding= "UTF-8"?><Beansxmlns= "Http://www.springframework.org/schema/beans"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"Xmlns:context= "Http://www.springframework.org/schema/context"xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/ Spring-beans-3.0.xsd Http://www.springframework.org/schema/context Http://www.springframework.org/schema/con Text/spring-context-3.0.xsd ">                  <Context:annotation-config/>    <Context:component-scanBase-package= "Com.lichmama.ws.demo" />        <BeanID= "ApplicationContext"class= "Org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder" />      </Beans>

4. New/web-inf/services/axis2/meta-inf/services.xml:

<?XML version= "1.0" encoding= "UTF-8"?><Servicegroup>    <Servicename= "HelloService"Scope= "Application">        <Description>Simple Spring Example</Description>        <parametername= "Serviceobjectsupplier">Org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier</parameter>        <parametername= "Springbeanname">HelloService</parameter>        <messagereceivers>            <MessagereceiverMEP= "Http://www.w3.org/2004/08/wsdl/in-only"class= "Org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"  />            <MessagereceiverMEP= "Http://www.w3.org/2004/08/wsdl/in-out"class= "Org.apache.axis2.rpc.receivers.RPCMessageReceiver"  />        </messagereceivers>    </Service></Servicegroup>

5. Configure/web-inf/web.xml:

<?XML version= "1.0" encoding= "UTF-8"?><Web-appXmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xmlns= "Http://java.sun.com/xml/ns/javaee"Xmlns:web= "Http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"ID= "webapp_id"version= "3.0">              <Display-name>Ws-sample</Display-name>    <Listener>        <Listener-class>Org.springframework.web.context.ContextLoaderListener</Listener-class>    </Listener>    <Context-param>        <Param-name>Contextconfiglocation</Param-name>        <Param-value>/web-inf/applicationcontext.xml</Param-value>    </Context-param>        <servlet>        <Servlet-name>Axisservlet</Servlet-name>        <Servlet-class>Org.apache.axis2.transport.http.AxisServlet</Servlet-class>    </servlet>        <servlet-mapping>        <Servlet-name>Axisservlet</Servlet-name>        <Url-pattern>/services/*</Url-pattern>    </servlet-mapping>   <welcome-file-list>      <Welcome-file>index.jsp</Welcome-file>      <Welcome-file>Index.html</Welcome-file>    </welcome-file-list></Web-app>

6. After completing the above work, the project directory structure is as follows:

7. Release the project and start Tomcat

8. Visit HTTP://LOCALHOST:8080/WS-SAMPLE/SERVICES/HELLOSERVICE?WSDL to see if the service was published successfully.

If the publication succeeds, the access Http://localhost:8080/ws-sample/services/HelloService/sayHello?name=lichmama results should be as follows:

9.* easy Way is to download axis2-war.zip (http://archive.apache.org/dist/axis/axis2/java/core/1.6.2/ Axis2-1.6.2-war.zip), copy the files under Web-inf to the project directory.

Then modify each configuration file according to the actual situation (Application.xml, Services.xml, Web. xml).

10.* The above example project: http://pan.baidu.com/s/1hrBsZ4o

Spring Integrated AXIS2 (minimal configuration) example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.