Use Java 6 for webservice

Source: Internet
Author: User

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

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.