"Turn" JAVA6 development WebService Advanced

Source: Internet
Author: User
Tags wsdl

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

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.