呼叫webservice釋出的介面
public String executeTask(BgWorkingContext paramBgWorkingContext) throws BusinessException {
String resString = "";
// 第二種:
Call call = null;
AggNcSendEbArgBean aggBean = new AggNcSendEbArgBean();
NcSendEbArgBean bean = new NcSendEbArgBean();
bean.setBegintime("2018-01-01");
// 結束日期
bean.setEndtime("2018-10-01");
// 獲取設定的公共引數集團編碼
String dwbmcode = SysInitBO_Client.getParaString("0001", "DWBMCODE");
bean.setDwbm(dwbmcode);
aggBean.setBean(bean);
try {
// 傳遞的引數
String canshu = JaxbUtil.convertToXml(aggBean);
// wsdl地址
String addr = "http://localhost:8585/uapws/service/nc.uap.itf.iweb.IHNWebService";
// 名稱空間 wsdl裡的targetnamespace
String targetspace = "http://iweb.itf.uap.nc/IHNWebService";
Service service = new Service();
call = (Call) service.createCall();
call.setTargetEndpointAddress(new URL(addr));
// 引數型別 type是介面定義中命名的 例如:public String Weather(String type);
call.addParameter("type", XMLType.XSD_STRING, ParameterMode.IN);
// 返回值型別
call.setReturnType(XMLType.XSD_STRING);
// 呼叫Webservic介面返回的值; ( Weather是訪問的方法)
String obj = (String) call.invoke(new javax.xml.namespace.QName(targetspace, "Weather"), new Object[] { canshu });
if (obj != null && !"".equals(obj)) {
resString = obj.toString();
}
} catch (Exception e1) {
System.out.println(e1.getMessage() + ">>" + resString);
}
System.out.println("-----------" + resString + "--------------");
return null;
}