Overview: Web Service is a platform-independent, low-coupling, self-contained, programmable WEB-based application that describes, publishes, discovers, coordinates, and configures these applications using Open XML (a subset of standard common markup language) standards. Used to develop distributed, interoperable applications. WEB Service technology enables different applications running on different machines to exchange data or integrate with each other without the use of additional, specialized third-party software or hardware. WEB Service provides a common mechanism for integration of business processes across the enterprise or even across multiple organizations. A Web service is an application that exposes an API that can be invoked through the web and is a simple, interoperable messaging framework.
Eclipse establishes a Web service process:
First step: Create a new Java project project named WebService01, and then set up a package named Com.webservice.demo, a new class in the package named Demo01.java
Step Two: Right-click on the project webservice01,new-->others, select Web Service inside Web services, click Next, and watch the circled section.
Attention:
Step three: Next-->next-->start server then all the way Next until the following scenario appears in Finish,eclipse:
Fourth step: Copy the path to the browser, select the Sayhi () method, write any content in the input box, click Invoke after the result area will have the corresponding output, as follows:
The following shows the client's call to DEMO01:
The first step: Add Axis2 Package, a new class named: Demo01service.java, as follows:
PackageCom.webservice.demo;ImportJavax.xml.namespace.QName;ImportOrg.apache.axis2.AxisFault;Importorg.apache.axis2.client.Options;Importorg.apache.axis2.rpc.client.RPCServiceClient; Public classDemo01service { Public Static voidMain (string[] args)throwsAxisfault {rpcserviceclient serviceclient=Newrpcserviceclient (); Options Options=serviceclient.getoptions (); Org.apache.axis2.addressing.EndpointReference Targetepr=NewOrg.apache.axis2.addressing.EndpointReference ("Http://localhost:8081/ws01/services/demo01"); Options.setto (TARGETEPR); QName Sayhientry=NewQName ("http://demo.webservice.com", "Sayhi"); Object[] Sayhientryargs=Newobject[]{"My"}; Class[] Classes=NewClass[]{string.class}; System.out.println (Serviceclient.invokeblocking (Sayhientry, sayhientryargs,classes) [0]); }}
Where the value of Endpointreference,qname is related to the path that the JSP project saved when start server, especially with the Servicelocator file:
When you're finished, right-click Demo01service-->run As-->java Application console appears: Hello my
A probe into Web service