这边我是用Spring的jar包是Spring官方提供的,并没有使用CXF中的Spring的jar文件。
<!-- 加载spring容器配置 -->
<listener>
listener-class>org.springframework.web.context.ContextLoaderListener</>
<!-- 设置spring容器加载配置文件路径 -->
context-paramparam-name>contextConfigLocationparam-value>classpath*:applicationContext-server.xml>
>org.springframework.web.util.IntrospectorCleanupListenerservletservlet-name>CXFServiceservlet-class>org.apache.cxf.transport.servlet.CXFServletservlet-mappingurl-pattern>/*>
然后在src目录中,新建一个applicationContext-server.xml文件,文件内容如下:
<?xml version="1.0" encoding="UTF-8"?>
beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd" >
注意上面的带下划线加粗部分,这个很重要的哦!不能写错或是遗漏了。
package com.hoo.service;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.soAPBinding;
import javax.jws.soap.soAPBinding.Style;
import com.hoo.entity.User;
import com.hoo.entity.Users;
/**
* <b>function:</b>定制客户端请求WebService所需要的接口
* @author hoojo
* @createDate 2011-3-18 上午08:22:55
* @file ComplexUserService.java
* @package com.hoo.service
* @project CXFWebService
* @blog http://blog.csdn.net/IBM_hoojo
* @email [email protected]
* @version 1.0
*/
@WebService
@SOAPBinding(style = Style.RPC)
public interface IComplexUserService {
public User getUserByName(@WebParam(name = "name") String name);
void setUser(User user);
}