Detailed graph Description: Java-based WebService Programming

Source: Internet
Author: User

Yesterday, I sorted out the basic concepts related to Web services. As a result of that blog, this article will explain how to write WebService server programs and how to call self-compiled services.

Step 1, create a WebService project, select the JAX-WS [Note: this example uses IDE for myeclipse]

Step 2: create a service class

Package COM. xjtu. webService;/***** <p> * Title: Test code/P> *** <p> * description: example business class * </P> ** <p> * copyright: Copyright (c) 2012 * </P> ** @ author DML @ 2012-12-11 * @ version 1.0 */public class mobilenuminfo {Public String getmobilenum () {return "13888888888 ";}}

Step 3: Release the web service. Select the project you just created, and choose create Web service from Java class from strategy.

Step 4: generate the WSDL

Step 5, add the library file [JAX-WS *]

Step 6: start Tomcat

Step 7: Open your browser and enter the address http: // 127.0.0.1: 8080/mobilenumservice/mobilenuminfoport? WSDL

The following page is displayed, indicating that the service has been released successfully.

Step 8: Create a client test project and select Java project.

Step 9: generate the library file required by WS

Generate files such:

Step 10: Compile the test program and view the execution result

Package COM. xjtu. webService. test; import COM. xjtu. webService. mobilenuminfodelegate; import COM. xjtu. webService. mobilenuminfoservice;/***** <p> * Title: Test code/P> ** <p> * description: example business class * </P> ** <p> * copyright: Copyright (c) 2012 * </P> ** @ author DML @ 2012-12-11 * @ version 1.0 */public class mobilenumtest {public static void main (string [] ARGs) {mobilenuminfoservice mnis = new mobilenuminfoservice (); mobilenuminfodelegate mnid = mnis. getmobilenuminfoport (); system. out. println (mnid. getmobilenum ());}}

Execution result:

13888888888

Next, you can refer to the source code for detailed explanation of Java WebService program.

P.s. The process is actually not difficult, and you can master it by yourself.

Pp. S. The temperature drops sharply. You should pay more attention to adding clothes to keep warm ~~ As long as you do not get sick, it is happiness.

PPP. s. in this world, "the only thing that is unstoppable is time. It is like a blade, silently cutting everything hard and soft and moving forward steadily, nothing can make its progress bumpy, but it changes everything."

Dml@2012.12.11

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.