Develop a simple web Service under Eclipse

Source: Internet
Author: User
Tags wsdl

Service section

Create a new Dynamic Web project under Eclipse

Create a new service class in the project

Writing code for the SayHello class

 PackageOrg.sunny.service;//don't quote the wrong bag.ImportJavax.jws.WebService;ImportJavax.xml.ws.Endpoint;//Annotations@WebService no less .@WebService Public classSayHello {//The method is called by the client, and the method name is arbitrary     Publicstring Say (string name) {return"Hello" + name + ", this is Sayhelloservice!" ; }     Public Static voidMain (string[] args) {//The first parameter is the url,9091 that is accessed when any one of the ports is not occupiedEndpoint.publish ("Http://localhost:9091/Service/SayHello",NewSayHello ()); System.out.println ("Service Success!"); }}

To test: Right-click on any of the blanks

Or

The main method in the class is called after it is run

The following configuration of the results of the operation indicates a successful publication

To load a project into Tomcat

Start Tomcat

Visit webpage: http://localhost:9091/Service/SayHello?wsdl

Note: '? wsdl ' is required to be added.

The following page appears to indicate a successful publication

Client part to be updated tomorrow

Develop a simple web Service under Eclipse

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.