Using Jax-rs for Web service Interface development

Source: Internet
Author: User
Tags wsdl

One, server-side

1. Create a Web project with the project name Ws_server

2. Create the package and create the Testservice class under the package:

 Package Com.test.webservice;  Public class Testservice {    publicstaticfinal String TITLE = "This message is returned by the WebService server side:";          Public string Test (String msg) {        return TITLE + msg;}    }

3, the Testservice.java class into the server side:

(1) Class name-right-click-web service-web Service

(2) Click Next

  

(3) Click Next, select the class that you want to be the server side, and then click the Finish button when you are finished.

  

(4) can be found under the package more than one Testservicedelegate.java class; Web-inf a sun-jaxws.xml file.

(5) Add the jar package and allow Tomcat. When you're done, type: HTTP://LOCALHOST:8080/WS_SERVER/TESTSERVICEPORT?WSDL in the browser's address bar, and the results are as follows:

Second, the client

(1) Create a Web project with the project name: ws_client

(2) Create a new Web Service client, such as the server side, you can use the following shortcut button

(3) Enter the server-side WSDL address: Click Next and the client's file will be generated.

(4) Create Testclient.java

  

 Package Com.test.webservice;  Public class testclient {    publicstaticvoid  main (string[] args) {        new  Testserviceservice (). Gettestserviceport ();         // call the server-side test method        SYSTEM.OUT.PRINTLN ("------&&&&& Witness Results &&&&&&------");        SYSTEM.OUT.PRINTLN (result);}    }

(5) Add the project to Tomcat, start the server, and execute the client's testclient with the following results:

Using Jax-rs for Web service Interface development

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.