WebService create a service yourself or call a third-party webservice service

Source: Internet
Author: User

One, create your own webservice service

First create a project with the following directory structure

Helloservice.java files are as follows

Package Com.joydo.cn;import Javax.jws.webservice;import Javax.xml.ws.Endpoint, @WebServicepublic class HelloService {    public string GetValue (string name) {return "My name is" +NAME; } public static void Main (string[] args) {endpoint.publish ("Http://127.0.0.1:9089/Service/HelloService", New Helloserv Ice ()); System.out.println ("Publish Success");}}

Then enter HTTP://127.0.0.1:9089/SERVICE/HELLOSERVICE?WSDL in the address bar

If the following occurs, the publication succeeds:

Create a new client, and then at the command prompt, enter:

1: the client src directory; 2: The package directory where the files generated by the webservice will be stored; 3 The WebService path just released

Next, refresh the client, and you can see the directory structure as follows:

Test.java is the test class I created, with the following code:

Package Com.hyan.client;public class Test {public static void main (string[] args) {HelloService helloservice=new Hello  Serviceservice (). Gethelloserviceport ();  String Aa=helloservice.getvalue ("Zhang San"); SYSTEM.OUT.PRINTLN (AA);}}

This succeeds in invoking the


Two. Call the external WebService

The theory is that someone else has posted it directly, so the process executes directly from the Command Prompt window.

WebService's website: http://www.webxml.com.cn/zh_cn/web_services.aspx


WebService create a service yourself or call a third-party webservice service

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.