Implement , publish, and Invoke Webservice services in the Eclipse development platform using the AIXS2 framework .
"Experimental Environment":
1, MyEclipse10
2. Tomcat 7..0
3, Axis2
Download Axis , http://download.csdn.net/detail/u011731233/8743263 Put the downloaded War pack into the tomcat webapps directory and launch Tomcat service, enter in the browser address bar http://localhost:8080/axis2/ Verify that axis is installed properly
Create a new Web service file
Package Com;public class Hello {public String hw () {return "Hello,world";}}
To create a services.xml file
<service name= "Hello" > <description> HelloWorld Example Description </description> <parameter Name= "ServiceClass" locked= "false" > com. Hello </parameter> <operation name= "HW" > <messagereceiver class= "Org.apache.axis2.rpc.receivers.RPCM Essagereceiver "></messageReceiver> </operation></service>
(select the project you want to package, right-click the export---->java----->java File----->next----->exported All output folders for Checked Project----->export destination The location of the input jar package and the file name---->finish)
New client Invoke Web service file
package com; Import Java.util.iterator;import Org.apache.axiom.om.omelement;import Org.apache.axis2.addressing.endpointreference;import Org.apache.axis2.client.options;import Org.apache.axis2.rpc.client.rpcserviceclient;public class Client {public static void main (string[] args) throws Exception {rpcserviceclient rpcclient = new Rpcserviceclient (); options opt = new options (); Opt.setto (new EndpointReference ("Http://localhost:8080/axis2/services/Hello")); Opt.setaction ("URN:HW"); Rpcclient.setoptions ( opt); omelement element = rpcclient.invokeblocking (new Javax.xml.namespace.QName ("http://com", "HW"), new object[] { null}); Iterator values = Element.getchildrenwithname (New Javax.xml.namespace.QName ("http://com", "return"); while ( Values.hasnext ()) {omelement omelement = (omelement) values.next (); System.out.println (Omelement.gettext ());}}}
Axis of Web Services