刚起步时实际上服务端是最简单的。
一、加入cxf支持
简单的说就是创建一个web项目,并将cxf的发布包和相关依赖包放到web工程的lib目录下。我选择的cxf版本是2.2.5
二、创建webservice服务接口和实现类
1、创建服务接口,全例如:
package cn.ibeans.cxf.server;
import javax.jws.WebService;
@WebService
public interface HelloWorld {
String sayHello(String msg);
}
2、创建web服务接口的实现类
package cn.ibeans.cxf.server;
import javax.jws.WebService;
@WebService(endpointInterface="cn.ibeans.cxf.server.HelloWorld")
public class HelloWorldImpl implements HelloWorld {
public String sayHello(String msg) {
System.out.println("客户端的传值为: "+msg);
return "你好! "+msg;
}
}
三、配置spring,对外发布web serive
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<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" />
<jaxws:endpoint id="helloWorld" implementor="cn.ibeans.cxf.server.HelloWorldImpl" address="/HelloWorld"/>
</beans>
四、配置web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/classes/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<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>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
五、发布应用及服务
即将web项目发布到tomcat之类的web应用服务器中。运行即可。
要想知道我们的web服务是否成功发布,可以访问以下地址:
http://localhost:8080/appname/HelloWorld?wsdl
如果能成功展现xml形式的描述文件(如下图),则发布成功。反之,没有成功。
- 大小: 4.3 KB
分享到:
相关推荐
NULL 博文链接:https://ll-feng.iteye.com/blog/558518
使用cxf+spring框架开发webservice的客户端与服务端代码,用于连接两个项目
CXF学习笔记.docx ) CXF学习笔记.docx ) CXF学习笔记.docx ) CXF学习笔记.docx ) CXF学习笔记.docx ) CXF学习笔记.docx ) CXF学习笔记.docx )
很简洁的一个Cxf+webservice(客服端和服务端)接口
webserivce.、cxf整合spring,用的是spring3和cxf3。欢迎大家下载尝试
Apache cxf 学习笔记.pdfApache cxf 学习笔记.pdf
cxf开发webservice简单实例:包括服务端与客户端并所有需要的jar,不要分啦。
WebService+Spring客户端和服务端程序,实现了多数据源动态切换 测试的麻油们,依次打开客户端和服务端的main方法就可以测试了
CXF源码:CXF_Spring源码 CXF源码:CXF_Spring源码
CXF例子 创建服务端、客户端、相关xml的配置和环境jar说明
cxf 与 Spring 结合,此例子中包含服务端和客户端, 2个工程都是与SSH 结合使用。相信对刚接触的朋友有用!
完整整合spring4、cxf3和maven3的服务端和客户端项目。
绝对可运行,里面有客户端和服务端还有对应的操作文档,导入eclipse或者MyEclipse十分钟内就搞定,虽然贵点但是绝对物有所值.
cxf客户端调用axis服务端流程
CXF+spring+struts实现WebService
Apache cxf 学习笔记,供大家参考
CXF结合spring项目实例,com.email.ws.impl包下为eclipse工具生成的客户端,text包用来测试
具体再解释一下,服务端需要 接口类,实现类,cxf 服务端xml,和一个pojo 客户端也需要接口类文件和pojo,和cxf客户端xml 但是没有接口的实现类,就是为了去服务端来调用的。 具体有不懂可以问我 给我发消息, 劳烦...
cxf服务端wsdl发布帮助.docxcxf服务端wsdl发布帮助.docx