已知存在webservice服務端地址,如http://127.0.0.1:8080/hello?wsdl
使用jdk自帶的wsimport工具生成客戶端代理類,命令如下:
wsimport -d D:\test -keep-verbose http://127.0.0.1:8080/hello?wsdl
將生成好的代碼復制到自己的工程中,調用如下:
public static void main(String[] args) throws MalformedURLException {
Map map = new HashMap();
map.put("pk_oa", "2022121901");
map.put("djrq", "2022-12-16 15:20:42");
map.put("zy", "報銷內容111");
map.put("jsfs", "0001Z0100000000000XZ");
map.put("zyx2", "1");
map.put("zyx1", "1");
map.put("zyx4", "1");
map.put("fydwbm", "1");
map.put("fydeptid", "1");
map.put("hbbm", "1");
map.put("customer", "1");
map.put("szxmid", "1");
map.put("jkbxr", "1");
JSONObject map1 = new JSONObject();
map1.put("defitem12", "1001A11000000001JVB5");
map1.put("defitem13", "1001A21000000006D8BP");
map1.put("defitem14", "20");
map1.put("defitem15", "10.00");
map1.put("amount", "100");
map1.put("defitem16", "10");
map1.put("defitem17", "12");
List list = new ArrayList();
list.add(map1);
map.put("items", list);
//創(chuàng)建WSDL地址,不是服務地址
URL url = new URL("http://193.168.1.30:8080/uapws/service/nc.oa.nin.itf.IRecOAInfo?wsdl");
//創(chuàng)建服務名稱
? ? ? ? //參數(shù)1:namespaceURL--命名空間地址(wsdl文檔中的targetNamespace)
? ? ? ? //參數(shù)2:服務試圖名字(wsdl文檔服務名稱,例如:)
QName qname = new QName("http://itf.nin.oa.nc/IRecOAInfo", "IRecOAInfo");
//Service創(chuàng)建視圖
Service service = Service.create(url, qname);
//獲取服務實現(xiàn)類
? ? ? ? //參數(shù)解釋:IRecOAInfoPortType?服務端口(wsdl文檔中服務端口的name屬性,例如:)
IRecOAInfoPortType mobileCodeWSSoap = service.getPort(IRecOAInfoPortType.class);
//調用查詢方法
String result = mobileCodeWSSoap.saveBxdBill(JSON.toJSONString(map));
System.out.println(result);
}
引用jar包如下
org.apache.axis axis1.4 commons-discovery commons-discovery0.2 commons-logging commons-logging org.apache.axis axis-jaxrpc1.4 org.apache.axis axis-saaj1.4 wsdl4j wsdl4j1.6.3
你是否還在尋找穩(wěn)定的海外服務器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機房具備T級流量清洗系統(tǒng)配攻擊溯源,準確流量調度確保服務器高可用性,企業(yè)級服務器適合批量采購,新人活動首月15元起,快前往官網(wǎng)查看詳情吧
本文名稱:java?調用webservice接口過程-創(chuàng)新互聯(lián)
網(wǎng)址分享:http://www.sd-ha.com/article6/iogig.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導航、做網(wǎng)站、網(wǎng)站制作、企業(yè)網(wǎng)站制作、ChatGPT、App設計
聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內容