<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請(qǐng)求數(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請(qǐng)求

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

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 免费一级e一片在线播放| 免费国产在线观看老王影院 | 国产成人精品日本亚洲网址| 久久国内免费视频| 好男人www免费高清视频在线| 亚洲a∨国产av综合av下载| 久久精品免费一区二区| 亚洲AV无码一区二区三区网址| 久久精品亚洲男人的天堂| 99久久99久久精品免费观看| 日本红怡院亚洲红怡院最新| 久草视频在线免费| 国产高潮久久免费观看| 久久精品国产亚洲αv忘忧草| 女人体1963午夜免费视频| 亚洲综合伊人久久综合| 国产精品免费观看久久| 成人无码精品1区2区3区免费看 | 亚洲综合AV在线在线播放| 无码乱肉视频免费大全合集| a级毛片免费观看网站| 亚洲人xxx日本人18| 亚洲精品成人片在线观看精品字幕 | 一级毛片免费在线观看网站| 亚洲狠狠ady亚洲精品大秀| 51精品视频免费国产专区| 污视频网站免费在线观看| 相泽亚洲一区中文字幕| 成人免费网站在线观看| 免费不卡在线观看AV| 国产精品hd免费观看| 看亚洲a级一级毛片| 亚洲国产成人精品青青草原| 久久久久亚洲AV成人网人人网站| 无码高潮少妇毛多水多水免费| 成人无码a级毛片免费| 中文字幕亚洲免费无线观看日本| 亚洲色一色噜一噜噜噜| 国产精品久久免费视频| 国产无遮挡色视频免费观看性色| 亚洲av无码一区二区三区天堂 |