1. First install the axis2 plug-in myeclipse, Which is troublesome and in various situations.
Reference: http://blog.csdn.net/seven_zhao/article/details/6089747
2. axis2.jar package download address: http://axis.apache.org/axis2/java/core/download.cgi, my version is1.5.6
3. Generate yourprojectname for the server project
Reference: http://www.lifeba.org/arch/java_axis2_webservice.html use Part 3: Methods in standalone deployment.
Copy three axis2 related folders and web. xml under Web-info, and modify the service name yourservicename and method name yourmethod in services. xml.
For example, testws:
Package ws; public class testws {Public String showname (string name) {return name;} Public String getname () {return "Hello, axis2, by getname method .";}}
Services. XML is configured as follows:
<Service name = "axisservice"> <description> axisservice </description> <parameter name = "serviceclass"> ws. testws </parameter> <operation name = "showname"> <messagereceiverclass = "org. apache. axis2.rpc. receivers. rpcmessagereceiver "/> </Operation> <operation name =" getname "> <messagereceiverclass =" org. apache. axis2.rpc. receivers. rpcmessagereceiver "/> </Operation> </service>
Project name: axis2service
Deploy it in Tomcat to verify whether the service is normal:
Http: // localhost: 81/yourprojectname/services/yourservicename? WSDL
Http: // localhost: 81/axis2service/services/axisservice? WSDL
4. Generate a client for testingProgram
Use the installed axis2 plug-in "axis2 code generator" to generateCodeTo the specified project.
Test class:
Package test; import ws. axisservicestub; public class clienttest {public static void main (string [] ARGs) throws exception {axisservicestub stub = new axisservicestub (); axisservicestub. showname command = new axisservicestub. showname (); command. setname ("Hello, axis2, by showname method. "); string shownamertn = stub. showname (command ). get_return (); system. out. println (shownamertn); string getnamertn = stub. getname (). get_return (); system. out. println (getnamertn );}}
Output:
Hello, axis2, by showname method.
Hello, axis2, by getname method.