webservice的搭建

关于webservice客户端的搭建:

一:先导入三个jar包:

<dependency>

    <groupId>org.apache.cxf</groupId>

    <artifactId>cxf-rt-frontend-jaxws</artifactId>

    <version>3.2.7</version>

</dependency>

<dependency>

    <groupId>org.apache.cxf</groupId>

    <artifactId>cxf-rt-transports-http</artifactId>

    <version>3.2.7</version>

</dependency>

 

<dependency>

    <groupId>org.apache.cxf</groupId>

    <artifactId>cxf-rt-transports-http-jetty</artifactId>

    <version>3.2.7</version>

</dependency>

 

二:构建程序

  JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance();

Client client = clientFactory.createClient("http://114.215.157.224:8086/mds/services/DataService?wsdl");//服务端地址

Object[] result = client.invoke("uploadAllData", xmlString);//方法名和传进去的参数

System.out.println(result[0]);//输出返回参数

上一篇:java – 将DAO注入CXF服务


下一篇:spring – CXF – com.ctc.wstx.exc.WstxUnexpectedCharException:非法字符((CTRL-CHAR,代码5))