<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 評論 :: 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); 
        
        
    //最后生成一個HttpClient對象,并發(fā)出postMethod請求

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



    動態(tài)構(gòu)造調(diào)用串的話如下實現(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) 評論(0)  編輯  收藏 所屬分類: web
    主站蜘蛛池模板: 一个人看的hd免费视频| 91成年人免费视频| 久久久久亚洲AV无码去区首| 久久香蕉国产线看观看亚洲片| 免费在线观看亚洲| 亚洲免费网站观看视频| 免费人成网站在线观看不卡| 人禽伦免费交视频播放| 亚洲AV无码一区二区三区牲色| 亚洲国产精品人久久电影| 亚洲第一精品福利| 亚洲av无码一区二区三区不卡 | 国产成人精品亚洲精品| 国产高清在线精品免费软件| 99久久精品日本一区二区免费| 少妇人妻偷人精品免费视频| 182tv免费视频在线观看| 国产精品午夜免费观看网站| 一级特黄录像免费播放中文版| 久久久久亚洲国产AV麻豆 | 永久黄网站色视频免费观看| 在线a级毛片免费视频| 青娱乐免费视频在线观看| 亚洲成人免费电影| 亚洲精品视频免费在线观看| 18女人毛片水真多免费| 久久成人国产精品免费软件| a拍拍男女免费看全片| 成年人免费的视频| 无人影院手机版在线观看免费| 999在线视频精品免费播放观看| 日本zzzzwww大片免费| 亚色九九九全国免费视频| 欧美a级成人网站免费| 午夜一区二区免费视频| 国产一级大片免费看| 亚洲av高清在线观看一区二区 | 亚洲另类小说图片| 亚洲国产综合精品中文第一| 亚洲精华国产精华精华液好用| 色五月五月丁香亚洲综合网|