`
nxw_tsp
  • 浏览: 18502 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

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();
            }
        }
    }
}
<script type="text/javascript"> $(function () { $('pre.prettyprint code').each(function () { var lines = $(this).text().split('\n').length; var $numbering = $('<ul/>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('<li/>').text(i)); }; $numbering.fadeIn(1700); }); }); </script>
分享到:
评论

相关推荐

    javacode发布成webservice

    通过将生成的WebService部署到WSApp类型的ServiceProcessor中,可以确保服务能够正常运行并对外提供访问接口。 综上所述,通过上述步骤,我们可以将Java代码成功地发布为WebService。这一过程不仅涉及基本的技术...

    Cordys开发流程指南

    - **连接活动**: 使用“Connector”将“Start”节点连接到第一个活动(获取产品信息)。 - **消息映射**: 对每个活动进行消息映射,确保输入输出消息正确传递,从而实现流程各环节之间的数据交换。 以上内容概述了...

    Cordys项目jar包

    Cordys是一个基于Java的企业级业务流程管理(BPM)和企业服务总线(ESB)平台,它提供了一个统一的框架来设计、执行和优化企业的业务流程。这个压缩包包含的是Cordys项目的相关jar文件,对于在Eclipse开发环境中进行...

    实现Cordys的gatway

    在IT行业中,Cordys是一个基于Java的企业级工作流和集成平台,它提供了一系列工具和服务,帮助企业构建、部署和管理应用程序。"实现Cordys的gatway"这个主题主要涉及的是Cordys平台中的一个关键组件——Gateway,它...

    cordys资料

    在这个示例中,JavaScript 代码初始化了 Cordys 的 TaskLibrary 对象,并从 URL 查询字符串中获取任务 ID。当用户点击“提交”按钮时,`submitpage()` 函数会修改 XML 数据并提交到 BPM 平台,完成任务。 【总结】 ...

    CORDYS中XFORM开发步骤

    ### CORDYS中XFORM开发步骤详解 #### 一、概览 本文档详细介绍了在CORDYS平台上进行XFORM开发的具体步骤。CORDYS是一个企业级的业务流程管理(Business Process Management, BPM)平台,它提供了丰富的工具和服务来...

    CORDYS BOP 业务运营平台技术方案v1

    ### CORDYS BOP 业务运营平台技术方案v1 关键知识点解析 #### CORDYS BOP 概述 **CORDYS BOP**(Business Operation Platform)是一个全面的业务运营平台,旨在通过集成多种关键技术和工具来提升企业的业务流程...

    cordys中的查询

    Cordys中的简单查询,在Cordys中多表关联时,需要的查询方法

    基于Cordys平台的煤矿设备管理系统的数据安全设计

    Cordys平台是近年来在企业级应用开发中被广泛使用的商务流程自动化平台。基于Cordys平台开发的煤矿设备管理系统是一个针对煤炭行业设备管理特殊需求定制的信息系统,它能够帮助煤炭企业进行高效、安全的设备管理。...

    bpm_cordys框架

    Cordys平台采用了独特的XML架构,这不仅使得数据交换变得更加容易,还增强了系统的灵活性和可扩展性。XML是一种广泛接受的标准格式,便于与其他系统的集成。 **6. Cordys WS-APP Server,复合应用的快速开发环境** ...

    webservices各种生成方式.doc

    本文档旨在详细介绍 Cordys BOP-4 平台中创建 WebService 的多种方法及其步骤。这些方法涵盖了从简单的数据操作到复杂的业务流程处理的各种场景,旨在为开发人员提供一个全面且实用的指南。 #### WebService 创建...

    BPM_cordys框架

    ### BPM_Cordys框架知识点详解 #### 一、Cordys框架概述 **Cordys框架**是由荷兰Cordys信息系统有限公司开发的一款先进的面向服务架构(SOA)平台。该平台旨在帮助企业构建更加灵活和敏捷的IT系统,以应对快速变化...

    CORDYS和SAP场景模拟-wall

    CORDYS 和 SAP 场景模拟 CORDYS 和 SAP 场景模拟

    .Cordys建模基础.doc

    本文将深入探讨Cordys建模基础的核心概念,特别是其在商业领域的应用,包括价值链模型、业务环境模型及业务流程模型,并阐述业务流程建模的重要性及其在Cordys Studio中的实现方式。 ### 模型与现实世界的桥梁 ...

    基于Cordys的煤矿设备维护管理系统设计

    从煤矿设备日常维护管理的现状出发,设计了基于Cordys的煤矿设备维护管理系统,实现了空间数据、属性数据在整个煤矿的全面整合,对煤矿设备实现了实时、远程、动态的管理,当设备运行异常时快速实现故障定位与维护。

    Cordys 项目导出与debug配置

    Cordys是一个企业服务总线(Enterprise Service Bus,ESB)解决方案,它允许企业通过定义和控制服务来管理复杂的IT系统和应用。它为企业提供了一种服务导向的架构(Service-Oriented Architecture,SOA)来改进业务...

    CORDYS+BOP+业务运营平台技术方案

    - **开放环境中的安全**: 针对开放环境下的安全问题提出了相应的防护措施。 - **基于CORDYS身份的安全**: 通过多种认证方式确保用户身份的安全。 总之,CORDYS+BOP+业务运营平台技术方案提供了一套完整的解决方案,...

Global site tag (gtag.js) - Google Analytics