接口:
package com.sss.crm.business.service.impl;
import javax.jws.WebService; @WebService public interface HelloService { public String sayhello(String name); }实现:
package com.sss.crm.business.service.impl; import javax.jws.WebMethod; import javax.jws.WebService; import org.springframework.stereotype.Component; @Component("helloService") @WebService(endpointInterface="com.sss.crm.business.service.impl.HelloService") public class HelloServiceImpl implements HelloService{ @WebMethod public String sayhello(String name) { return "Hello " + name + " !"; } } </span>spring 配置:
<bean xsi:schemalocation="http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd" xmlns:jaxws="http://cxf.apache.org/jaxws"> <import resource="classpath:meta-inf/cxf/cxf.xml"/> <import resource="classpath:meta-inf/cxf/cxf-servlet.xml"/> <!--#helloService 也可以是完整的包名类名实现 如com.sss.crm.business.service.impl.HelloServiceImpl--> <jaxws:endpoint id="helloWorld" implementor="#helloService" address="/HelloWorld"/>
web.xml 配置:
<!-- cxf --> <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>/*</url-pattern> </servlet-mapping>
生成客户端后测试: public class test { public static void main(String[] args) { javax.xml.ws.Service sss=new HelloServiceImplService(); HelloService service=((HelloServiceImplService) sss).getHelloServiceImplPort(); String str=service.sayhello("Tom"); System.out.println(str); } }
jar包下载
http://mirror.bit.edu.cn/apache/cxf/3.0.4/apache-cxf-3.0.4.zip
报错
Could not load Webservice SEI
这个错误的原音是,在实现类的endpointInterface的路径写错了
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。