com.ebt.platform.utility.WebServiceCaller.java Source code

Java tutorial

Introduction

Here is the source code for com.ebt.platform.utility.WebServiceCaller.java

Source

package com.ebt.platform.utility;

import java.io.ByteArrayInputStream;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

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;

public class WebServiceCaller {
    private static final String USER = "CASClient";
    private static final String SIGN = "adbb683698744f8643d144091a71e040";

    public static String CallCasWebService(String xml) {
        PostMethod postMethod = new PostMethod("http://ws.e-baotong.cn:8085/CASServer.asmx?wsdl");
        String responseString = null;
        try {
            byte[] b = xml.getBytes("utf-8");
            InputStream inS = new ByteArrayInputStream(b, 0, b.length);
            RequestEntity req = new InputStreamRequestEntity(inS, b.length, "text/xml; charset=utf-8");
            postMethod.setRequestEntity(req);

            HttpClient httpClient = new HttpClient();
            int statusCode = httpClient.executeMethod(postMethod);
            if (statusCode == 200) {
                responseString = new String(postMethod.getResponseBodyAsString().getBytes("ISO-8859-1"), "UTF-8");
                System.out.println("WebService??====" + responseString);
            } else {
                System.out.println("WebService??" + statusCode);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return responseString;
    }

    private static String CallDatv2WebService(String xml) {
        PostMethod postMethod = new PostMethod("http://datv2.e-baotong.cn:9089/GetVersionData.asmx?wsdl");
        String responseString = null;
        try {
            byte[] b = xml.getBytes("utf-8");
            InputStream inS = new ByteArrayInputStream(b, 0, b.length);
            RequestEntity req = new InputStreamRequestEntity(inS, b.length, "text/xml; charset=utf-8");
            postMethod.setRequestEntity(req);

            HttpClient httpClient = new HttpClient();
            int statusCode = httpClient.executeMethod(postMethod);
            if (statusCode == 200) {
                responseString = new String(postMethod.getResponseBodyAsString().getBytes("ISO-8859-1"), "UTF-8");
                System.out.println("WebService??====" + responseString);
            } else {
                System.out.println("WebService??" + statusCode);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return responseString;
    }

    public static String getCasRequestXml(String json) throws IOException {
        StringBuilder soapBuilder = new StringBuilder();
        soapBuilder.append(
                "<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/'>");
        soapBuilder.append("<soap:Header>");
        soapBuilder.append("<EBTSoapHeader xmlns='http://songlink.org/'>");
        soapBuilder.append("<User>" + USER + "</User>");
        soapBuilder.append("<Sign>" + SIGN + "</Sign>");
        soapBuilder.append("</EBTSoapHeader>");
        soapBuilder.append("</soap:Header>");
        soapBuilder.append("<soap:Body>");
        soapBuilder.append("<RequestDeviceService xmlns='http://songlink.org/'>");
        soapBuilder.append("<strJson>" + json + "</strJson>");
        soapBuilder.append("</RequestDeviceService>");
        soapBuilder.append("</soap:Body>");
        soapBuilder.append("</soap:Envelope>");
        return soapBuilder.toString();
    }

    private static String getRequestXml(String json) throws IOException {
        StringBuilder soapBuilder = new StringBuilder();
        soapBuilder.append(
                "<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/'>");
        soapBuilder.append("<soap:Header>");
        soapBuilder.append("<EBTSoapHeader xmlns='http://songlink.org/'>");
        soapBuilder.append("<User>" + USER + "</User>");
        soapBuilder.append("<Sign>" + SIGN + "</Sign>");
        soapBuilder.append("</EBTSoapHeader>");
        soapBuilder.append("</soap:Header>");
        soapBuilder.append("<soap:Body>");
        soapBuilder.append("<RequestDeviceService xmlns='http://songlink.org/'>");
        soapBuilder.append("<strJson>" + json + "</strJson>");
        soapBuilder.append("</RequestDeviceService>");
        soapBuilder.append("</soap:Body>");
        soapBuilder.append("</soap:Envelope>");
        return soapBuilder.toString();
    }

    private static String getRequestXml(String opName, Map<String, String> map) throws IOException {
        StringBuilder soapBuilder = new StringBuilder();
        soapBuilder.append(
                "<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/'>");
        soapBuilder.append("<soap:Header>");
        soapBuilder.append("<EBTSoapHeader xmlns='http://res.e-bao.cn/'>");
        soapBuilder.append("<User>" + USER + "</User>");
        soapBuilder.append("<Sign>" + SIGN + "</Sign>");
        soapBuilder.append("</EBTSoapHeader>");
        soapBuilder.append("</soap:Header>");
        soapBuilder.append("<soap:Body>");
        soapBuilder.append("<" + opName + " xmlns='http://res.e-bao.cn/'>");
        for (Map.Entry<String, String> entry : map.entrySet()) {
            soapBuilder.append("<" + entry.getKey() + ">" + entry.getValue() + "</" + entry.getKey() + ">");
        }
        soapBuilder.append("</" + opName + ">");
        soapBuilder.append("</soap:Body>");
        soapBuilder.append("</soap:Envelope>");
        return soapBuilder.toString();
    }

    /**
     * Get ChannelCompany code
     * @return
     * @throws IOException
     */
    public static String GetChannelCompany() throws IOException {
        String json = String.format("{\"ServiceName\":\"GetChannelCompanyJson\",\"Parameters\":["
                + "{\"Name\":\"ChnlCategory\",\"Value\":\"insurance\"},"
                + "{\"Name\":\"ChnlParent\",\"Value\":\"\"}]}");
        System.out.println("GetChannelCompany() json entity:" + json);
        return CallCasWebService(getRequestXml(json));
    }

    /**
     * Get BrandProductList code
     * @return
     * @throws IOException
     */
    public static String GetBrandProductList(String strBrandID) throws IOException {

        Map<String, String> pramsMap = new HashMap<String, String>();
        pramsMap.put("strBrandID", strBrandID);

        System.out.println("GetChannelCompany() json entity:" + pramsMap);
        return CallDatv2WebService(getRequestXml("GetBrandProductList", pramsMap));
    }

    public static String getTKRequestXml(String TransrCode, String AgentChannel, String PolicyNo, String TransrDate,
            String TransrTime) throws IOException {
        StringBuilder soapBuilder = new StringBuilder();
        soapBuilder.append("<?xml version='1.0' encoding='GBK'?>");
        soapBuilder.append(
                "<PolicyQuery xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:CIXML='http://www.cixml.com'>");
        soapBuilder.append("<TranBaseInfo>");
        soapBuilder.append("<TransrChannel>FH</TransrChannel>");
        soapBuilder.append("<TransrDate>" + TransrDate + "</TransrDate>");
        soapBuilder.append("<TransrTime>" + TransrTime + "</TransrTime>");
        soapBuilder.append("<FuncFlag>ST002</FuncFlag>");
        soapBuilder.append("<TransrCode>" + TransrCode + "</TransrCode>");
        soapBuilder.append("<AgentChannel>1137000003/" + AgentChannel + "</AgentChannel>");
        soapBuilder.append("</TranBaseInfo>");
        soapBuilder.append("<TranKeyInfo>");
        soapBuilder.append("<PolicyNo>" + PolicyNo + "</PolicyNo>");
        soapBuilder.append("</TranKeyInfo>");
        soapBuilder.append("</PolicyQuery>");
        return soapBuilder.toString();
    }

    public static String getTKPostRequestXml(Long TransrCode, String AgentChannel, String riskCoverageNum,
            String premium, String sumIns) throws IOException {
        StringBuilder soapBuilder = new StringBuilder();
        soapBuilder.append("<?xml version='1.0' encoding='UTF-8'?>");
        soapBuilder.append("<Policy xmlns:CIXML='http://www.cixml.com'>");
        soapBuilder.append("<TranBaseInfo>");
        soapBuilder.append("<TransrChannel>FH</TransrChannel>");
        soapBuilder.append("<TransrDate>2016-04-18</TransrDate>");
        soapBuilder.append("<TransrTime>18:31:06</TransrTime>");
        soapBuilder.append("<FuncFlag>ST001</FuncFlag>");
        soapBuilder.append("<TransrCode>" + TransrCode + "</TransrCode>");
        soapBuilder.append("<AgentChannel>1137000003/" + AgentChannel + "</AgentChannel>");
        soapBuilder.append("</TranBaseInfo>");
        soapBuilder.append("<KeyInfo>");
        soapBuilder.append("<coyNum>C</coyNum>");
        soapBuilder.append("<printStyle>0</printStyle>");
        soapBuilder.append("<confirmationNO>2016000000</confirmationNO>");
        soapBuilder.append("<standardPremiumEstimate>50</standardPremiumEstimate>");
        soapBuilder.append("<POS>2</POS>");
        soapBuilder.append("<transferAmount>5252.69</transferAmount>");
        soapBuilder.append("<temporaryAmount/>");
        soapBuilder.append("</KeyInfo>");
        soapBuilder.append("<BaseInfo>");
        soapBuilder.append("<plcyType>A32</plcyType>");
        soapBuilder.append("<agentSubComName>???</agentSubComName>");
        soapBuilder.append("<agentBranchName>???</agentBranchName>");
        soapBuilder.append("<agentQuafNum>20060737010009000838</agentQuafNum>");
        soapBuilder.append("<agentQuafEndDate/>");
        soapBuilder.append("<agentIdNo>372801196704124021</agentIdNo>");
        soapBuilder.append("<agentSex>F</agentSex>");
        soapBuilder.append("<agentBirthDay>19670412</agentBirthDay>");
        soapBuilder.append("<agentDegree/>");
        soapBuilder.append("<agentPhone/>");
        soapBuilder.append("<agentMobile>0531-81851976</agentMobile>");
        soapBuilder.append("<agentJoinDate>20081121</agentJoinDate>");
        soapBuilder.append("<agentOutworkDate/>");
        soapBuilder.append("<agentStateFlag>10</agentStateFlag>");
        soapBuilder.append("<agentComNum>14A1350500</agentComNum>");
        soapBuilder.append("<agentNum>1122</agentNum>");
        soapBuilder.append("<agentName></agentName>");
        soapBuilder.append("<collectMethod>D</collectMethod>");
        soapBuilder.append("<collectMethodB>D</collectMethodB>");
        soapBuilder.append("<bank>02</bank>");
        soapBuilder.append("<bankCode>ACB-JN</bankCode>");
        soapBuilder.append("<bankAccount>34324324324324234324</bankAccount>");
        soapBuilder.append("<accountName>?</accountName>");
        soapBuilder.append("<isAutoLoan>1</isAutoLoan>");
        soapBuilder.append("<payablePremium>5252.69</payablePremium>");
        soapBuilder.append("<prepayPremium>5252.69</prepayPremium>");
        soapBuilder.append("</BaseInfo>");
        soapBuilder.append("<Applicant>");
        soapBuilder.append("<cltName>?</cltName>");
        soapBuilder.append("<cltSex>M</cltSex>");
        soapBuilder.append("<married/>");
        soapBuilder.append("<securityType>13</securityType>");
        soapBuilder.append("<securityNum>54523423423423423432</securityNum>");
        soapBuilder.append("<securityExpired>99991231</securityExpired>");
        soapBuilder.append("<nationality>36</nationality>");
        soapBuilder.append("<birthday>19900528</birthday>");
        soapBuilder.append("<diploma/>");
        soapBuilder.append("<homeAddress>?????</homeAddress>");
        soapBuilder.append("<post>324234</post>");
        soapBuilder.append("<telephone/>");
        soapBuilder.append("<mobile>15523423423</mobile>");
        soapBuilder.append("<secOccp>0803001</secOccp>");
        soapBuilder.append("<occupationWorkType>()</occupationWorkType>");
        soapBuilder.append("<occupationClass>2</occupationClass>");
        soapBuilder.append(
                "<companyAddress>???</companyAddress>");
        soapBuilder.append("<position/>");
        soapBuilder.append("<height>178</height>");
        soapBuilder.append("<weight>66</weight>");
        soapBuilder.append("<email/>");
        soapBuilder.append("<income>1</income>");
        soapBuilder.append("</Applicant>");
        soapBuilder.append("<Insureds>");
        soapBuilder.append("<InsuredCount>1</InsuredCount>");
        soapBuilder.append("<Insured>");
        soapBuilder.append("<isApplicant>Y</isApplicant>");
        soapBuilder.append("<tradeExperience>N</tradeExperience>");
        soapBuilder.append("<appRelation>01</appRelation>");
        soapBuilder.append("<cltName>?</cltName>");
        soapBuilder.append("<cltSex>M</cltSex>");
        soapBuilder.append("<birthday>19900528</birthday>");
        soapBuilder.append("<securityType>13</securityType>");
        soapBuilder.append("<securityNum>54523423423423423432</securityNum>");
        soapBuilder.append("<securityExpired>99991231</securityExpired>");
        soapBuilder.append("<nationality>36</nationality>");
        soapBuilder.append("<married/>");
        soapBuilder.append("<diploma/>");
        soapBuilder.append("<homeAddress>?????</homeAddress>");
        soapBuilder.append("<post>324234</post>");
        soapBuilder.append("<telephone/>");
        soapBuilder.append("<mobile>15523423423</mobile>");
        soapBuilder.append("<email/>");
        soapBuilder.append("<secOccp>0803001</secOccp>");
        soapBuilder.append("<occupationWorkType>()</occupationWorkType>");
        soapBuilder.append("<occupationClass>2</occupationClass>");
        soapBuilder.append(
                "<companyAddress>???</companyAddress>");
        soapBuilder.append("<position/>");
        soapBuilder.append("<healthUniform>NIL</healthUniform>");
        soapBuilder.append("<abnormityUniform></abnormityUniform>");
        soapBuilder.append("<medicalSocialSecurity>Y</medicalSocialSecurity>");
        soapBuilder.append("<Health>");
        soapBuilder.append("<purchasedInsurance>0</purchasedInsurance>");
        soapBuilder.append("<purchasedCompany/>");
        soapBuilder.append("<purchasedRiskName/>");
        soapBuilder.append("<purchasedPremium/>");
        soapBuilder.append("<purchasedDate/>");
        soapBuilder.append("<purchasedAddFee/>");
        soapBuilder.append("<purchaseAddFeeReason/>");
        soapBuilder.append("<purchasedCompany2/>");
        soapBuilder.append("<purchasedRiskName2/>");
        soapBuilder.append("<purchasedPremium2/>");
        soapBuilder.append("<purchasedDate2/>");
        soapBuilder.append("<purchasedAddFee2/>");
        soapBuilder.append("<purchaseAddFeeReason2/>");
        soapBuilder.append("<hasOccurTermination>0</hasOccurTermination>");
        soapBuilder.append("<hasBeenClaims>0</hasBeenClaims>");
        soapBuilder.append("<hasLicenseOfDriver>0</hasLicenseOfDriver>");
        soapBuilder.append("<typeOfLicense/>");
        soapBuilder.append("<hasOccurTrafficAccidents/>");
        soapBuilder.append("<hasJoinDangerousSports>0</hasJoinDangerousSports>");
        soapBuilder.append("<height>178</height>");
        soapBuilder.append("<weight>66</weight>");
        soapBuilder.append("<recentStatus>0</recentStatus>");
        soapBuilder.append("<recentMedicalTreatment>0</recentMedicalTreatment>");
        soapBuilder.append("<recentPhysicalExam>0</recentPhysicalExam>");
        soapBuilder.append("<hasBeenHospital>0</hasBeenHospital>");
        soapBuilder.append("<hospitalName/>");
        soapBuilder.append("<isMental>0</isMental>");
        soapBuilder.append("<isFacialDisease>0</isFacialDisease>");
        soapBuilder.append("<isCirculatoryDisease>0</isCirculatoryDisease>");
        soapBuilder.append("<isRespiratoryDisease>0</isRespiratoryDisease>");
        soapBuilder.append("<isDigestiveDisease>0</isDigestiveDisease>");
        soapBuilder.append("<isGenitalDisease>0</isGenitalDisease>");
        soapBuilder.append("<isEndocrineDisease>0</isEndocrineDisease>");
        soapBuilder.append("<isCancer>0</isCancer>");
        soapBuilder.append("<isCongenitalDesease>0</isCongenitalDesease>");
        soapBuilder.append("<isOtherDesease>0</isOtherDesease>");
        soapBuilder.append("<isDisability>0</isDisability>");
        soapBuilder.append("<isSmoking>0</isSmoking>");
        soapBuilder.append("<amountOfSomkingPerDay/>");
        soapBuilder.append("<ageOfSomked/>");
        soapBuilder.append("<isDrinking>0</isDrinking>");
        soapBuilder.append("<isDrinkBeer/>");
        soapBuilder.append("<isDrinkwine/>");
        soapBuilder.append("<isLiquor/>");
        soapBuilder.append("<amountOfDrinkPerDay/>");
        soapBuilder.append("<ageOfDrink/>");
        soapBuilder.append("<isFamilyMedicalHistory>0</isFamilyMedicalHistory>");
        soapBuilder.append("<isPregnancy>0</isPregnancy>");
        soapBuilder.append("<periodOfPregnancy/>");
        soapBuilder.append("<isPain>0</isPain>");
        soapBuilder.append("<isGynecologicalDisease>0</isGynecologicalDisease>");
        soapBuilder.append("<isInfertility>0</isInfertility>");
        soapBuilder.append("<childIsCongenitalDesease>0</childIsCongenitalDesease>");
        soapBuilder.append("<childBornHeight/>");
        soapBuilder.append("<childBornWeight/>");
        soapBuilder.append("<insuredAnnualIncome>45</insuredAnnualIncome>");
        soapBuilder.append("<gongXinIncomeInsured>1</gongXinIncomeInsured>");
        soapBuilder.append("<siYingIncomeInsured/>");
        soapBuilder.append("<geTiIncomeInsured/>");
        soapBuilder.append("<otherIncomeInsured/>");
        soapBuilder.append("<otherIncomeInsuredRemarks/>");
        soapBuilder.append("<isLoanInsured>0</isLoanInsured>");
        soapBuilder.append("<loanAmountInsured/>");
        soapBuilder.append("<loanInsuredRemarks/>");
        soapBuilder.append("<applicantAnnualIncome>45</applicantAnnualIncome>");
        soapBuilder.append("<gongXinInvestor>1</gongXinInvestor>");
        soapBuilder.append("<siYingInvestor/>");
        soapBuilder.append("<geTiInvestor/>");
        soapBuilder.append("<qiTaInvestor/>");
        soapBuilder.append("<qitaInvestorRemarks/>");
        soapBuilder.append("<isLoanInvestor>0</isLoanInvestor>");
        soapBuilder.append("<loadAmountInvestor/>");
        soapBuilder.append("<loadInvestorRemarks/>");
        soapBuilder.append("<remarks>  </remarks>");
        soapBuilder.append(
                "<otherRemarks>  </otherRemarks>");
        soapBuilder.append("</Health>");
        soapBuilder.append("<Beneficiarys>");
        soapBuilder.append("<BeneficiaryCount>1</BeneficiaryCount>");
        soapBuilder.append("<Beneficiary>");
        soapBuilder.append("<cltName>?</cltName>");
        soapBuilder.append("<cltSex>M</cltSex>");
        soapBuilder.append("<birthday>19900528</birthday>");
        soapBuilder.append("<securityType>13</securityType>");
        soapBuilder.append("<securityNum>54523423423423423432</securityNum>");
        soapBuilder.append("<relation>04</relation>");
        soapBuilder.append("<benefitType>D</benefitType>");
        soapBuilder.append("<benefitSort>1</benefitSort>");
        soapBuilder.append("<benefitProport>100</benefitProport>");
        soapBuilder.append("</Beneficiary>");
        soapBuilder.append("</Beneficiarys>");
        soapBuilder.append("<Risks>");
        soapBuilder.append("<RiskCount>3</RiskCount>");
        soapBuilder.append("<Risk>");
        soapBuilder.append("<riskCoverageNum>" + riskCoverageNum + "</riskCoverageNum>");
        soapBuilder.append("<riskRiderNum/>");
        soapBuilder.append("<sumIns>" + sumIns + "</sumIns>");
        soapBuilder.append("<premium>" + premium + "</premium>");
        soapBuilder.append("<lmpcnt/>");
        soapBuilder.append("<sum/>");
        soapBuilder.append("<level/>");
        soapBuilder.append("<pcesstrm>3</pcesstrm>");
        soapBuilder.append("<pcessage/>");
        soapBuilder.append("<riskterm>30</riskterm>");
        soapBuilder.append("<riskage/>");
        soapBuilder.append("<beneterm/>");
        soapBuilder.append("<beneage/>");
        soapBuilder.append("<bappmeth/>");
        soapBuilder.append("<zrpayopt/>");
        soapBuilder.append("<bcesage/>");
        soapBuilder.append("<bcespcnt/>");
        soapBuilder.append("<bcestype/>");
        soapBuilder.append("<longfreq/>");
        soapBuilder.append("<longperiod/>");
        soapBuilder.append("</Risk>");
        soapBuilder.append("<Risk>");
        soapBuilder.append("<riskCoverageNum>A32P</riskCoverageNum>");
        soapBuilder.append("<riskRiderNum>R51P</riskRiderNum>");
        soapBuilder.append("<sumIns>100000</sumIns>");
        soapBuilder.append("<premium>2189</premium>");
        soapBuilder.append("<lmpcnt/>");
        soapBuilder.append("<sum/>");
        soapBuilder.append("<level/>");
        soapBuilder.append("<pcesstrm>3</pcesstrm>");
        soapBuilder.append("<pcessage/>");
        soapBuilder.append("<riskterm>30</riskterm>");
        soapBuilder.append("<riskage/>");
        soapBuilder.append("<beneterm/>");
        soapBuilder.append("<beneage/>");
        soapBuilder.append("<bappmeth/>");
        soapBuilder.append("<zrpayopt/>");
        soapBuilder.append("<bcesage/>");
        soapBuilder.append("<bcespcnt/>");
        soapBuilder.append("<bcestype/>");
        soapBuilder.append("<longfreq/>");
        soapBuilder.append("<longperiod/>");
        soapBuilder.append("</Risk>");
        soapBuilder.append("<Risk>");
        soapBuilder.append("<riskCoverageNum>A32P</riskCoverageNum>");
        soapBuilder.append("<riskRiderNum>R52P</riskRiderNum>");
        soapBuilder.append("<sumIns>100</sumIns>");
        soapBuilder.append("<premium>190.3</premium>");
        soapBuilder.append("<lmpcnt/>");
        soapBuilder.append("<sum/>");
        soapBuilder.append("<level/>");
        soapBuilder.append("<pcesstrm>3</pcesstrm>");
        soapBuilder.append("<pcessage/>");
        soapBuilder.append("<riskterm>30</riskterm>");
        soapBuilder.append("<riskage/>");
        soapBuilder.append("<beneterm/>");
        soapBuilder.append("<beneage/>");
        soapBuilder.append("<bappmeth/>");
        soapBuilder.append("<zrpayopt/>");
        soapBuilder.append("<bcesage/>");
        soapBuilder.append("<bcespcnt/>");
        soapBuilder.append("<bcestype/>");
        soapBuilder.append("<longfreq/>");
        soapBuilder.append("<longperiod/>");
        soapBuilder.append("</Risk>");
        soapBuilder.append("</Risks>");
        soapBuilder.append("</Insured>");
        soapBuilder.append("</Insureds>");
        soapBuilder.append("</Policy>");
        return soapBuilder.toString();
    }

    public static String CallTKWebService(String xml, String webservicePath) {
        PostMethod postMethod = new PostMethod(webservicePath);
        String responseString = null;
        String key = "HOCMojuo1SY=";
        try {
            byte[] b = Base64.encode(DESCoder.encrypt(xml.getBytes("GBK"), key)).getBytes("UTF-8");
            InputStream inS = new ByteArrayInputStream(b, 0, b.length);
            RequestEntity req = new InputStreamRequestEntity(inS, b.length, "text/xml; charset=UTF-8");
            postMethod.setRequestEntity(req);

            HttpClient httpClient = new HttpClient();
            int statusCode = httpClient.executeMethod(postMethod);
            if (statusCode == 200) {
                //String teString = "Rc8vPD/7VKO5hmhaSEFIs+5Y4+vxCWsgxJRd2T3vtFuyOoJwklhLP+Rom/FPTqnA7XUqxV+tVaOL jr5oD9Kl4YgoVY/VedW7zYzSr95IIs1lB5J8PFws6s2M0q/eSCLNJx2pIfGaAoilvQKp0zzxoQxt 1JFTWwxNzO/kSu5IAj3uhQghuFBSjL8XDayI0z+xf2GfBm0cGCAZsuHXFZZQCn6cqTr7r8rBKKjH Q8nBkewMSwkiOcgqayiox0PJwZHslrOc+35gnEgy9mfmvxgJkgzXjdJsSjlJ4pQvxUHV8OmlA5hY pWLBIFR/4cyH6PY+BkDbVHv07XhjJXJymBAFn4tlHQjkHsKWrYeQWedxU7D1/rUeeOl27kdLMNCB i6OsAhHHQPK5PBqL2H/z3clPHyD6UaNQIHEf/wfQy6xZYmGaqXVgjZ2hIgGWGreKSEIJEzBvIFZm qCMMhE1nM/PAkemyUv9YJr0cvwvQgQ50f26rmc1VjVgnp7+LHpMEPs7AQxl+e3o9WaPaVh24E7A/ HEdLMNCBi6OsPQy6Sec0txkEtMxfrDjcHYxmHlzEujar";
                byte[] responses = Base64.decode(postMethod.getResponseBodyAsString());
                //byte[] responses = Base64.decode(teString);
                responseString = new String(DESCoder.decrypt(responses, key), "UTF-8");
                System.out.println("WebService??====" + responseString);
            } else {
                System.out.println("WebService??" + statusCode);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return responseString;
    }

    public static String getERPLoginQueryXml(String userID, String name, String psw) throws IOException {
        StringBuilder soapBuilder = new StringBuilder();
        soapBuilder.append(
                "<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/'>");
        soapBuilder.append("<soap:Header>");
        soapBuilder.append("<OSAPHeader xmlns='http://tempuri.org/'>");
        soapBuilder.append("<UserID>" + userID + "</UserID>");
        soapBuilder.append("<PassWord>admin</PassWord>");
        soapBuilder.append("</OSAPHeader>");
        soapBuilder.append("</soap:Header>");
        soapBuilder.append("<soap:Body>");
        soapBuilder.append("<LoginQuery xmlns='http://tempuri.org/'>");
        soapBuilder.append("<name>" + name + "</name>");
        soapBuilder.append("<psw>" + psw + "</psw>");
        soapBuilder.append("</LoginQuery>");
        soapBuilder.append("</soap:Body>");
        soapBuilder.append("</soap:Envelope>");
        return soapBuilder.toString();
    }

    public static String CallERPWebService(String xml, String webservicePath) {
        PostMethod postMethod = new PostMethod(webservicePath);
        String responseString = null;
        try {
            byte[] b = xml.getBytes("utf-8");
            InputStream inS = new ByteArrayInputStream(b, 0, b.length);
            RequestEntity req = new InputStreamRequestEntity(inS, b.length, "text/xml; charset=utf-8");
            postMethod.setRequestEntity(req);

            HttpClient httpClient = new HttpClient();
            int statusCode = httpClient.executeMethod(postMethod);
            if (statusCode == 200) {
                responseString = new String(postMethod.getResponseBodyAsString().getBytes("ISO-8859-1"), "UTF-8");
                System.out.println("WebService??====" + responseString);
            } else {
                System.out.println("WebService??" + statusCode);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return responseString;
    }

    public static String getUacLoginXml(String name, String psw) throws IOException {
        StringBuilder soapBuilder = new StringBuilder();
        soapBuilder.append(
                "<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/'>");
        soapBuilder.append("<soap:Header>");
        soapBuilder.append("<EBTSoapHeader xmlns='http://www.songlink.uac.cn/'>");
        soapBuilder.append("<User>" + USER + "</User>");
        soapBuilder.append("<Sign>" + SIGN + "</Sign>");
        soapBuilder.append("</EBTSoapHeader>");
        soapBuilder.append("</soap:Header>");
        soapBuilder.append("<soap:Body>");
        soapBuilder.append("<RequestSecretDeviceService xmlns='http://www.songlink.uac.cn/'>");
        soapBuilder.append("<strJson>{\"ServiceName\":\"Login\",\"Parameters\":[{\"name\":\"UserName\",\"value\":"
                + name + "},{\"name\":\"PassWord\",\"value\":" + psw + "}]}</strJson>");
        soapBuilder.append("</RequestSecretDeviceService>");
        soapBuilder.append("</soap:Body>");
        soapBuilder.append("</soap:Envelope>");
        return soapBuilder.toString();
    }

    public static String getUacRequestXml(String json) throws IOException {
        StringBuilder soapBuilder = new StringBuilder();
        soapBuilder.append(
                "<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/'>");
        soapBuilder.append("<soap:Header>");
        soapBuilder.append("<EBTSoapHeader xmlns='http://www.songlink.uac.cn/'>");
        soapBuilder.append("<User>" + USER + "</User>");
        soapBuilder.append("<Sign>" + SIGN + "</Sign>");
        soapBuilder.append("</EBTSoapHeader>");
        soapBuilder.append("</soap:Header>");
        soapBuilder.append("<soap:Body>");
        soapBuilder.append("<RequestSecretDeviceService xmlns='http://www.songlink.uac.cn/'>");
        soapBuilder.append("<strJson>" + json + "</strJson>");
        soapBuilder.append("</RequestSecretDeviceService>");
        soapBuilder.append("</soap:Body>");
        soapBuilder.append("</soap:Envelope>");
        return soapBuilder.toString();
    }

    public static String CallUacWebService(String xml) {
        PostMethod postMethod = new PostMethod("http://UACServer.e-bao.cn:8086/UACService.asmx");
        String responseString = null;
        try {
            byte[] b = xml.getBytes("utf-8");
            InputStream inS = new ByteArrayInputStream(b, 0, b.length);
            RequestEntity req = new InputStreamRequestEntity(inS, b.length, "text/xml; charset=utf-8");
            postMethod.setRequestEntity(req);

            HttpClient httpClient = new HttpClient();
            int statusCode = httpClient.executeMethod(postMethod);
            if (statusCode == 200) {
                responseString = new String(postMethod.getResponseBodyAsString().getBytes("ISO-8859-1"), "UTF-8");
                System.out.println("WebService??====" + responseString);
            } else {
                System.out.println("WebService??" + statusCode);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return responseString;
    }

    /**
     * ?Json?UAC?
     * @param json
     * @return
     * @throws IOException
     */
    public static String CallUacWebServiceWithJsonParam(String json) throws IOException {
        PostMethod postMethod = new PostMethod("http://UACServer.e-bao.cn:8086/UACService.asmx");
        String responseString = null;
        String xml = getUacRequestXml(json);
        try {
            byte[] b = xml.getBytes("utf-8");
            InputStream inS = new ByteArrayInputStream(b, 0, b.length);
            RequestEntity req = new InputStreamRequestEntity(inS, b.length, "text/xml; charset=utf-8");
            postMethod.setRequestEntity(req);

            HttpClient httpClient = new HttpClient();
            int statusCode = httpClient.executeMethod(postMethod);
            if (statusCode == 200) {
                responseString = new String(postMethod.getResponseBodyAsString().getBytes("ISO-8859-1"), "UTF-8");
                System.out.println("WebService??====" + responseString);
            } else {
                System.out.println("WebService??" + statusCode);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return responseString;
    }

    public static String getSMSRequestXml(String json) throws IOException {
        StringBuilder soapBuilder = new StringBuilder();
        soapBuilder.append(
                "<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/'>");
        soapBuilder.append("<soap:Header>");
        soapBuilder.append("<EBTSoapHeader xmlns='http://sms.yibaoyun.cn/'>");
        soapBuilder.append("<User>" + USER + "</User>");
        soapBuilder.append("<Sign>" + SIGN + "</Sign>");
        soapBuilder.append("</EBTSoapHeader>");
        soapBuilder.append("</soap:Header>");
        soapBuilder.append("<soap:Body>");
        soapBuilder.append("<SendSMS xmlns='http://sms.yibaoyun.cn/'>");
        soapBuilder.append("<strJson>" + json + "</strJson>");
        soapBuilder.append("</SendSMS>");
        soapBuilder.append("</soap:Body>");
        soapBuilder.append("</soap:Envelope>");
        return soapBuilder.toString();
    }

    /**
     * ?Json?SMS?
     * @param json
     * @return
     * @throws IOException
     */
    public static String CallSMSWebServiceWithJsonParam(String json) throws IOException {
        PostMethod postMethod = new PostMethod("http://sms.e-baotong.cn:8085/EBaoSMS.asmx");
        String responseString = null;
        String xml = getSMSRequestXml(json);
        try {
            byte[] b = xml.getBytes("utf-8");
            InputStream inS = new ByteArrayInputStream(b, 0, b.length);
            RequestEntity req = new InputStreamRequestEntity(inS, b.length, "text/xml; charset=utf-8");
            postMethod.setRequestEntity(req);

            HttpClient httpClient = new HttpClient();
            int statusCode = httpClient.executeMethod(postMethod);
            if (statusCode == 200) {
                responseString = new String(postMethod.getResponseBodyAsString().getBytes("ISO-8859-1"), "UTF-8");
                System.out.println("WebService??====" + responseString);
            } else {
                System.out.println("WebService??" + statusCode);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return responseString;
    }

}