@WebService public interface HelloWorld { @WebMethod String sayHello(String name); } @WebService(endpointInterface = "com.example.HelloWorld") public class HelloWorldImpl implements HelloWorld { @Override public String sayHello(String name) { return "Hello, " + name + "!"; } } public class HelloWorldPublisher { public static void main(String[] args) { String url = "http://localhost:8080/helloworld"; Endpoint.publish(url, new HelloWorldImpl()); System.out.println("Service is published at " + url); } } <?xml version="1.0" encoding="UTF-8"?> <endpoint xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" implementation="com.sun.xml.ws.transport.http.server.EndpointImpl" wsdl="WEB-INF/wsdl/HelloWorld.wsdl" url-pattern="/helloworld"/>


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