<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
    主站蜘蛛池模板: 亚洲中文字幕丝袜制服一区| 亚洲国产综合精品| 人人玩人人添人人澡免费| 亚洲激情校园春色| 免费国产怡红院在线观看| 伊人久久大香线蕉免费视频| 亚洲成aⅴ人片在线观| 免费在线观看理论片| 99国产精品免费视频观看| 色欲色欲天天天www亚洲伊| 亚洲乱色熟女一区二区三区丝袜| 亚洲精品国产精品乱码不卡√| 国产午夜亚洲精品国产| ZZIJZZIJ亚洲日本少妇JIZJIZ| 亚洲人成色77777在线观看| 国产亚洲人成网站在线观看| 免费阿v网站在线观看g| 免费看黄网站在线看 | 久久精品国产免费一区| 久久久久久亚洲Av无码精品专口| 日本免费高清视频| 久久亚洲欧美国产精品| 亚洲欧洲日本国产| 免费吃奶摸下激烈视频| 一级女人18毛片免费| 182tv免费视频在线观看| 在线观看亚洲专区| 亚洲免费观看在线视频| 亚洲精品国产字幕久久不卡| 又黄又爽的视频免费看| 国产h视频在线观看免费| 男女作爱在线播放免费网站| 日本视频免费观看| 亚洲AV无码专区国产乱码不卡| 国产免费黄色大片| 国产乱子精品免费视观看片| 国产婷婷成人久久Av免费高清| 夜夜亚洲天天久久| 黑人精品videos亚洲人| 日本媚薬痉挛在线观看免费| 桃子视频在线观看高清免费完整|