<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Sealyu

    --- 博客已遷移至: http://www.sealyu.com/blog

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      618 隨筆 :: 87 文章 :: 225 評(píng)論 :: 0 Trackbacks

    用到的jar包有:
        commons-codec-1.3.jar
        commons-httpclient-3.0.jar
        commons-logging-1.0.4.jar


    具體流程大致這樣:

            
            String soapRequestData 
    = "<?xml version=""1.0"" encoding=""utf-8""?>" +
            
    "<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">" +
              "<soap12:Body>" +
               
    " <qqCheckOnline xmlns=""http://WebXml.com.cn/"">" +
              "    <qqCode>349104641</qqCode>" +
             
    "   </qqCheckOnline>" +
            
    "  </soap12:Body>" +
            
    "</soap12:Envelope>";
            
            System.out.println(soapRequestData);


        
    //PostMethod postMethod = new PostMethod("http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl");
        
        PostMethod postMethod 
    = new PostMethod("http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl");

       
    // 然后把Soap請求數(shù)據(jù)添加到PostMethod中


        
    byte[] b = soapRequestData.getBytes("utf-8");
        InputStream is 
    = new ByteArrayInputStream(b,0,b.length);
        RequestEntity re 
    = new InputStreamRequestEntity(is,b.length,"application/soap+xml; charset=utf-8");
        postMethod.setRequestEntity(re); 
        
        
    //最后生成一個(gè)HttpClient對(duì)象,并發(fā)出postMethod請求

        HttpClient httpClient 
    = new HttpClient();
        
    int statusCode = httpClient.executeMethod(postMethod);
        String soapResponseData 
    =  postMethod.getResponseBodyAsString();
            
            
        System.out.print(soapResponseData);



    動(dòng)態(tài)構(gòu)造調(diào)用串的話如下實(shí)現(xiàn):


        
    private String tns;
        
    private String methodName;
        
    private String wsdlLocation;
        
    private String soapResponseData;

    private int invoke(Map<String, String> patameterMap) throws Exception {
            PostMethod postMethod 
    = new PostMethod(wsdlLocation);
            String soapRequestData 
    = buildRequestData(patameterMap);

            
    byte[] bytes = soapRequestData.getBytes("utf-8");
            InputStream inputStream 
    = new ByteArrayInputStream(bytes, 0,
                    bytes.length);
            RequestEntity requestEntity 
    = new InputStreamRequestEntity(inputStream,
                    bytes.length, 
    "application/soap+xml; charset=utf-8");
            postMethod.setRequestEntity(requestEntity);

            HttpClient httpClient 
    = new HttpClient();
            
    int statusCode = httpClient.executeMethod(postMethod);
            soapResponseData 
    = postMethod.getResponseBodyAsString();
            
    return statusCode;
        }


        
    private String buildRequestData(Map<String, String> patameterMap) {
            StringBuffer soapRequestData 
    = new StringBuffer();
            soapRequestData.append(
    "<?xml version=""1.0"" encoding=""utf-8""?>");
            soapRequestData
                    .append(
    "<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">");
            soapRequestData.append("<soap12:Body>");
            soapRequestData.append(
    "<" + methodName + " xmlns=""" + tns + """>");
            Set
    <String> nameSet = patameterMap.keySet();
            
    for (String name : nameSet) {
                soapRequestData.append(
    "<" + name + ">" + patameterMap.get(name)
                        
    + "</" + name + ">");
            }

            soapRequestData.append(
    "</" + methodName + ">");
            soapRequestData.append(
    "</soap12:Body>");
            soapRequestData.append(
    "</soap12:Envelope>");

            
    return soapRequestData.toString();
        }
    posted on 2010-07-27 14:42 seal 閱讀(1964) 評(píng)論(0)  編輯  收藏 所屬分類: web
    主站蜘蛛池模板: 玖玖在线免费视频| 一级特级aaaa毛片免费观看| 亚洲午夜免费视频| 亚洲AV无码乱码国产麻豆 | 777亚洲精品乱码久久久久久 | 亚洲人成日本在线观看| 国产精品久久久久久久久免费| 久久久亚洲AV波多野结衣| 国产成人精品免费视| 亚洲精品无码不卡在线播放| 日韩高清在线免费观看| 精品女同一区二区三区免费播放| 亚洲不卡无码av中文字幕| 一级做性色a爰片久久毛片免费| 国产精品亚洲mnbav网站| 西西人体免费视频| 亚洲人成在线电影| 四虎永久在线观看免费网站网址 | 亚洲视频一区二区在线观看| 国色精品卡一卡2卡3卡4卡免费| 亚洲日产2021三区在线 | 成年在线网站免费观看无广告 | 免费观看91视频| 亚洲国产精品成人精品小说| 免费高清小黄站在线观看| 一区二区三区免费在线视频| 亚洲va久久久噜噜噜久久男同 | 免费a级毛片无码av| 成全视频在线观看免费| 亚洲精品在线电影| 成在线人永久免费视频播放| 国产免费久久精品99久久| 亚洲精品日韩专区silk| 免费人妻av无码专区| 久久国产乱子伦精品免费看| 亚洲综合色丁香婷婷六月图片| 中文字幕日韩亚洲| 久久久久久国产a免费观看黄色大片| 视频一区在线免费观看| 亚洲影院在线观看| 亚洲日韩在线第一页|