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:
- WebService annotations
This annotation declares this class as a web Service
- 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