cxf 简单例子学习

最少需要的jar:
cxf-2.3.3.jar
geronimo-annotation_1.0_spec-1.1.1.jar
geronimo-jaxws_2.2_spec-1.0.jar
geronimo-stax-api_1.0_spec-1.0.1.jar
geronimo-ws-metadata_2.0_spec-1.1.3.jar
jaxb-api-2.2.1.jar
jaxb-impl-2.2.1.1.jar
neethi-2.0.4.jar
wsdl4j-1.6.2.jar
XmlSchema-1.4.7.jar
wstx-asl-3.2.9.jar
1:在web.xml 中配置
<!-- 配置CXFService框架 -->
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/services/*</url-pattern>若是struts配置为*.action
</servlet-mapping>
2:在spring的配置文件中导入spring-cxf.xml文件
<import resource="classpath:xml/spring-cxf.xml" />
3:配置spring-cxf.xml
<?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:jaxws="http://cxf.apache.org/jaxws"
xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd


http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.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" />
<http-conf:conduit name="*.http-conduit">
<http-conf:client ConnectionTimeout="3000" ReceiveTimeout="5000"/>
</http-conf:conduit>

<jaxws:server id="userServiceCxf" serviceClass="com.platform.csfservice.UserServiceCxf" address="/userservice">
<jaxws:serviceBean>
<bean class="com.platform.csfservice.impl.UserServiceCxfImpl"/>
</jaxws:serviceBean>
</jaxws:server>
</beans>
id="userServiceCxf" 唯一性,最好为每一个外放接口的管理的bean名称
如下面的例子:
接口:
@WebService
public interface UserServiceCxf extends BaseDao<User> {
@WebMethod
public User loginUser(@WebParam(name="name") String name, @WebParam(name="password") String password);
}
实现类:
@Service("userServiceCxf")
public class UserServiceCxfImpl extends BaseDaoImpl<User> implements UserServiceCxf {

@Override
public User loginUser(String name, String password) {
List<User> user = (List<User> ) this.find("from User t where t.name = ? and t.password = ?",new Object[]{"学生","4297f44b13955235245b2497399d7a93"});
System.out.println(user);
return user.get(0);
}
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值