JWS built-in webservice application in JDK 6

Source: Internet
Author: User

Before using the webservice features inherent in JDK 6, interfaces in the project can be used to develop webservice frameworks such as Axis2, XFire, and CXF. By obtaining relevant wsdl files, remote communication data interaction can be realized.
Axis2 works with the relevant IDE Generation Service and is released to the server. It is quite simple to generate a client to call the java class based on one of the selected wsdl engines. It feels that the jar package of the class library is complicated to use.
XFire is a powerful webservice framework that is easy to integrate with web containers and spring provides integrated support.
CXF is the transformation product of apache after acquiring XFire and has powerful functions.
After using the webservice feature of JDK 6, you are deeply aware of the ease of deployment and the real lightweight nature. This allows you to focus on the design and implementation of server-related functions.
The following is an example of the Webservice feature of JDK 6:

IDE: eclipse3.6 + javaee
After creating a java project, you can simply implement webservice by creating the following classes:

1 import javax. jws. WebService;
2 import javax. xml. ws. Endpoint;
3
4 @ WebService
5 public class HelloWorld {
6 public String sayHello (){
7 return "helloworld ";
8}
9 public static void main (String [] args ){
10 // publish a WebService
11 Endpoint. publish ("http: // localhost: 9090/HelloWorld", new HelloWorld ());
12}
13}
14
Start the main method to publish a webservice. Enter http: // localhost: 9090/HelloWorld in the browser? You can access the wsdl.
Note: HelloWorld is a common class. It only adds the annotation @ WebService to the first line of the class, and the release is in line 4th, http: // localhost: 9090/HelloWorld is the Publishing Service address, where new HelloWorld () is the service class.
In actual project development, service addresses can be extracted from hard coding, written to configuration files or databases for easy maintenance and management, and addresses can be modified from the previous service.

By apple0668

 

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.