`
西门吹牛
  • 浏览: 227230 次
  • 性别: Icon_minigender_1
  • 来自: 天津
社区版块
存档分类
最新评论

Web Service:Apache CXF 测试demo

    博客分类:
  • java
阅读更多
web.xml配置
	<servlet>
		 <servlet-name>CXFServlet</servlet-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>/wbs/*</url-pattern>
   </servlet-mapping>

测试类接口


import javax.jws.WebService;


@WebService
public interface HelloWorld {
	
	public String sayHello(String name);
	//cxf好像只支持string
	//public List<Date> getDate(Map<String, String> map);

}


测试类接口实现类
import javax.jws.WebService;

import org.symbol.web.service.def.HelloWorld;
//http://localhost:8080/cas/wbs/HelloWord?wsdl
@WebService(endpointInterface="org.symbol.web.service.def.HelloWorld")
public class HelloWorldImpl implements HelloWorld{

	public String sayHello(String name) {
		return "hello!"+name;
	}


}


spring xml
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:jaxws="http://cxf.apache.org/jaxws"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
        http://cxf.apache.org/jaxws 
        http://cxf.apache.org/schemas/jaxws.xsd">
     <!-- Import Apache CXF Bean Definition -->
    <import resource="classpath:META-INF/cxf/cxf.xml"/>
    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
    <!-- ************************************************************************************ -->
	<!-- ******************			web Service配置	       ************************ -->
	<!-- ************************************************************************************ -->
     <!-- service -->
     <jaxws:endpoint id="hellworld" 
     	 address="/HelloWord" 
     	 implementor="com.xxoo.web.service.impl.HelloWorldImpl"
     	 > 
     </jaxws:endpoint>

</beans>

通过http://localhost:8080/${webappName}/wbs/HelloWord?wsdl查看wsdl

通过附件里的批处理文件生成客户端java类,该工具来自http://www.iteye.com/topic/746819
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics