网上这种IFRAME很多的,都封好了

解决方案 »

  1.   

    找个网站,然后用httpclient去抓就可以了,将抓到内容自己分析一下结构,取出天气,就ok了。呵呵,最好用ajax!
      

  2.   

    调用公开的WebService
    比如:http://www.webservicex.net/globalweather.asmx
      

  3.   

    这个我做过  直接调用webservice
    http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdlpackage cn.spume.temp;import org.apache.axis.client.Call; 
    import org.apache.axis.client.Service; import javax.swing.JOptionPane;
    import javax.xml.namespace.QName; //天气预报客户端2008-05-17
    public class SelfInvoke { 
      public static void main(String[] args) { 
        String theCityName = JOptionPane.showInputDialog("请输入要查询的城市名称"); 
        String soapactionName = "http://WebXml.com.cn/"; 
        try { 
          String endpoint = "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl"; 
          Service service = new Service(); 
          Call call = (Call) service.createCall(); 
          call.setTargetEndpointAddress(new java.net.URL(endpoint)); 
          call.addParameter(new QName(soapactionName, 
              "theCityName"), org.apache.axis.encoding.XMLType.XSD_STRING, 
                            javax.xml.rpc.ParameterMode.IN); 
    //call.addParameter(new javax.xml.namespace.QName("http://WebXml.com.cn/", "strPassword"), org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN); 
          call.setReturnType(new QName(soapactionName, "getWeatherbyCityName"), String[].class);//由于返回的是一个数组所以要自定义返回类型 
          call.setOperationName(new QName( 
              soapactionName, "getWeatherbyCityName")); 
          call.setUseSOAPAction(true); 
          call.setSOAPActionURI(soapactionName+"getWeatherbyCityName"); 
          String[] result = (String[]) call.invoke(new Object[] {theCityName}); 
          for (int i=0;i <result.length;i++) 
          { 
            System.out.println(result[i]); 
          } 
          JOptionPane.showMessageDialog(null, "结果已经在控制台输出");
        } 
        catch (Exception e) { 
          System.err.println(e.toString()); 
          e.printStackTrace(); 
        } 
      } }