陆鹏提供了一个ws地址 http://172.26.1.123:9091/jdzh/service/DateCenterShare?wsdl 给我,它长这样:

生成代码
首先,使用jdk自带的wsimport工具生成java类:wsimport -keep -p com.soyuan.webservice.test http://172.26.1.123:9091/jdzh/service/DateCenterShare\?wsdl
-p: 指定包名
-keep: 生成源代码
运行命令后,导入到idea中:

说明:删除了.class文件;client不是自动生成的,是我自己创建用来测试的,测试代码见下面一节。
测试
在client下创建类MainTest.java
xmlData是download接口的调用参数。
package com.soyuan.webservice.test.client;import com.soyuan.webservice.test.DateCenterShareService;import com.soyuan.webservice.test.Exception_Exception;/*** @author tangwx@soyuan.com.cn* @date 2019-09-29 15:36*/public class MainTest {public static String xmlData="<?xml version='1.0' encoding='UTF-8' ?>"+"<record timeStamp='20170921164853123' id='yunnan' password='3DCEDDA1EBF7099FCD205EC77C382FBC98E1A50C' ip='172.26.1.123' rid='66530000000000000000065' operate_xm='李四' operate_sfzh='11012219771224xxxx' operate_dwmc='XX省XX市XX县XX派出所' operate_ip='10.1.1.1'>"+"<table>TB_DPAJ_JBXX</table>"+"<mingxsjc></mingxsjc>"+"<maxgxsjc></maxgxsjc>"+"<startrow>0</startrow>"+"<rownum>2</rownum>"+"</record>";public static void main(String[] args) {System.out.println(xmlData);DateCenterShareService service = new DateCenterShareService();try {String res = service.getDateCenterSharePort().download(xmlData);System.out.println(res);} catch (Exception_Exception e) {e.printStackTrace();}}}
打包
mvn clean package

Kettle中调用
将 webservice-test-1.0-SNAPSHOT.jar 拷贝到kettle安装目录下的lib目录。

注意: 必须是lib目录,而不能是lib/third-part-jar/*
示例
注意:
- 导入包
- 实例化DateCenterShareService
- 调用 ```java import com.soyuan.webservice.test.DateCenterShareService; import com.soyuan.webservice.test.Exception_Exception;
private DateCenterShareService service = new DateCenterShareService();
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException { if (first) { first = false; }
Object[] r = getRow();
if (r == null) { setOutputDone(); return false; } r = createOutputRow(r, data.outputRowMeta.size()); String input = get(Fields.In, “input”).getString(r); String res=””; try { res = service.getDateCenterSharePort().download(input);
} catch (Exception_Exception e) {e.printStackTrace();}
get(Fields.Out, “output”).setValue(r, res); putRow(data.outputRowMeta, r);
return true; }
```

