1.首先在web.xml配置cxf配置文件的路径
<context-param>
<param-name>contextConfigLocation</param-name><param-value>
/WEB-INF/apache-cxf.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
2.配置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>
3.在配置cxf配置文件中配置对应的信息
<?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"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<!-- CXF ,此处是配置发布的 web service -->
<!--<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" />
-->
<!--
id指 在spring配置的bean的Id implementor 指具体的实现类 address 指明这个web service的相对地址
-->
<jaxws:endpoint address="/dxwgService">
<jaxws:implementor ref="DxwgService" />
</jaxws:endpoint>
<bean id="DxwgService" class="com.zfsoft.webservice.dxwg.service.DxwgServiceImpl"/>
</beans>
4.设置那个接口,必须配置@WebService定义
@WebService
public interface DxwgService {
/**
* 获取邮件密钥
* @param usename
* @param password
* @return
*/
public String getCodeKey(@WebParam(name = "key")String usename,@WebParam(name = "sign")String password);
/**
*
* 发送短信
* @param phone
* @param code
* @return
*/
public String sendSM(@WebParam(name = "phone")String phone,@WebParam(name = "codeKey")String codeKey,@WebParam(name = "content")String content,
@WebParam(name = "way")String way,@WebParam(name = "Sendtime")String Sendtime,@WebParam(name = "UserName")String UserName);
}
5.实现类继承这个接口,被cxf配置文件定义bean。
6.启动项目即可