日期:2014-05-20 浏览次数:20621 次
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <servlet> <servlet-name>CXFServlet</servlet-name> <display-name>CXF Servlet</display-name> <servlet-class> org.apache.cxf.transport.servlet.CXFServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>CXFServlet</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> </web-app>
package com.pal.service.api; import javax.jws.WebService; @WebService public interface SayHello { public String hello(); }
package com.pal.service.impl; import javax.jws.WebService; import com.pal.service.api.SayHello; @WebService(endpointInterface="com.pal.service.api.SayHello",serviceName="SayHello") public class SayHelloImpl implements SayHello { public String hello() { return "hello , Web Service !"; } }
package com.pal.service.app; import javax.xml.ws.Endpoint; import com.pal.service.impl.SayHelloImpl; public class WebApp { public static void main(String[] args) { System.out.println("Starting Server"); SayHelloImpl implementor = new SayHelloImpl(); String address = "http://localhost:8080/helloWorld"; Endpoint.publish(address, implementor); } }