|
@@ -1,411 +0,0 @@
|
|
-package com.huimv.manage.util;
|
|
|
|
-
|
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
|
-import org.apache.commons.httpclient.HttpClient;
|
|
|
|
-import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
|
|
|
|
-import org.apache.commons.httpclient.methods.PostMethod;
|
|
|
|
-import org.apache.commons.httpclient.methods.RequestEntity;
|
|
|
|
-import org.apache.commons.httpclient.params.HttpConnectionParams;
|
|
|
|
-import org.dom4j.Document;
|
|
|
|
-import org.dom4j.DocumentException;
|
|
|
|
-import org.dom4j.DocumentHelper;
|
|
|
|
-import org.dom4j.Element;
|
|
|
|
-
|
|
|
|
-import java.io.*;
|
|
|
|
-import java.util.Iterator;
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * @Project : huimv.shiwan
|
|
|
|
- * @Package : com.huimv.biosafety.uface.controller
|
|
|
|
- * @Description : TODO
|
|
|
|
- * @Version : 1.0
|
|
|
|
- * @Author : ZhuoNing
|
|
|
|
- * @Create : 2020-12-25
|
|
|
|
- **/
|
|
|
|
-public class Soap2 {
|
|
|
|
- private final static String url = "http://atap.cadc.net.cn:19090/EarMarkManage/WebService2/ProduceMissionService.asmx?wsdl";
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- public static void main(String[] args) throws Exception {
|
|
|
|
- Soap2 soap2 = new Soap2();
|
|
|
|
-
|
|
|
|
- // HelloWorld ok
|
|
|
|
- String HelloWorldText = "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
|
|
|
|
- " <soap:Body>\n" +
|
|
|
|
- " <HelloWorld xmlns=\"http://tempuri.org/\" />\n" +
|
|
|
|
- " </soap:Body>\n" +
|
|
|
|
- "</soap:Envelope>";
|
|
|
|
-// callSoap(HelloWorldText);
|
|
|
|
-
|
|
|
|
- // 获取厂商编码
|
|
|
|
-// String GetProducerCodeByIDText = "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
|
|
|
|
-// " <soap:Body>\n" +
|
|
|
|
-// " <GetProducerCodeByID xmlns=\"http://tempuri.org/\">\n" +
|
|
|
|
-// " <producerID>161374</producerID>\n" +
|
|
|
|
-// " </GetProducerCodeByID>\n" +
|
|
|
|
-// " </soap:Body>\n" +
|
|
|
|
-// "</soap:Envelope>";
|
|
|
|
-// callSoap(GetProducerCodeByIDText);
|
|
|
|
-
|
|
|
|
- // 获取任务号 GetNewProduceMission ok
|
|
|
|
- String GetNewProduceMissionText = "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
|
|
|
|
- " <soap:Body>\n" +
|
|
|
|
- " <GetNewProduceMission xmlns=\"http://tempuri.org/\">\n" +
|
|
|
|
- " <produceKey>161374</produceKey>\n" +
|
|
|
|
- " </GetNewProduceMission>\n" +
|
|
|
|
- " </soap:Body>\n" +
|
|
|
|
- "</soap:Envelope>";
|
|
|
|
- // ok
|
|
|
|
-// JSONArray applyJa = soap2.parseApplyXML(soap2.callSoap(GetNewProduceMissionText));
|
|
|
|
-// System.out.println("获取任务号:"+applyJa.size());
|
|
|
|
-// for(int a=0;a<applyJa.size();a++){
|
|
|
|
-// JSONObject applyJo = applyJa.getJSONObject(a);
|
|
|
|
-// System.out.println(applyJo);
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
- // 返回任务已下载信息 ok
|
|
|
|
- String setMissionHasDownloadText = "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
|
|
|
|
- " <soap:Body>\n" +
|
|
|
|
- " <SetMissionHasDownload xmlns=\"http://tempuri.org/\">\n" +
|
|
|
|
- " <applyID>216765</applyID>\n" +
|
|
|
|
- " </SetMissionHasDownload>\n" +
|
|
|
|
- " </soap:Body>\n" +
|
|
|
|
- "</soap:Envelope>";
|
|
|
|
- //
|
|
|
|
-// soap2.callSoap(setMissionHasDownloadText);
|
|
|
|
-
|
|
|
|
- // 获取批次数据 ok
|
|
|
|
- String getNewMissionPackageText = "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
|
|
|
|
- " <soap:Body>\n" +
|
|
|
|
- " <GetNewMissionPackage xmlns=\"http://tempuri.org/\">\n" +
|
|
|
|
- " <applyID>216765</applyID>\n" +
|
|
|
|
- " </GetNewMissionPackage>\n" +
|
|
|
|
- " </soap:Body>\n" +
|
|
|
|
- "</soap:Envelope>";
|
|
|
|
- // 需要重置数据才能解析下载
|
|
|
|
-// JSONArray earPackageJa = soap2.parsePackageXML(soap2.callSoap(getNewMissionPackageText));
|
|
|
|
-// System.out.println("earPackageJa.size>>"+earPackageJa.size());
|
|
|
|
-// for(int a=0;a<earPackageJa.size();a++){
|
|
|
|
-// System.out.println((a+1)+", "+earPackageJa.getJSONObject(a));
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
- // 返回批次已下载 ok
|
|
|
|
- String setPackagesHasDownloadText = "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
|
|
|
|
- " <soap:Body>\n" +
|
|
|
|
- " <SetPackagesHasDownload xmlns=\"http://tempuri.org/\">\n" +
|
|
|
|
- " <packageIDs>\n" +
|
|
|
|
- " <int>119</int>\n" +
|
|
|
|
- " <int>120</int>\n" +
|
|
|
|
- " </packageIDs>\n" +
|
|
|
|
- " </SetPackagesHasDownload>\n" +
|
|
|
|
- " </soap:Body>\n" +
|
|
|
|
- "</soap:Envelope>";
|
|
|
|
- //
|
|
|
|
-// soap2.callSoap(setPackagesHasDownloadText);
|
|
|
|
-
|
|
|
|
- // 获取耳标数据 ok
|
|
|
|
- String getNewMissionEarMarkText = "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
|
|
|
|
- " <soap:Body>\n" +
|
|
|
|
- " <GetNewMissionEarMark xmlns=\"http://tempuri.org/\">\n" +
|
|
|
|
- " <applyID>216765</applyID>\n" +
|
|
|
|
- " </GetNewMissionEarMark>\n" +
|
|
|
|
- " </soap:Body>\n" +
|
|
|
|
- "</soap:Envelope>";
|
|
|
|
- // ok
|
|
|
|
-// JSONArray earMarkJa = soap2.parseEarMarkXML(soap2.callSoap(getNewMissionEarMarkText));
|
|
|
|
-// System.out.println("earMarkJa.size>>"+earMarkJa.size());
|
|
|
|
-// for(int a=0;a<earMarkJa.size();a++){
|
|
|
|
-// System.out.println((a+1)+", "+earMarkJa.getJSONObject(a));
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
- // 返回耳标已下载 ok
|
|
|
|
- String setEarMarksHasDownLoadText = "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
|
|
|
|
- " <soap:Body>\n" +
|
|
|
|
- " <SetEarMarksHasDownload xmlns=\"http://tempuri.org/\">\n" +
|
|
|
|
- " <earMarkIDs>\n" +
|
|
|
|
- " <long>9787182314</long>\n" +
|
|
|
|
- " <long>9787182315</long>\n" +
|
|
|
|
- " </earMarkIDs>\n" +
|
|
|
|
- " </SetEarMarksHasDownload>\n" +
|
|
|
|
- " </soap:Body>\n" +
|
|
|
|
- "</soap:Envelope>";
|
|
|
|
- // ok
|
|
|
|
-// soap2.callSoap(setEarMarksHasDownLoadText);
|
|
|
|
-
|
|
|
|
-// String uploadDataToWebServiceText = "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
|
|
|
|
-// " <soap:Body>\n" +
|
|
|
|
-// " <UploadDataToWebService xmlns=\"http://tempuri.org/\">\n" +
|
|
|
|
-// " <uploadData>\n" +
|
|
|
|
-// " <xsd:schema>schema</xsd:schema>xml</uploadData>\n" +
|
|
|
|
-// " </UploadDataToWebService>\n" +
|
|
|
|
-// " </soap:Body>";
|
|
|
|
-
|
|
|
|
- // 上传批次、耳标生产数据
|
|
|
|
- // 1
|
|
|
|
-// String uploadDataToWebServiceText = "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
|
|
|
|
-// " <soap:Body>\n" +
|
|
|
|
-// " <UploadDataToWebService xmlns=\"http://tempuri.org/\">\n" +
|
|
|
|
-// " <uploadData>\n" +
|
|
|
|
-// " <applyID>216765</applyID>" +
|
|
|
|
-// " <packageID>119</packageID>" +
|
|
|
|
-// " <produceDate>2021-10-22</produceDate>" +
|
|
|
|
-// " <produceLineID>001</produceLineID>" +
|
|
|
|
-// " <earMarkID>9787182314</earMarkID>" +
|
|
|
|
-// " </uploadData>\n" +
|
|
|
|
-// " </UploadDataToWebService>\n" +
|
|
|
|
-// " </soap:Body>\n"+
|
|
|
|
-// "</soap:Envelope>";
|
|
|
|
- // 2
|
|
|
|
- String uploadDataToWebServiceText = "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
|
|
|
|
- " <soap:Body>\n" +
|
|
|
|
- " <UploadDataToWebService xmlns=\"http://tempuri.org/\">\n" +
|
|
|
|
-// " <uploadData>\n" +
|
|
|
|
- " <Package id='119'>\n" +
|
|
|
|
- " <applyID>216765</applyID>\n" +
|
|
|
|
- " <packageID>119</packageID>\n" +
|
|
|
|
- " <produceDate>2021-10-22 10:10:10.000</produceDate>\n" +
|
|
|
|
- " <produceLineID>1</produceLineID>\n" +
|
|
|
|
- " <earMarkID>9787182314</earMarkID>\n" +
|
|
|
|
- " </Package>\n" +
|
|
|
|
-// " </uploadData>\n" +
|
|
|
|
- " </UploadDataToWebService>\n" +
|
|
|
|
- " </soap:Body>\n" +
|
|
|
|
- "</soap:Envelope>";
|
|
|
|
- //
|
|
|
|
- soap2.callSoap(uploadDataToWebServiceText);
|
|
|
|
-
|
|
|
|
-// JSONArray earMarkJa = soap2.parseEarMarkXML(soap2.callSoap(uploadDataToWebServiceText));
|
|
|
|
-// System.out.println("earMarkJa.size>>"+earMarkJa.size());
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // 上传装箱信息数据
|
|
|
|
-
|
|
|
|
- // 上传箱发货信息
|
|
|
|
-
|
|
|
|
- // 获取服务器时间 ok
|
|
|
|
- String getServerDateTimeText = "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
|
|
|
|
- " <soap:Body>\n" +
|
|
|
|
- " <GetServerDateTime xmlns=\"http://tempuri.org/\" />\n" +
|
|
|
|
- " </soap:Body>\n" +
|
|
|
|
- "</soap:Envelope>";
|
|
|
|
-// callSoap(getServerDateTimeText);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 解析获取任务号 ok
|
|
|
|
- private JSONArray parseApplyXML(String xml) {
|
|
|
|
- Document doc = null;
|
|
|
|
- try {
|
|
|
|
- doc = DocumentHelper.parseText(xml); // 将字符串转为XML
|
|
|
|
- Element rootElt = doc.getRootElement(); // 获取根节点
|
|
|
|
-// System.out.println("根节点:" + rootElt.getName()); // 拿到根节点的名称
|
|
|
|
-
|
|
|
|
- Iterator iter = rootElt.elementIterator("Body"); // 获取根节点下的子节点 Body
|
|
|
|
- Element recordEle = (Element) iter.next();
|
|
|
|
-
|
|
|
|
- Iterator iter2 = recordEle.elementIterator("GetNewProduceMissionResponse");
|
|
|
|
- Element recordEle2 = (Element) iter2.next();
|
|
|
|
-
|
|
|
|
- Iterator GetNewMissionEarMarkResultIter = recordEle2.elementIterator("GetNewProduceMissionResult");
|
|
|
|
- Element GetNewMissionEarMarkResultIterEle = (Element) GetNewMissionEarMarkResultIter.next();
|
|
|
|
-
|
|
|
|
-// Iterator schemaIter = GetNewMissionEarMarkResultIterEle.elementIterator("schema");
|
|
|
|
-// Element schemaEle = (Element) schemaIter.next();
|
|
|
|
- Iterator diffgramIter = GetNewMissionEarMarkResultIterEle.elementIterator("diffgram");
|
|
|
|
- Element diffgramEle = (Element) diffgramIter.next();
|
|
|
|
-
|
|
|
|
- Iterator newDataSetIter = diffgramEle.elementIterator("NewDataSet");
|
|
|
|
- Element newDataSetChildEle = (Element) newDataSetIter.next();
|
|
|
|
-
|
|
|
|
- Iterator missionIter = newDataSetChildEle.elementIterator("Mission");
|
|
|
|
- System.out.println("missionIter.hasNext()>>"+missionIter.hasNext());
|
|
|
|
- // 所有数据
|
|
|
|
- JSONArray allDataJa = new JSONArray();
|
|
|
|
-
|
|
|
|
- while (missionIter.hasNext()) {
|
|
|
|
- JSONObject earMarkJo = new JSONObject();
|
|
|
|
- allDataJa.add(earMarkJo);
|
|
|
|
- Element earMarkIterEle = (Element) missionIter.next();
|
|
|
|
- earMarkJo.put("ApplyID",earMarkIterEle.elementTextTrim("ApplyID"));
|
|
|
|
- earMarkJo.put("org_id",earMarkIterEle.elementTextTrim("org_id"));
|
|
|
|
- earMarkJo.put("org_name",earMarkIterEle.elementTextTrim("org_name"));
|
|
|
|
- earMarkJo.put("org_address",earMarkIterEle.elementTextTrim("org_address"));
|
|
|
|
- earMarkJo.put("org_linkman",earMarkIterEle.elementTextTrim("org_linkman"));
|
|
|
|
- earMarkJo.put("postcode",earMarkIterEle.elementTextTrim("postcode"));
|
|
|
|
- earMarkJo.put("org_tel",earMarkIterEle.elementTextTrim("org_tel"));
|
|
|
|
- earMarkJo.put("AssignedDate",earMarkIterEle.elementTextTrim("AssignedDate"));
|
|
|
|
- earMarkJo.put("EarMarkAmount",earMarkIterEle.elementTextTrim("EarMarkAmount"));
|
|
|
|
- earMarkJo.put("RealEarMarkAmount",earMarkIterEle.elementTextTrim("RealEarMarkAmount"));
|
|
|
|
- earMarkJo.put("MissionProcessor",earMarkIterEle.elementTextTrim("MissionProcessor"));
|
|
|
|
- earMarkJo.put("ConsignmentDate",earMarkIterEle.elementTextTrim("ConsignmentDate"));
|
|
|
|
- earMarkJo.put("ApplyRegionName",earMarkIterEle.elementTextTrim("ApplyRegionName"));
|
|
|
|
- earMarkJo.put("AnimalType",earMarkIterEle.elementTextTrim("AnimalType"));
|
|
|
|
- earMarkJo.put("AnimalTypeName",earMarkIterEle.elementTextTrim("AnimalTypeName"));
|
|
|
|
- }
|
|
|
|
- return allDataJa;
|
|
|
|
- } catch (DocumentException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- return null;
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //
|
|
|
|
- private JSONArray parsePackageXML(String xml) {
|
|
|
|
- JSONArray packageJa = new JSONArray();
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- return packageJa;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //解析EarMark
|
|
|
|
- public JSONArray parseEarMarkXML(String xml){
|
|
|
|
- Document doc = null;
|
|
|
|
- try {
|
|
|
|
- doc = DocumentHelper.parseText(xml); // 将字符串转为XML
|
|
|
|
- Element rootElt = doc.getRootElement(); // 获取根节点
|
|
|
|
-// System.out.println("根节点:" + rootElt.getName()); // 拿到根节点的名称
|
|
|
|
-
|
|
|
|
- Iterator iter = rootElt.elementIterator("Body"); // 获取根节点下的子节点 Body
|
|
|
|
-// System.out.println("iter.hasNext:"+iter.hasNext());
|
|
|
|
- Element recordEle = (Element) iter.next();
|
|
|
|
-// System.out.println("name="+recordEle.getName());
|
|
|
|
-
|
|
|
|
- Iterator iter2 = recordEle.elementIterator("GetNewMissionEarMarkResponse");
|
|
|
|
-// System.out.println("iter2.hasNext:"+iter2.hasNext());
|
|
|
|
- Element recordEle2 = (Element) iter2.next();
|
|
|
|
-// System.out.println("name="+recordEle2.getName());
|
|
|
|
-
|
|
|
|
- Iterator GetNewMissionEarMarkResultIter = recordEle2.elementIterator("GetNewMissionEarMarkResult");
|
|
|
|
-// System.out.println("GetNewMissionEarMarkResultIter.hasNext:"+GetNewMissionEarMarkResultIter.hasNext());
|
|
|
|
- Element GetNewMissionEarMarkResultIterEle = (Element) GetNewMissionEarMarkResultIter.next();
|
|
|
|
-// System.out.println("name="+GetNewMissionEarMarkResultIterEle.getName());
|
|
|
|
-
|
|
|
|
- Iterator schemaIter = GetNewMissionEarMarkResultIterEle.elementIterator("schema");
|
|
|
|
-// System.out.println("schemaIter.hasNext:"+schemaIter.hasNext());
|
|
|
|
- Element schemaEle = (Element) schemaIter.next();
|
|
|
|
-// System.out.println("name="+schemaEle.getName());
|
|
|
|
- Iterator diffgramIter = GetNewMissionEarMarkResultIterEle.elementIterator("diffgram");
|
|
|
|
-// System.out.println("diffgramIter.hasNext:"+diffgramIter.hasNext());
|
|
|
|
- Element diffgramEle = (Element) diffgramIter.next();
|
|
|
|
-// System.out.println("name="+diffgramEle.getName());
|
|
|
|
-
|
|
|
|
- Iterator newDataSetIter = diffgramEle.elementIterator("NewDataSet");
|
|
|
|
-// System.out.println("newDataSetIter.hasNext:"+newDataSetIter.hasNext());
|
|
|
|
- Element newDataSetChildEle = (Element) newDataSetIter.next();
|
|
|
|
-// System.out.println("name="+newDataSetChildEle.getName());
|
|
|
|
-
|
|
|
|
- Iterator earMarkIter = newDataSetChildEle.elementIterator("EarMark");
|
|
|
|
-// System.out.println("newDataSetIter.hasNext:"+newDataSetIter.hasNext());
|
|
|
|
- // 所有数据
|
|
|
|
- JSONArray allDataJa = new JSONArray();
|
|
|
|
-
|
|
|
|
- while (earMarkIter.hasNext()) {
|
|
|
|
- JSONObject earMarkJo = new JSONObject();
|
|
|
|
- allDataJa.add(earMarkJo);
|
|
|
|
- Element earMarkIterEle = (Element) earMarkIter.next();
|
|
|
|
- earMarkJo.put("EarMarkID",earMarkIterEle.elementTextTrim("EarMarkID"));
|
|
|
|
- earMarkJo.put("PackageID",earMarkIterEle.elementTextTrim("PackageID"));
|
|
|
|
- earMarkJo.put("EarMarkNumber",earMarkIterEle.elementTextTrim("EarMarkNumber"));
|
|
|
|
- earMarkJo.put("ApplyID",earMarkIterEle.elementTextTrim("ApplyID"));
|
|
|
|
- earMarkJo.put("EarMarkData",earMarkIterEle.elementTextTrim("EarMarkData"));
|
|
|
|
-
|
|
|
|
-// Iterator earMarkIDIter = earMarkIterEle.elementIterator("EarMarkID");
|
|
|
|
-// Element earMarkIDEle = (Element) earMarkIDIter.next();
|
|
|
|
-// System.out.println("EarMarkID="+earMarkIDEle.getText());
|
|
|
|
-// earMarkJo.put("EarMarkID",earMarkIDEle.getText());
|
|
|
|
-//
|
|
|
|
-
|
|
|
|
-// Iterator packageIDIter = earMarkIterEle.elementIterator("PackageID");
|
|
|
|
-// Element packageIDEle = (Element) packageIDIter.next();
|
|
|
|
-// System.out.println("PackageID="+packageIDEle.getText());
|
|
|
|
-// earMarkJo.put("PackageID",packageIDEle.getText());
|
|
|
|
-
|
|
|
|
-// Iterator earMarkNumberIter = earMarkIterEle.elementIterator("EarMarkNumber");
|
|
|
|
-// Element earMarkNumberEle = (Element) earMarkNumberIter.next();
|
|
|
|
-// System.out.println("EarMarkNumber="+earMarkNumberEle.getText());
|
|
|
|
-// earMarkJo.put("EarMarkNumber",earMarkNumberEle.getText());
|
|
|
|
-
|
|
|
|
-// Iterator applyIDIter = earMarkIterEle.elementIterator("ApplyID");
|
|
|
|
-// Element applyIDEle = (Element) applyIDIter.next();
|
|
|
|
-// System.out.println("ApplyID="+applyIDEle.getText());
|
|
|
|
-// earMarkJo.put("ApplyID",applyIDEle.getText());
|
|
|
|
-
|
|
|
|
-// Iterator earMarkDataIter = earMarkIterEle.elementIterator("EarMarkData");
|
|
|
|
-// Element earMarkDataEle = (Element) earMarkDataIter.next();
|
|
|
|
-// System.out.println("EarMarkData="+earMarkDataEle.getText());
|
|
|
|
-// earMarkJo.put("EarMarkData",earMarkDataEle.getText());
|
|
|
|
-// System.out.println("");
|
|
|
|
- }
|
|
|
|
-// System.out.println("2 allDataJa.size>>"+allDataJa.size());
|
|
|
|
-// for(int a=0;a<allDataJa.size();a++){
|
|
|
|
-// System.out.println((a+1)+" "+allDataJa.getJSONObject(a));
|
|
|
|
-// }
|
|
|
|
- return allDataJa;
|
|
|
|
- } catch (DocumentException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- return null;
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- public String callSoap(String text) throws UnsupportedEncodingException {
|
|
|
|
- String str = new String(text.getBytes(), "UTF-8");
|
|
|
|
- System.out.println(str);
|
|
|
|
- HttpClient httpClient = new HttpClient();
|
|
|
|
- httpClient.getParams().setParameter(HttpConnectionParams.CONNECTION_TIMEOUT, 3000);
|
|
|
|
- httpClient.getParams().setParameter(HttpConnectionParams.SO_TIMEOUT, 1000);
|
|
|
|
- PostMethod post = new PostMethod(url);
|
|
|
|
- post.setRequestHeader("Content-Type", "text/xml;charset=utf-8");
|
|
|
|
- RequestEntity re = new InputStreamRequestEntity(new ByteArrayInputStream(str.getBytes()));
|
|
|
|
- post.setRequestEntity(re);
|
|
|
|
- BufferedReader in = null;
|
|
|
|
- try {
|
|
|
|
- int status = httpClient.executeMethod(post);
|
|
|
|
- System.out.println("返回状态码>>"+status);
|
|
|
|
- if (status == 200) {
|
|
|
|
- System.out.println("返回数据成功.");
|
|
|
|
- InputStream io = post.getResponseBodyAsStream();
|
|
|
|
- InputStreamReader is = new InputStreamReader(io, "UTF-8");
|
|
|
|
- in = new BufferedReader(is);
|
|
|
|
- String inputLine;
|
|
|
|
- StringBuilder result = new StringBuilder();
|
|
|
|
- while ((inputLine = in.readLine()) != null) {
|
|
|
|
- result.append(inputLine);
|
|
|
|
- }
|
|
|
|
- String a = result.toString().replace("<", "<").replace(">", ">");
|
|
|
|
- System.out.println("返回下面的数据>>");
|
|
|
|
- System.out.println(a);
|
|
|
|
- return a;
|
|
|
|
- } else {
|
|
|
|
- System.out.println("调用接口失败");
|
|
|
|
- System.out.println(post.getResponseBodyAsString());
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- return null;
|
|
|
|
- } finally {
|
|
|
|
- if (in != null) {
|
|
|
|
- try {
|
|
|
|
- in.close();
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- // TODO Auto-generated catch block
|
|
|
|
- e.printStackTrace();
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- post.releaseConnection();
|
|
|
|
- httpClient.getHttpConnectionManager().closeIdleConnections(0);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-}
|
|
|