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