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

image.png

生成代码

首先,使用jdk自带的wsimport工具生成java类:
wsimport -keep -p com.soyuan.webservice.test http://172.26.1.123:9091/jdzh/service/DateCenterShare\?wsdl

-p: 指定包名
-keep: 生成源代码

运行命令后,导入到idea中:

image.png

说明:删除了.class文件;client不是自动生成的,是我自己创建用来测试的,测试代码见下面一节。

测试

在client下创建类MainTest.java

xmlData是download接口的调用参数。

  1. package com.soyuan.webservice.test.client;
  2. import com.soyuan.webservice.test.DateCenterShareService;
  3. import com.soyuan.webservice.test.Exception_Exception;
  4. /**
  5. * @author tangwx@soyuan.com.cn
  6. * @date 2019-09-29 15:36
  7. */
  8. public class MainTest {
  9. public static String xmlData="<?xml version='1.0' encoding='UTF-8' ?>"
  10. +"<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'>"
  11. +"<table>TB_DPAJ_JBXX</table>"
  12. +"<mingxsjc></mingxsjc>"
  13. +"<maxgxsjc></maxgxsjc>"
  14. +"<startrow>0</startrow>"
  15. +"<rownum>2</rownum>"
  16. +"</record>";
  17. public static void main(String[] args) {
  18. System.out.println(xmlData);
  19. DateCenterShareService service = new DateCenterShareService();
  20. try {
  21. String res = service.getDateCenterSharePort().download(xmlData);
  22. System.out.println(res);
  23. } catch (Exception_Exception e) {
  24. e.printStackTrace();
  25. }
  26. }
  27. }

打包

mvn clean package

image.png

Kettle中调用

webservice-test-1.0-SNAPSHOT.jar 拷贝到kettle安装目录下的lib目录。

image.png

注意: 必须是lib目录,而不能是lib/third-part-jar/*

示例

注意:

  1. 导入包
  2. 实例化DateCenterShareService
  3. 调用 ```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);

  1. } catch (Exception_Exception e) {
  2. e.printStackTrace();
  3. }

get(Fields.Out, “output”).setValue(r, res); putRow(data.outputRowMeta, r);

return true; }

```

image.png