???: Setting the server's publish address to be http://localhost:9000/cxfdemo
2012-12-12 11:29:04 org.eclipse.jetty.util.log.Slf4jLog info ???: jetty-7.4.2.v20110526
2012-12-12 11:29:04 org.eclipse.jetty.util.log.Slf4jLog info ???: Started SelectChannelConnector@localhost:9000 STARTING 2012-12-12 11:29:04 org.eclipse.jetty.util.log.Slf4jLog info ???: started o.e.j.s.h.ContextHandler{,null} Start success
2012-12-12 11:29:04
org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
???: Creating Service {http://cxfdemo/}CXFDemoService from class cxfdemo.CXFDemo
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.076 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 ... ...
4 在webapp中发布
CXF提供了spring的集成,同时还提供了org.apache.cxf.transport.servlet.CXFServlet用于在web容器中发布WebService。 前面的例子中增加了整个apache-cxf的依赖,所以会自动增加对srping的引用。只需要写beans配置文件和web.xml文件即可。
?
在web.xml中配置CXFServlet
?
在web.xml中增加spring的ContextLoaderListener并配置context-param
?
beans配置文件内容如下
cxfdemo-beans.xml
xsi:schemaLocation=\http://cxf.apache.org/schemas/jaxws.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd\ >
如此,WebService就已经在web容器中发布了。启动web应用:
$mvn jetty:run
就可以在浏览器中看到已经发布的WebService,如下图:
相关推荐: