<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 評論 :: 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); 
        
        
    //最后生成一個HttpClient對象,并發(fā)出postMethod請求

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



    動態(tài)構(gòu)造調(diào)用串的話如下實現(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) 評論(0)  編輯  收藏 所屬分類: web
    主站蜘蛛池模板: 色吊丝永久在线观看最新免费| 久久免费精品一区二区| 91在线品视觉盛宴免费| 久久精品国产亚洲77777| 久久久久久AV无码免费网站| 黑人精品videos亚洲人| 在线观看人成视频免费无遮挡| 国产aⅴ无码专区亚洲av麻豆 | 国产成人无码综合亚洲日韩| 伊人久久大香线蕉免费视频| 国产亚洲高清不卡在线观看| 久久国产乱子伦精品免费不卡| 亚洲成AV人片在线播放无码| 91av免费观看| 亚洲最大中文字幕无码网站| 四虎在线视频免费观看| 青青免费在线视频| 亚洲欧洲自拍拍偷精品 美利坚| 成人妇女免费播放久久久| 亚洲国产精品成人精品无码区在线| 久久久久国产精品免费免费不卡| 久久久久久亚洲精品成人| 在线看片v免费观看视频777| 亚洲国产精品嫩草影院| 亚洲视频一区二区| 99爱免费观看视频在线| 色婷五月综激情亚洲综合 | 精品国产_亚洲人成在线高清| 一区二区免费视频| 亚洲乱码无人区卡1卡2卡3| 亚洲日韩涩涩成人午夜私人影院| APP在线免费观看视频| 激情五月亚洲色图| 亚洲女同成人AⅤ人片在线观看| 日韩电影免费在线观看中文字幕| 亚洲综合一区二区精品久久| 日本一区免费电影| 波多野结衣免费一区视频 | 欧美色欧美亚洲另类二区| 亚洲国产精品成人网址天堂| 日本在线看片免费人成视频1000|