Java接收Cordys中webservice介面的返回資料並解析xml獲取相應節點資料
在做專案的過程中,需要用Java呼叫Cordys的webservice介面的返回資料,眾所周知,webservice返回的資料是xml形式的,那麼我們怎樣獲取相關節點下的資料呢?
處理之前返回的資料格式如下:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:TestBfoToPmsResponse xmlns:ns2="http://webservice.software.com/">
<return >
<![CDATA[<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Header xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<header xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas.cordys.com/General/1.0/">
< msg-id>005056B8-1720-11E7-EE6C-E0DE65F01FA7</msg-id>
<license>License has expired since 823 day(s)<cense>
</header>
<bpm xmlns="http://schemas.cordys.com/bpm/instance/1.0">
<instance_id>005056B8-1720-11E7-EE6C-E18135A09FA7</instance_id>< /bpm>
</SOAP:Header><SOAP:Body><validateInterfaceResponse xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://www.schneider.com/bpm/validateInterface">
<CValue xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://www.schneider.com/bpm/validateInterface">S</CValue>
</validateInterfaceResponse></SOAP:Body>
</SOAP:Envelope>]]>
</return>
</ns2:TestBfoToPmsResponse>
</soap:Body>
</soap:Envelope>
那麼我們現在想要獲取CValue節點下的資料,怎樣獲取呢?
下面我們進行一下處理。
public static String TestBfoToCordys(){
String cordys_webservice_url = "http://www.silencewen.me/cordys/com.eibus.web.soap.Gateway.wcp?organization=o=silence,cn=cordys,cn=defaultInst,o=nxw"
String soap =
"<SOAP:Envelope xmlns:SOAP=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
" <SOAP:Body>" +
" <validateInterface xmlns=\"http://www.schneider.com/bpm/validateInterface\">" +
" <validateInterfaceResponse>"+
"</validateInterfaceResponse>"+
" </validateInterface>" +
" </SOAP:Body>" +
"</SOAP:Envelope>";
Map<String, String> resultMap = HttpKit.postSoap3(cordys_webservice_url, soap);
String resp = resultMap.get("ResultXML");//返回XML
String resultStatus = resultMap.get("ResultStatus");//返回狀態
if(!"200".equals(resultStatus)){
Log.soaplog.debug("Cordys webservice 介面連線失敗");
return "ERROR";
}
SAXReader reader = new SAXReader();
Document document = null;
try {
document = DocumentHelper.parseText(resp);
Node EspaNode = document.selectSingleNode(".//*[local-name()='CValue']");//返回xml中CValue節點的資料
String note = EspaNode.getText();//獲取節點資料
return note;
} catch (DocumentException e) {
e.printStackTrace();
}
return null;
}
這樣我們就拿到了我們所需要的CValue節點下的值。
下邊是工具類,可以獲取cordys的一些證書什麼的。
package com.software.utils;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.HashMap;
import java.util.Map;
import javax.net.ssl.SSLContext;
import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.config.SocketConfig;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.util.EntityUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Node;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created by Silence.
*/
public class HttpKit {
private static Logger logger = LoggerFactory.getLogger(HttpKit.class);
/**
* 傳送soap到http/https
*
* @param url
* @param xml
* @return HttpResponse
*/
public static SSLContext sslContext;
public static SSLConnectionSocketFactory sslsf;
public static PoolingHttpClientConnectionManager cm;
public static PoolingHttpClientConnectionManager cmhttps;
// static {
// try {
// sslContext = new SSLContextBuilder().loadTrustMaterial(null,
// new TrustStrategy() {
// public boolean isTrusted(X509Certificate[] chain,
// String authType) throws CertificateException {
// return true;
// }
// }).build();
// sslsf = new SSLConnectionSocketFactory(sslContext);
// Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder
// .<ConnectionSocketFactory> create()
// .register("https", sslsf).build();
// cm = new PoolingHttpClientConnectionManager();
// cm.setMaxTotal(200);
// cm.setDefaultMaxPerRoute(20);
// cmhttps = new PoolingHttpClientConnectionManager(
// socketFactoryRegistry);
// cmhttps.setMaxTotal(200);
// cmhttps.setDefaultMaxPerRoute(20);
//
// // Naylor
// // int socketTimeout = 30000;
// // SocketConfig socketConfig = SocketConfig.custom()
// // .setSoTimeout(socketTimeout).build();
// // cmhttps.setDefaultSocketConfig(socketConfig);
// } catch (KeyStoreException e) {
// e.printStackTrace();
// } catch (NoSuchAlgorithmException e) {
// e.printStackTrace();
// } catch (KeyManagementException e) {
// e.printStackTrace();
// }
// }
public static void init(){
try {
sslContext = new SSLContextBuilder().loadTrustMaterial(null,
new TrustStrategy() {
public boolean isTrusted(X509Certificate[] chain,
String authType) throws CertificateException {
return true;
}
}).build();
sslsf = new SSLConnectionSocketFactory(sslContext);
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder
.<ConnectionSocketFactory> create()
.register("https", sslsf).build();
cm = new PoolingHttpClientConnectionManager();
cm.setMaxTotal(200);
cm.setDefaultMaxPerRoute(20);
cmhttps = new PoolingHttpClientConnectionManager(
socketFactoryRegistry);
cmhttps.setMaxTotal(200);
cmhttps.setDefaultMaxPerRoute(20);
// Naylor
// int socketTimeout = 30000;
// SocketConfig socketConfig = SocketConfig.custom()
// .setSoTimeout(socketTimeout).build();
// cmhttps.setDefaultSocketConfig(socketConfig);
} catch (KeyStoreException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
}
}
public static CloseableHttpClient createSSLClientDefault() {
try {
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(
null, new TrustStrategy() {
// 信任所有
public boolean isTrusted(X509Certificate[] chain,
String authType) throws CertificateException {
return true;
}
}).build();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
sslContext);
return HttpClients.custom().setSSLSocketFactory(sslsf).build();
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (KeyStoreException e) {
e.printStackTrace();
}
return HttpClients.createDefault();
}
// public static HttpResponse postSoap(String url,String xml){
// Log.soaplog.debug("url=" + url);
// Log.soaplog.debug("xml=" + xml);
// try{
// CloseableHttpClient httpClient;
// if("https".equals(url.substring(0, 5))){
// httpClient=createSSLInsecureClient();
// }else{
// httpClient=HttpClients.custom().setConnectionManager(cm).build();
// }
// HttpPost httppost=new HttpPost(url);
// HttpEntity re = new StringEntity(xml,"UTF-8");
// httppost.setHeader("Content-Type","application/soap+xml; charset=utf-8");
// httppost.setEntity(re);
// HttpResponse response = httpClient.execute(httppost);
// // httppost.abort();
//
// return response;
// }catch(Exception e){
// e.printStackTrace();
// }
// return null;
// }
// By Naylor httpPost: 過載
// 每次呼叫完需要將連線關閉掉;
public static Map<String, String> postSoap2(String url, String xml) {
//初始化:
init();
Map<String, String> resultMap = new HashMap<String, String>();
// 返回字串
String rs = null;
// 返回狀態
String resultStatusCode = "";
// 建立httppost
HttpPost httpPost = null;
// 建立引數佇列
CloseableHttpResponse response = null;
CloseableHttpClient httpClient = null;
try {
if ("https".equals(url.substring(0, 5))) {
httpClient = createSSLInsecureClient2();
// httpClient = createSSLClientDefault();
} else {
httpClient = HttpClients.custom().setConnectionManager(cm).build();
// httpClient = HttpClients.createDefault();
}
httpPost = new HttpPost(url );
HttpEntity re = new StringEntity(xml, "UTF-8");
httpPost.setHeader("Content-Type",
"application/soap+xml; charset=utf-8");
httpPost.setEntity(re);
response = httpClient.execute(httpPost);
resultStatusCode = String.valueOf(response.getStatusLine()
.getStatusCode());
HttpEntity entity = response.getEntity();
if (entity != null) {
rs = EntityUtils.toString(entity, "UTF-8");
}
} catch (Exception e) {
Log.soaplog.debug("error", e);
e.printStackTrace();
} finally {
// 關閉連線,釋放資源
try {
response.close();
httpPost.abort();
httpClient.close();
} catch (Exception e) {
e.printStackTrace();
}
}
resultMap.put("ResultStatus", resultStatusCode);
resultMap.put("ResultXML", rs);
return resultMap;
}
public static Map<String, String> postSoap3(String url, String xml) {
Map<String, String> resultMap = new HashMap<String, String>();
// 返回字串
String rs = null;
// 返回狀態
String resultStatusCode = "";
// 建立httppost
HttpPost httpPost = null;
// 建立引數佇列
CloseableHttpClient httpClient = null;
try {
String msg = "";
if(Log.msetlog.isDebugEnabled()){
if(xml.indexOf("<TaskId>") > 0){//審批時呼叫
msg = "; 審批時相關TaskId :" + xml.substring(xml.indexOf("<TaskId>")+8, xml.indexOf("</TaskId>"));
}else if(xml.indexOf("<def:EspaId>") > 0){
msg = "; SEQID:" + xml.substring(xml.indexOf("<def:EspaId>")+12, xml.indexOf("</def:EspaId>"));
}else if(xml.indexOf("<espaId>") > 0){
msg = "; SEQID:" + xml.substring(xml.indexOf("<espaId>")+8, xml.indexOf("</espaId>"));
}else if(xml.indexOf("<wsse:Username>") > 0){
msg = "; UserName:" + xml.substring(xml.indexOf("<wsse:Username>")+15, xml.indexOf("</wsse:Username>"));
}
}
if ("https".equals(url.substring(0, 5))) {
// 使用連線池
// httpClient=createSSLInsecureClient();
// 不使用連線池
Log.msetlog.debug("建立https對應httpClient開始時間:"+DateKit.getNowTime()+msg);
httpClient = createSSLClientDefault();
Log.msetlog.debug("建立https對應httpClient結束時間:"+DateKit.getNowTime()+msg);
} else {
// httpClient=HttpClients.custom().setConnectionManager(cm).build();
Log.msetlog.debug("建立httpClient開始時間:"+DateKit.getNowTime()+msg);
httpClient = HttpClients.createDefault();
Log.msetlog.debug("建立httpClient結束時間:"+DateKit.getNowTime()+msg);
}
Log.msetlog.debug("建立httpPost開始時間:"+DateKit.getNowTime()+msg);
httpPost = new HttpPost(url);
Log.msetlog.debug("建立httpPost結束時間:"+DateKit.getNowTime()+msg);
Log.msetlog.debug("設定httpPost屬性開始時間:"+DateKit.getNowTime()+msg);
HttpEntity re = new StringEntity(xml, "UTF-8");
httpPost.setHeader("Content-Type",
"application/soap+xml; charset=utf-8");
httpPost.setEntity(re);
Log.msetlog.debug("設定httpPost屬性結束時間:"+DateKit.getNowTime()+msg);
Log.msetlog.debug("最終執行呼叫介面開始時間:"+DateKit.getNowTime()+msg);
CloseableHttpResponse response = httpClient.execute(httpPost);
Log.msetlog.debug("最終執行呼叫介面結束時間:"+DateKit.getNowTime()+msg);
if (response != null) {
resultStatusCode = String.valueOf(response.getStatusLine()
.getStatusCode());
}
try {
HttpEntity entity = response.getEntity();
if (entity != null) {
rs = EntityUtils.toString(entity, "UTF-8");
}
} finally {
response.close();
httpPost.abort();
}
} catch (Exception e) {
Log.soaplog.debug("error", e);
e.printStackTrace();
} finally {
// 關閉連線,釋放資源
try {
httpClient.close();
} catch (Exception e) {
Log.soaplog.debug("error", e);
e.printStackTrace();
}
}
resultMap.put("ResultStatus", resultStatusCode);
resultMap.put("ResultXML", rs);
return resultMap;
}
//過載新增超時設定
public static Map<String, String> postSoap3(String url, String xml, int timeOut) {
Map<String, String> resultMap = new HashMap<String, String>();
// 返回字串
String rs = null;
// 返回狀態
String resultStatusCode = "";
// 建立httppost
HttpPost httpPost = null;
// 建立引數佇列
CloseableHttpClient httpClient = null;
//返回異常資訊:
String ex = null;
try {
String msg = "";
if(Log.msetlog.isDebugEnabled()){
if(xml.indexOf("<TaskId>") > 0){//審批時呼叫
msg = "; 審批時相關TaskId :" + xml.substring(xml.indexOf("<TaskId>")+8, xml.indexOf("</TaskId>"));
}else if(xml.indexOf("<def:EspaId>") > 0){
msg = "; SEQID:" + xml.substring(xml.indexOf("<def:EspaId>")+12, xml.indexOf("</def:EspaId>"));
}else if(xml.indexOf("<espaId>") > 0){
msg = "; SEQID:" + xml.substring(xml.indexOf("<espaId>")+8, xml.indexOf("</espaId>"));
}else if(xml.indexOf("<wsse:Username>") > 0){
msg = "; UserName:" + xml.substring(xml.indexOf("<wsse:Username>")+15, xml.indexOf("</wsse:Username>"));
}
}
if ("https".equals(url.substring(0, 5))) {
// 使用連線池
// httpClient=createSSLInsecureClient();
// 不使用連線池
Log.msetlog.debug("建立https對應httpClient開始時間:"+DateKit.getNowTime()+msg);
httpClient = createSSLClientDefault();
Log.msetlog.debug("建立https對應httpClient結束時間:"+DateKit.getNowTime()+msg);
} else {
// httpClient=HttpClients.custom().setConnectionManager(cm).build();
Log.msetlog.debug("建立httpClient開始時間:"+DateKit.getNowTime()+msg);
httpClient = HttpClients.createDefault();
Log.msetlog.debug("建立httpClient結束時間:"+DateKit.getNowTime()+msg);
}
Log.msetlog.debug("建立httpPost開始時間:"+DateKit.getNowTime()+msg);
httpPost = new HttpPost(url);
Log.msetlog.debug("建立httpPost結束時間:"+DateKit.getNowTime()+msg);
Log.msetlog.debug("設定httpPost屬性開始時間:"+DateKit.getNowTime()+msg);
HttpEntity re = new StringEntity(xml, "UTF-8");
httpPost.setHeader("Content-Type", "application/soap+xml; charset=utf-8");
httpPost.setEntity(re);
//新增超時:
RequestConfig requestConfig = RequestConfig.custom()
.setSocketTimeout(timeOut).setConnectTimeout(timeOut).build();//設定請求和傳輸超時時間
httpPost.setConfig(requestConfig);
Log.msetlog.debug("設定httpPost屬性結束時間:"+DateKit.getNowTime()+msg);
Log.msetlog.debug("最終執行呼叫介面開始時間:"+DateKit.getNowTime()+msg);
CloseableHttpResponse response = httpClient.execute(httpPost);
Log.msetlog.debug("最終執行呼叫介面結束時間:"+DateKit.getNowTime()+msg);
if (response != null) {
resultStatusCode = String.valueOf(response.getStatusLine()
.getStatusCode());
if ("504".equals(resultStatusCode))
{
// 504是超時
ex = "TimeoutException";
}
}
try {
HttpEntity entity = response.getEntity();
if (entity != null) {
rs = EntityUtils.toString(entity, "UTF-8");
}
} finally {
response.close();
httpPost.abort();
}
}catch(ConnectTimeoutException e1){
e1.printStackTrace();
ex = "TimeoutException";
}catch (SocketTimeoutException e2) {
e2.printStackTrace();
ex = "TimeoutException";
}catch (Exception e) {
Log.soaplog.debug("error", e);
e.printStackTrace();
ex = "Exception";
} finally {
// 關閉連線,釋放資源
try {
httpClient.close();
} catch (Exception e) {
Log.soaplog.debug("error", e);
e.printStackTrace();
ex = "Exception";
}
}
resultMap.put("ResultStatus", resultStatusCode);
resultMap.put("ResultXML", rs);
resultMap.put("ex", ex);
return resultMap;
}
/**
* 傳送soap到http/https
*
* @param url
* @param xml
* @return String
*/
public static String postSoapForStr(HttpEntity resEntity) {
if (resEntity != null) {
try {
return EntityUtils.toString(resEntity, "UTF-8");
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
/**
* 建立SSL連線忽略證書
*
* @return
*/
public static CloseableHttpClient createSSLInsecureClient() {
try {
return HttpClients.custom().setConnectionManager(cmhttps)
.setSSLSocketFactory(sslsf)
.setConnectionManagerShared(true).build();
} catch (Exception e) {
e.printStackTrace();
}
return HttpClients.createDefault();
}
public static CloseableHttpClient createSSLInsecureClient2() {
try {
return HttpClients.custom().setConnectionManager(cmhttps)
.setSSLSocketFactory(sslsf)
.build();
} catch (Exception e) {
e.printStackTrace();
}
return HttpClients.createDefault();
}
public static void main(String[] args) {
// // long begin = System.currentTimeMillis();
// // String url = "https://10.177.1.195/services/ESPAService";
// // for(int i=0;i<10;i++){
// // System.out.println(postSoap3(url,""));
// // }
// // System.out.println(System.currentTimeMillis()-begin);
//
// for (int i = 0; i < 250; i++) {
// System.out.println(createSSLInsecureClient2());
// System.out.println(cmhttps.getTotalStats());
// // try {
// // Thread.sleep(1000);
// // } catch (InterruptedException e) {
// // e.printStackTrace();
// // }
// }
//
// createSSLInsecureClient();
// System.out.println(cmhttps);
// System.out.println(cmhttps.getMaxTotal());
// System.out.println(cmhttps.getTotalStats());
long begin = System.currentTimeMillis();
String url = "http://localhost:8080/bpm/webservice/ESPABillService";
String oppId = "Nnnn";
String xml = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"http://webservice.software.com/\"> <soapenv:Header/> <soapenv:Body> <web:createESPABillPrebiding> <ESPABillPrebidingRequest> <accountName>石油xxxx</accountName> <accountNum>83</accountNum> <awardedDate>2015-12-31</awardedDate> <biddate>2015-12-18</biddate> <CWT>N</CWT> <channelType>N</channelType> <country>中國</country> <countryCode>0</countryCode> <countyLevelCity>昌平區</countyLevelCity> <countyLevelCityCode>12</countyLevelCityCode> <productLines> <family1code>MVS</family1code> <family1Id>659</family1Id> <forecastAmt>10000000.0000</forecastAmt> <forecastQuantity>1111111</forecastQuantity> <l2Id>MVS</l2Id> <lineItemId>3712</lineItemId> <productLine>PTACB</productLine> <productLineId>650</productLineId> </productLines> <productLines> <family1code>NSX</family1code> <family1Id>674</family1Id> <forecastAmt>10000000.0000</forecastAmt> <forecastQuantity>1111111</forecastQuantity> <l2Id>NSX</l2Id> <lineItemId>3713</lineItemId> <productLine>PTCCB</productLine> <productLineId>662</productLineId> </productLines> <productLines> <family1code>A9 Enclosure</family1code> <family1Id>826</family1Id> <forecastAmt>10000000.0000</forecastAmt> <forecastQuantity>1111111</forecastQuantity> <l2Id>A9 Enclosure</l2Id> <lineItemId>3714</lineItemId> <productLine>PTFDS</productLine> <productLineId>825</productLineId> </productLines> <productLines> <family1code>Easypact TVS</family1code> <family1Id>697</family1Id> <forecastAmt>10000000.0000</forecastAmt> <forecastQuantity>1111111</forecastQuantity> <l2Id>Easypact TVS</l2Id> <lineItemId>3715</lineItemId> <productLine>PTCTR</productLine> <productLineId>696</productLineId> </productLines> <productLines> <family1code>PCP Others</family1code> <family1Id>707</family1Id> <forecastAmt>10000000.0000</forecastAmt> <forecastQuantity>1111111</forecastQuantity> <l2Id>PCP Others</l2Id> <lineItemId>3716</lineItemId> <productLine>PTCTR</productLine> <productLineId>696</productLineId> </productLines> <valueChainPlayers> <VCPAccoutnName>合肥京東方光電科技有限公司</VCPAccoutnName> <VCPAccountNum>57-001A000000v4sQmIAI</VCPAccountNum> <VCPAccoutnRole>System Integrator</VCPAccoutnRole> </valueChainPlayers> <valueChainPlayers> <VCPAccoutnName>河南省新科電控裝置有限公司</VCPAccoutnName> <VCPAccountNum>133-001A000000v50gSIAQ</VCPAccountNum> <VCPAccoutnRole>Panel Builders</VCPAccoutnRole> </valueChainPlayers> <forecastAamt>50000000.0000</forecastAamt> <offerPackageId>20</offerPackageId> <offerPackageName>NS LV Transaction</offerPackageName> <oppId>"
+ oppId
+ "</oppId> <opportunityName>NS-2015-NS_EU-SESA159144-CASE17-LINNA-自增-NS LV Transaction</opportunityName> <pipeStage>05</pipeStage> <prefectureLevelCity>北京市</prefectureLevelCity> <prefectureLevelCityCode>1</prefectureLevelCityCode> <province>北京</province> <provinceCode>5323</provinceCode> <projectName>CASE17-LINNA</projectName> <secSegLv1>住宅</secSegLv1> <secSegLv1Code>A0000</secSegLv1Code> <secSegLv2>別墅/聯排</secSegLv2> <secSegLv2Code>A0100</secSegLv2Code> <sesaID>SESA159144</sesaID> <stage>Pre-bidding</stage> </ESPABillPrebidingRequest> </web:createESPABillPrebiding> </soapenv:Body> </soapenv:Envelope>";
for(int i=79;i<80;i++){
xml = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"http://webservice.software.com/\"> <soapenv:Header/> <soapenv:Body> <web:createESPABillPrebiding> <ESPABillPrebidingRequest> <accountName>石油xxxx</accountName> <accountNum>83</accountNum> <awardedDate>2015-12-31</awardedDate> <biddate>2015-12-18</biddate> <CWT>N</CWT> <channelType>N</channelType> <country>中國</country> <countryCode>0</countryCode> <countyLevelCity>昌平區</countyLevelCity> <countyLevelCityCode>12</countyLevelCityCode> <productLines> <family1code>MVS</family1code> <family1Id>659</family1Id> <forecastAmt>10000000.0000</forecastAmt> <forecastQuantity>1111111</forecastQuantity> <l2Id>MVS</l2Id> <lineItemId>3712</lineItemId> <productLine>PTACB</productLine> <productLineId>650</productLineId> </productLines> <productLines> <family1code>NSX</family1code> <family1Id>674</family1Id> <forecastAmt>10000000.0000</forecastAmt> <forecastQuantity>1111111</forecastQuantity> <l2Id>NSX</l2Id> <lineItemId>3713</lineItemId> <productLine>PTCCB</productLine> <productLineId>662</productLineId> </productLines> <productLines> <family1code>A9 Enclosure</family1code> <family1Id>826</family1Id> <forecastAmt>10000000.0000</forecastAmt> <forecastQuantity>1111111</forecastQuantity> <l2Id>A9 Enclosure</l2Id> <lineItemId>3714</lineItemId> <productLine>PTFDS</productLine> <productLineId>825</productLineId> </productLines> <productLines> <family1code>Easypact TVS</family1code> <family1Id>697</family1Id> <forecastAmt>10000000.0000</forecastAmt> <forecastQuantity>1111111</forecastQuantity> <l2Id>Easypact TVS</l2Id> <lineItemId>3715</lineItemId> <productLine>PTCTR</productLine> <productLineId>696</productLineId> </productLines> <productLines> <family1code>PCP Others</family1code> <family1Id>707</family1Id> <forecastAmt>10000000.0000</forecastAmt> <forecastQuantity>1111111</forecastQuantity> <l2Id>PCP Others</l2Id> <lineItemId>3716</lineItemId> <productLine>PTCTR</productLine> <productLineId>696</productLineId> </productLines> <valueChainPlayers> <VCPAccoutnName>合肥京東方光電科技有限公司</VCPAccoutnName> <VCPAccountNum>57-001A000000v4sQmIAI</VCPAccountNum> <VCPAccoutnRole>System Integrator</VCPAccoutnRole> </valueChainPlayers> <valueChainPlayers> <VCPAccoutnName>河南省新科電控裝置有限公司</VCPAccoutnName> <VCPAccountNum>133-001A000000v50gSIAQ</VCPAccountNum> <VCPAccoutnRole>Panel Builders</VCPAccoutnRole> </valueChainPlayers> <forecastAamt>50000000.0000</forecastAamt> <offerPackageId>20</offerPackageId> <offerPackageName>NS LV Transaction</offerPackageName> <oppId>"
+ oppId+i
+ "</oppId> <opportunityName>NS-2015-NS_EU-SESA159144-CASE17-LINNA-自增-NS LV Transaction</opportunityName> <pipeStage>05</pipeStage> <prefectureLevelCity>北京市</prefectureLevelCity> <prefectureLevelCityCode>1</prefectureLevelCityCode> <province>北京</province> <provinceCode>5323</provinceCode> <projectName>CASE17-LINNA</projectName> <secSegLv1>住宅</secSegLv1> <secSegLv1Code>A0000</secSegLv1Code> <secSegLv2>別墅/聯排</secSegLv2> <secSegLv2Code>A0100</secSegLv2Code> <sesaID>SESA159144</sesaID> <stage>Pre-bidding</stage> </ESPABillPrebidingRequest> </web:createESPABillPrebiding> </soapenv:Body> </soapenv:Envelope>";
System.out.println(postSoap3(url,xml,1));
}
// for(int i=0;i<250;i++){
// System.out.println(createSSLInsecureClient());
// System.out.println(postSoap3(url,""));
// }
System.out.println(System.currentTimeMillis()-begin);
}
/**
* 字串轉Document
*
* @param xml
* @return
*/
public static Document convertDocFromStr(String xml) {
try {
return DocumentHelper.parseText(xml);
} catch (DocumentException e) {
return null;
}
}
/**
* 獲取xml某個節點的值
*
* @param xml
* @param node
* @return
*/
public static String getNodeByXml(String xml, String node) {
Document doc = convertDocFromStr(xml);
if (doc == null) {
return null;
} else {
Node typeNode = doc.selectSingleNode(".//*[local-name()='" + node
+ "']");
if (typeNode == null) {
return null;
} else {
return typeNode.getStringValue();
}
}
}
}
相關推薦
Java接收Cordys中webservice介面的返回資料並解析xml獲取相應節點資料
在做專案的過程中,需要用Java呼叫Cordys的webservice介面的返回資料,眾所周知,webservice返回的資料是xml形式的,那麼我們怎樣獲取相關節點下的資料呢? 處理之前返回的資料格式如下: <soap:Envelope xmln
java 簡單的建立webservice介面 和遠端訪問
1.使用jdk釋出webservice import javax.jws.WebMethod; import javax.jws.WebService; import javax.xml.ws.Endpoint; /** * * @author lili */
eclipse生成的webservice客戶端呼叫webservice介面返回值慢的問題
最近在對接一個webservice介面的時候,為了方便直接用eclipse生成了webservice的客戶端,發現一個奇怪的問題,呼叫webservice的時候呼叫速度很快,但是返回資料很慢,每次需要5分鐘左右才能接收到服務端返回的值。奇葩就奇葩在隔了五分鐘
關於java 傳送http json資料格式請求時,伺服器端如何接收json資料並解析
一般情況下,傳送http請求時content-tye是application/x-www-form-urlencoded格式,而這樣的格式會以鍵值對的形似被封裝,至於是在瀏覽器傳送的時候被封裝的還是在伺服器端被封裝的我還不太清楚。但是我的猜測是在瀏覽器傳送請求的時候在客戶端
jdbc為什麼使用java.sql包中的介面而不使用com.mysql.jdbc包中的類?
java.sql包中的介面,它是sun公司為了簡化,統一對資料庫的操作,定義了一套java操作資料庫的規範,由各個資料庫公司自己實現,資料庫有mysql oracle等,而com.mysql.jdbc包中的類是mysql自己實現規範介面的類,不同的資料庫有不同的實現,為了能夠只寫一套程式碼,實現跨資
java調.net的webservice介面的用法
package com.fbb.ap.utils; import javax.annotation.PostConstruct; import javax.xml.namespace.QName; import org.apache.axis.client.Call; im
java web設計中 使用介面的好處
採用標準的架構:描述從低層到高層 首先是系統分析,找出你需要什麼功能,然後按照下面的步驟執行: 資料庫層:資料庫層就是SQL語句、資料庫、表、檢視、觸發器等等的建立和管理。這一層和JAVA無關, 但是卻是最重要的一層 持久層(Hibernate、JPA、JDBC):這一層的目的很明確,就是ORM,這裡還不用
java 呼叫wsdl的webservice介面-簡單方法
原來部落格裡寫的是用httpclient的方式呼叫,比較麻煩,cxf的方式又有侷限性,其實cxf的方式加上如下這種也可以很方便 myeclipse可以直接在自己的專案中 new一個web service client , 然後把對方給的wsdl檔案儲存到本地
Java客戶端呼叫WebService介面
Java呼叫webservice介面,基本套路都是相同的,非常簡單,我這裡使用的是axis包呼叫webservice. 首先引入標頭檔案 import javax.xml.namespace.QName; import org.apache.axis.client.Call
Java陣列排序中Comparator介面實現自定義排序
1、為節點排序。節點由3個欄位組成,包括num ,weight ,height 。先按照weight升序排序,再按照height降序排序。 2、使用Comparator介面規則:編寫多個排序方式類實現Comparator介面,並重寫新Comparator介面中的compar
Java之HttpClient呼叫WebService介面傳送簡訊原始碼實戰
## 摘要 Java之HttpClient呼叫WebService介面傳送簡訊原始碼實戰 ### 一:介面文件 ![Java之HttpClient呼叫WebService介面原始碼-001.png](https://img-blog.csdnimg.cn/img_convert/1e2ea7858d12
java 彈出選擇目錄框(選擇資料夾),獲取選擇的資料夾路徑
JFileChooser fileChooser = new JFileChooser("D:\\"); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal =
JAVA後臺接收前臺傳過來的json字串並解析獲得key 和value
前臺程式碼: $.ajax({ type:"post", url:"project/updateProject", data:{ formda
Java從資料庫中讀取Blob物件圖片並顯示
import java.sql.*; import java.io.*; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.awt.image.AffineTransformOp; import j
swift http請求返回json資料並解析
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as a
C/S應用程式中進行HTTP登入,獲取相應的資料。
前段時間處理三星的一個裝置,用其的庫時,登陸時需要指定裝置型別,應用程式裡相關的資料裡也沒有儲存裝置的型別欄位,應用裡在我不知道這個裝置型號時,問廠家怎麼解決,回覆我說一個一個的裝置型別去連線吧! 很變態呀,幾個型別的裝置試下來時間很長。由於他的裝置支援HTT
Android 中 PopupWindow 響應返回鍵並關閉的問題
轉自: http://warnerhit.iteye.com/blog/1328957 PopupWindow 跟我們的 Activity 不一樣,因為我們在構造 PW 的時候往往不是繼承來的,而是 new 出來的。 所以不能使用重寫 PW 的 onKeyDown()
FLASH 呼叫攝像頭 JS中方法觸發拍照,並將照片儲存到本地資料夾
使用 FLASH CS4 開發 有些方法和實現過程是在網上趴的,經過自己的修改,為自己所用。 建一個檔案,不用新增任何控制元件,直接F9 輸入如下程式碼: import com.adobe.images.JPGEncoder; import com.adobe.images
SpringMVC 接收頁面Post提交的json字串並解析
son 使用的是ali的fastjson; 頁面提交的是json字串,後臺使用@RequestBody String param接收資料,通過json解析param; 頁面: <%@ page language="java" contentType="text/h
android串列埠通訊接受自定義協議資料並解析問題
1.一般自定義的串列埠協議 串列埠傳輸介面底層是按位(bit)傳送的,上層是按byte傳送和接收的,但協議為了方便描述,每個byte用十六進位制數(0x00~0xFF)表示,範相當於十進位制的0~255,而byte為八位且是有符號型別,相當於十進位制的-128~127,明