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

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

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

    一路拾遺
    Collect By Finding All The Way ......
    posts - 81,comments - 41,trackbacks - 0

    用到的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請求數據添加到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對象,并發出postMethod請求

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



    動態構造調用串的話如下實現:


        
    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-05-27 16:30 胖胖泡泡 閱讀(1216) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 免费看一级一级人妻片| 亚洲一区二区无码偷拍| 国产伦精品一区二区免费| 免费人成在线观看网站视频| 亚洲AV无码乱码麻豆精品国产| **一级毛片免费完整视| 亚洲美女视频一区| 国产成人精品免费视频大| 综合自拍亚洲综合图不卡区| 免费女人高潮流视频在线观看| 亚洲永久永久永久永久永久精品| 久久久久成人片免费观看蜜芽 | 全黄a免费一级毛片人人爱| 亚洲精品中文字幕无码A片老| 永久免费视频v片www| 亚洲国产精品无码第一区二区三区| 成人A级毛片免费观看AV网站| 亚洲人成电影网站免费| 国产精品麻豆免费版| 成人福利在线观看免费视频| 91麻豆精品国产自产在线观看亚洲| 国产精品成人啪精品视频免费| 免费人成视频在线播放| 亚洲精品国产成人影院| 国产中文字幕在线免费观看| 亚洲国产精品久久66| 国产高清不卡免费在线| 亚洲最大的成人网| 亚洲JIZZJIZZ中国少妇中文| 一级特黄录像免费播放肥| 亚洲五月六月丁香激情| 最近中文字幕无免费视频| 美女无遮挡免费视频网站 | 成人毛片免费观看视频| 蜜臀亚洲AV无码精品国产午夜.| 国产av无码专区亚洲国产精品| 人人玩人人添人人澡免费| 亚洲夂夂婷婷色拍WW47| 亚洲一区二区三区影院 | 亚洲精品精华液一区二区| 亚洲色图综合在线|