A probe into Web service

Source: Internet
Author: User

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.


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

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.