1、新建一个java项目

2、导入cxf相关的jar包,并部署到项目中

3、用命令生成客户端使用说明文档

wsdl2java -p com.xiaostudy -d . http://127.0.0.1:8080/demo12/ws/number?wsdl

4、编写applicationContext.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:jaxrs="http://cxf.apache.org/jaxrs" xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
<jaxws:client id="client" address="http://127.0.0.1:8080/demo12/ws/number" serviceClass="com.xiaostudy.TestServiceImpl"/>
</beans>

5、开启客户端

 package com.xiaostudy;

 import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; /**
* @desc 客户端
* @author xiaostudy
*
*/
public class MyClient { public static void main(String[] args) { ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
TestServiceImpl testServiceImpl = (TestServiceImpl)applicationContext.getBean("client");
System.out.println(testServiceImpl);
String string = testServiceImpl.getNumber("666");
System.out.println(string);
} }

6、运行客户端,看是否成功