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

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


    網站導航:
     
    主站蜘蛛池模板: 色噜噜的亚洲男人的天堂| 亚洲另类古典武侠| 无码精品人妻一区二区三区免费| 成年在线观看网站免费| 亚洲不卡中文字幕| 欧美最猛性xxxxx免费| 国产精品亚洲精品观看不卡| 中文字幕无码播放免费| 亚洲不卡1卡2卡三卡2021麻豆| 男女免费观看在线爽爽爽视频| 亚洲国产精品张柏芝在线观看| 无码国产精品一区二区免费| 国产精品亚洲精品| 国产一级大片免费看| 色老头综合免费视频| 亚洲精品狼友在线播放| 99热这里只有精品6免费| 亚洲精品永久www忘忧草| 成人午夜视频免费| 亚洲人成电影在线观看青青| 国产精品久久永久免费| 亚洲欧美中文日韩视频| 亚洲国产成人久久综合野外| 嫩草在线视频www免费看| 亚洲av无码片在线播放| 国内免费高清在线观看| 特级毛片免费观看视频| 亚洲人成影院在线无码按摩店| 8888四色奇米在线观看免费看| 中文字幕亚洲综合久久综合| 又粗又大又硬又爽的免费视频| a毛片全部免费播放| 亚洲国产成人超福利久久精品| 爽爽日本在线视频免费| 国产特黄特色的大片观看免费视频| 久久久久亚洲精品影视| 永久免费bbbbbb视频| 日本在线免费观看| 亚洲成在人线在线播放无码 | 破了亲妺妺的处免费视频国产| 永久免费精品影视网站|