@WebService public class HelloWorldService { @WebMethod public String sayHello(String name) { return "Hello, " + name + "!"; } } public class HelloWorldPublisher { public static void main(String[] args) { Endpoint.publish("http://localhost:8080/hello", new HelloWorldService()); } } public class HelloWorldClient { public static void main(String[] args) { URL wsdlURL = new URL("http://localhost:8080/hello?wsdl"); QName serviceName = new QName("http://example.com/", "HelloWorldService"); Service service = Service.create(wsdlURL, serviceName); HelloWorldService port = service.getPort(HelloWorldService.class); String response = port.sayHello("John"); System.out.println(response); } }


上一篇:
下一篇:
切换中文