As a webservice, you may immediately think of frameworks such as axis and xfire. You may not know that Java 6 has a built-in webservice server. How many lines can you get a webservice?
The Code is as follows:
Package com. geostar. geoglobe. jaxws;
Import javax. jws. WebMethod;
Import javax. jws. WebParam;
Import javax. jws. WebResult;
Import javax. jws. WebService;
Import javax. jws. soap. SOAPBinding;
Import javax. jws. soap. SOAPBinding. ParameterStyle;
Import javax. xml. ws. Endpoint;
@ SOAPBinding (parameterStyle = ParameterStyle. BARE)
@ WebService (serviceName = "GeoGlobeServer", targetNamespace = "http://www.geostar.com.cn ")
Public class WSDemo {
@ WebMethod
@ WebResult (name = "doSomethingResponse ")
Public String doSomething (@ WebParam (name = "input") String input ){
Return "hello:" + input;
};
Public static void main (String [] args ){
Endpoint. publish ("http: // 126.33.8.183: 9999/GeoGlobeServer", new WSDemo ());
};
}
The code is so simple, Run!
In the browser, enter http: // 126.33.8.183: 9999/GeoGlobeServer? Enter the wsdl key.
OK is not amazing.
Reprinted please indicate the source: http://www.cnblogs.com/likehua