cxf spring wsdl2java
安装cxf 2.5.2配置环境变量(添加 CXF_HOME D:\0pentakill\00dev-tool\apache-cxf-2.5.2\bin,
classpath 追加 CXF_HOME/bin;
)
cmd 输入 wsdl2java 测试如果测试没有反应 添加CLASSPATH %CXF_HOME%\lib
使用 cd到 指定文件夹 执行 wsdl2java wsdl路径生成客户端代码 拷贝到 src/mian/java中
maven
<cxf.version>2.7.18</cxf.version> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-api</artifactId> <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> <version>${cxf.version}</version> </dependency>
properity
endpoint = http://localhost:12333/queryCustomer/wsdl?wsdl
spring配置文件
<?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:context="http://www.springframework.org/schema/context" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:http-conf="http://cxf.apache.org/transports/http/configuration" xmlns:sec="http://cxf.apache.org/configuration/security" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd"> <context:property-placeholder location="classpath:config.properties" />
<!---这里放的是@WebService类型的接口-> <jaxws:client id="queryCustomerServiceImpl" serviceClass="cn.bdqn.ws.querycustomer.QueryCustomerServiceImpl" address="${endpoint}" /> </beans>
测试类
package cn.bdqn.ws.querycustomer; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import java.util.List; /** * QueryCustomerServiceImplService Tester. * * @author <Authors name> * @since <pre>ʮ���� 13, 2017</pre> * @version 1.0 */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:applicationContext.xml"}) public class QueryCustomerServiceImplServiceTest { @Autowired private QueryCustomerServiceImpl queryCustomerService; @Test public void selectCustomerService(){ List<String> dddd = this.queryCustomerService.selectCustomerService("dddd"); System.out.println(dddd.size()); } }