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