Original works, allow reprint, please be sure to use hyperlinks in the form of the original source of the article, author information and this statement. Otherwise, the legal liability will be investigated. http://lavasoft.blog.51cto.com/62575/226581
JAVA6 Development WebService AdvancedIn the above, the implementation of the simplest WebService service was made using JAVA6, and the service was released through JAVA6API. In this article, you'll see how to use Java6 to do a webservice service, and how to use the development tools provided by JAVA6 to generate client code and invoke the service.
first, the service-side code PackageLavasoft;
ImportJavax.jws.WebService;
ImportJavax.xml.ws.Endpoint;
/**
* Introduction to JAVA6 Development WebService
*
* @author leizhimin 2009-11-13 16:10:44
*/
@WebService
PublicclassJava6webservice {
/**
* Business methods in Web services
*
* @return A string
*/
PublicString dosomething () {
return"Hello Java6 webservice!";
}
PublicStaticvoidMain (string[] args) {
//Release a WebService
Endpoint.publish ("http://192.168.14.117:8080/java6ws/lavasoft. Java6webservice ", New Java6webservice ());
}
}Accessing WSDL:HTTP://192.168.14.117:8080/JAVA6WS/JAVA6WS?WSDL in the browser
ii. Generating Client codeJAVA6 provides a tool for generating WebService client code, note that you need to start the server side before you build, such as: The resulting project directory is as follows:
Third, write the test class of the client PackageLavasoft;
ImportLavasoft.wsclient.Java6WS;
ImportLavasoft.wsclient.Java6WSService;
/**
* Test JAVA6 WS-Generated client code
*
* @author leizhimin 2009-11-16 10:40:07
*/
Publicclasstestclient {
PublicStaticvoidMain (string[] args) {
//Create a Client service object
Java6ws Java6ws =NewJava6wsservice (). Getjava6wsport ();
//Call the service method and get the method return value
String returncontent = java6ws.dosomething ("Zhangsan");
//The return value of the print service
System.out.println (returncontent);
}
Note that the classes imported above are all under the Lavasoft.wsclient package. Run the test class: The service method is called correctly and the test succeeds. JAVA6 WebService Development So convenient, we also need Axis2, XFire, cxf? Stay tuned for further articles!
This article is from the lava blog, so be sure to keep this source http://lavasoft.blog.51cto.com/62575/226581
"Turn" JAVA6 development WebService Advanced