The simplest web service implementation

Source: Internet
Author: User
Tags wsdl

Overview Here is an implementation of the simplest Web service, based on Jax-ws. In addition to the JDK does not require any other jar packages, using the eclipse-provided Web Services ExplorerAccess the service. Implementation of the service side
 PackageCn.ljl.sand.jws.chapter0.service;ImportJavax.jws.WebService;Importjavax.xml.ws.Endpoint; @WebService Public classHelloService { Publicstring Hello (string name) {return"Hello," +name; }         Public Static voidMain (string[] args) {String address= "Http://localhost:6666/service/hello"; Endpoint.publish (Address,NewHelloService ()); }}

There are two types of places to note:

    1. WebService annotations
      This annotation declares this class as a web Service
    2. Main method
      Publish a service using Endpoint's Publish method
Access through the tools of eclipse Eclipse has embedded Web Services Explorertool that can be used as a client to access the services we have posted above. 1. Set up a Web browser in eclipse Web Services ExplorerYou need to use a browser to open it, you can use an eclipse-embedded browser, or a different external browser. I used the Google Browser, and later found that I could not see the SOAP message, and switched to IE browser. 2. Open the tool run-launch the Web Services Explorer3. Request service The address of the WSDL here is the address we posted on the server, plus ?wsdl



From for notes (Wiz)



The simplest web service implementation

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.