<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      ETL第二篇 調(diào)用webservice

      前言

      這里使用ETL [Java代碼] 實現(xiàn)

      代碼中使用axis調(diào)用webservice

      在ETL提供了 Processor類中直接寫業(yè)務(wù)代碼, 而且是每次讀取一行數(shù)據(jù)

      jar包準(zhǔn)備

      將需要用到的jar包提前放到data-integration/libdata-integration/libswt/對應(yīng)的目錄下
      我這里為了方便, 將需要的包發(fā)到了data-integration/libswt/win64/

      用到的相關(guān)包: 鏈接: https://pan.baidu.com/s/1vpUppn-57sc9z3tFGux3uA 密碼: 3phi

      代碼示例

      這里提供一個簡單的示例供參考

      import java.net.URL;
      
      import javax.xml.namespace.QName;
      
      import net.sf.json.JSONArray;
      import net.sf.json.JSONObject;
      
      import org.apache.axis.client.Call;
      import org.apache.axis.client.Service;
      
      
      
      public boolean processRow(StepMetaInterface smi,StepDataInterface sdi) throws KettleException{
      
      	Object[] r = getRow(); // 獲取輸入, 這里獲取流中的一行數(shù)據(jù)
      	
      	if (r == null) {
      		setOutputDone(); // 結(jié)束輸出, 說明流中沒有數(shù)據(jù)了
      		return false; 
      	}
      
      	// 獲取字段, 從r中獲取需要的字段
      	String pk_corp = get(Fields.In, "pk_corp").getString(r);
      
      	
      	// 因為我這里需要給WS接口發(fā)送的數(shù)據(jù)是[{"pk_corp":pk_corp},{}...]
      	JSONArray syncDatas = new JSONArray();
      	JSONObject syncData = new JSONObject();
      		
      	syncData.put("pk_corp",pk_corp);
      
      	syncDatas.add(syncData);
      
      	// 輸出數(shù)組, 會輸出到輸出流
      	Object[] outputRow = createOutputRow(r, data.outputRowMeta.size());
      	JSONObject result = null;
      
      try {
      	// 輸出日志,也是ETL提供的方法
      	logBasic("【請求數(shù)據(jù)】" + syncDatas.toString());
      	
      	// 調(diào)用ws接口
      	result = syncToNC(syncDatas.toString());
      	
      	logBasic("【結(jié)果】" + result.toString());
      
      } catch (Exception e) {
      	logError("【捕獲異常】" + e.getMessage());
      
      	// 這里獲取流中的字段并賦值, syncSign和errorLog是我在ETL[字段]中自定義的
      	get(Fields.Out, "syncSign").setValue( outputRow, '0' );
      	get(Fields.Out, "errorLog").setValue( outputRow, e.getMessage());	
      	
      	// 輸出數(shù)據(jù)傳輸?shù)较乱徊? 下一步接收的數(shù)據(jù)就會有我在[字段中]添加的字段
      	putRow(data.outputRowMeta, outputRow);
      	
      	return true;
      }
      
      	if( result.containsKey("code") &&  result.getInt("code") == 0) {
      		JSONArray resultDatas = result.getJSONArray("data");
      		JSONObject resultData = resultDatas.getJSONObject(0);
      
      		// 輸出字段
      		get(Fields.Out, "syncSign").setValue( outputRow, '1' );
      		get(Fields.Out, "newNCPK").setValue( outputRow, resultData.getString("ncPK"));
      	} else {
      		// 輸出字段
      		get(Fields.Out, "syncSign").setValue( outputRow, '2' );
      		get(Fields.Out, "errorLog").setValue( outputRow, result.getString("msg"));		
      
      	}
      	
      	putRow(data.outputRowMeta, outputRow);
      
      	return true;
      } 
      
      // 調(diào)用webservice 
      private static JSONObject syncToNC(String str) throws Exception {
      	
      		JSONObject jsonResult = null;
      		// 接口地址  ( 這里后面不加"?wsdl"
      		String endpoint = "http://localhost:8090/uapws/service/nc.ift.hs.ydrs.IAddStapplybService";		
      		// targetNamespace
      		String targetNamespace = "http://ydrs.hs.ift.nc/IAddStapplybService";
      		// 調(diào)用接口中的方法
      		String operationName = "addStapplyb";
      		String result = null;
      		String message = null;
      		
      		// 接口方法名
      		Service service = new Service();
      		Call call = (Call) service.createCall();
      		// 設(shè)置webservice地址
      		call.setTargetEndpointAddress(new URL(endpoint));
      		// 發(fā)布的方法名
      		call.setOperationName(new QName(targetNamespace, operationName));
      		// 設(shè)置參數(shù)
      		call.addParameter("string", org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
      		// 返回類型
      		call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
      		call.setEncodingStyle("utf-8");
      		call.setUseSOAPAction(true);
      		call.setSOAPActionURI(targetNamespace + operationName);
      		// 設(shè)置參數(shù)組
      		Object[] params = new Object[] { str };
      
      		// 調(diào)用接口
      		result = (String) call.invoke(params);
      		// 處理結(jié)果
      		if (result != null && ! "".equals(result)) {
      			jsonResult = JSONObject.fromObject(result);
      		}
      	
      		return jsonResult;
      }
      

      ETL中使用Java代碼

      自定義字段

      posted @ 2018-08-22 08:02  小鳴Cycling  閱讀(2376)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 欧美激情精品久久久久久| 亚洲色拍拍噜噜噜最新网站| 亚洲AV国产福利精品在现观看| 国产婷婷精品av在线| 亚洲精品国产综合久久一线| 久久亚洲国产精品久久| 国产极品精品自在线不卡| 国产妇女馒头高清泬20p多毛| 亚洲精品美女久久久久9999 | 99久热在线精品视频| 亚洲中文字幕伊人久久无码 | 91一区二区三区蜜桃臀| 国产资源精品中文字幕| 久久精品第九区免费观看| 亚洲欧洲日产国码久在线| 91精品国产免费人成网站| 亚洲人成色99999在线观看| 疯狂做受XXXX高潮国产| 激情综合网激情综合网激情| 国产精品中文字幕av| 欲香欲色天天天综合和网| 麻豆文化传媒精品一区观看| 亚洲人成小说网站色在线 | 五十路丰满中年熟女中出| 国产成人午夜精品永久免费| 国产精品中文字幕二区| 强奷乱码欧妇女中文字幕熟女| av天堂久久精品影音先锋| 久久国产精品成人免费| 亚洲精品国男人在线视频| 国产资源精品中文字幕| 日本喷奶水中文字幕视频| 国产综合一区二区三区麻豆| 国产国产乱老熟女视频网站97 | 亚洲夜夜欢一区二区三区| 亚洲av成人一区二区三区| 日韩区中文字幕在线观看| 欧美激情一区二区三区成人| 男人又大又硬又粗视频| 国产精品无遮挡又爽又黄| 无码精品人妻一区二区三区中|