没看过那个例子的朋友,这里把例子写出来
HelloWorld.java
package demo.hw.server;
import javax.jws.WebService;
@WebService
public interface HelloWorld {
String sayHi(String text);
}HelloWorldImpl.java
package demo.hw.server;
import javax.jws.WebService;
@WebService(endpointInterface = "demo.hw.server.HelloWorld", serviceName = "HelloWorld")
public class HelloWorldImpl implements HelloWorld { public String sayHi(String text) {
return "Hello " + text;
}
}Server.java
package demo.hw.server;import javax.xml.ws.Endpoint;public class Server { protected Server() throws Exception {
// START SNIPPET: publish
HelloWorldImpl implementor = new HelloWorldImpl();
String address = "http://localhost:8080/helloWorld";
Endpoint.publish(address, implementor);
// END SNIPPET: publish
}
}
部署后会自动生成web.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>cxf</display-name>
<description>cxf</description>
<servlet>
<servlet-name>cxf</servlet-name>
<display-name>cxf</display-name>
<description>Apache CXF Endpoint</description>
<servlet-class>
org.apache.cxf.transport.servlet.CXFServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cxf</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
</web-app>最后在浏览器中输入URL,提示No service was found.但不报错
HelloWorld.java
package demo.hw.server;
import javax.jws.WebService;
@WebService
public interface HelloWorld {
String sayHi(String text);
}HelloWorldImpl.java
package demo.hw.server;
import javax.jws.WebService;
@WebService(endpointInterface = "demo.hw.server.HelloWorld", serviceName = "HelloWorld")
public class HelloWorldImpl implements HelloWorld { public String sayHi(String text) {
return "Hello " + text;
}
}Server.java
package demo.hw.server;import javax.xml.ws.Endpoint;public class Server { protected Server() throws Exception {
// START SNIPPET: publish
HelloWorldImpl implementor = new HelloWorldImpl();
String address = "http://localhost:8080/helloWorld";
Endpoint.publish(address, implementor);
// END SNIPPET: publish
}
}
部署后会自动生成web.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>cxf</display-name>
<description>cxf</description>
<servlet>
<servlet-name>cxf</servlet-name>
<display-name>cxf</display-name>
<description>Apache CXF Endpoint</description>
<servlet-class>
org.apache.cxf.transport.servlet.CXFServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cxf</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
</web-app>最后在浏览器中输入URL,提示No service was found.但不报错
解决方案 »
- 问一个hm.get()和it.next()的返回值问题 谢谢哈 急呀
- 请教高手STRUTS跟JSP的问题
- java.sql.SQLException: 从数据库取连接错误! DbConnectionPool is exhausted!
- 在myeclipse中开发web service
- 关于j2ee的学生管理系统问题
- 关于classpath
- 小弟初学JAVA,请教一TOMCAT配置问题?
- 有没有谁看过《java核心技术》VolumeII ?给点意见吧,我好矛盾~~~(来者有分!)
- 为什么在客户端可以调用在EJB的Remote接口和Home接口中没有定义,而在bean中有定义的方法?
- eclipse经常提示空指针异常
- resin如何获取utf-8编码的url参数
- 什么是企业级应用?
http://blog.csdn.net/irvine007/archive/2008/08/20/2801689.aspx