1、新建一个java项目

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

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

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

4、编写applicationContext.xml

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
 4     xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:cxf="http://cxf.apache.org/core"
 5     xsi:schemaLocation="http://www.springframework.org/schema/beans 
 6                             http://www.springframework.org/schema/beans/spring-beans.xsd
 7                             http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
 8                             http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
 9                             http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
10     <jaxws:client id="client" address="http://127.0.0.1:8080/demo12/ws/number" serviceClass="com.xiaostudy.TestServiceImpl"/>
11 </beans>

5、开启客户端

 1 package com.xiaostudy;
 2 
 3 import org.springframework.context.ApplicationContext;
 4 import org.springframework.context.support.ClassPathXmlApplicationContext;
 5 
 6 /**
 7  * @desc 客户端
 8  * @author xiaostudy
 9  *
10  */
11 public class MyClient {
12 
13     public static void main(String[] args) {
14         
15         ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
16         TestServiceImpl testServiceImpl = (TestServiceImpl)applicationContext.getBean("client");
17         System.out.println(testServiceImpl);
18         String string = testServiceImpl.getNumber("666");
19         System.out.println(string);
20     }
21 
22 }

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