<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 胖胖泡泡 閱讀(1217) 評論(0)  編輯  收藏

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


    網站導航:
     
    主站蜘蛛池模板: 久久亚洲精品国产亚洲老地址 | 亚洲自偷精品视频自拍| fc2免费人成在线视频| 亚洲国产精品人人做人人爽| 亚洲AV无码专区国产乱码不卡| 成人免费视频观看无遮挡| 亚洲日韩一区二区一无码| 全免费A级毛片免费看网站| 国产精品亚洲AV三区| 免费h黄肉动漫在线观看| 边摸边吃奶边做爽免费视频99| 亚洲精品无码av天堂| 中文在线观看免费网站| 亚洲成av人影院| 永久免费在线观看视频| 久久综合久久综合亚洲| 无码专区一va亚洲v专区在线| 九九热久久免费视频| 亚洲色图在线播放| 成人免费无码视频在线网站| 久久亚洲色WWW成人欧美| 中文字幕久久亚洲一区| 91高清免费国产自产拍2021| 亚洲校园春色另类激情| 免费在线看片网站| 久久99精品视免费看| 亚洲a级片在线观看| 波多野结衣视频在线免费观看| 中国一级毛片免费看视频| 亚洲黄色免费网址| 日本一道一区二区免费看 | 亚洲人成7777影视在线观看| 免费大香伊蕉在人线国产| 女同免费毛片在线播放| 亚洲一区二区三区在线| 亚洲成a人片在线观看日本麻豆| 野花香高清在线观看视频播放免费 | 免费一区二区三区四区五区| 免费91最新地址永久入口| 亚洲色欲啪啪久久WWW综合网| 国产亚洲av人片在线观看|