?? webutil.java
字號:
package com.shd.struts1.web.util;
import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.Map;
import javax.xml.rpc.ServiceException;
import cn.com.WebXml.WeatherWebService;
import cn.com.WebXml.WeatherWebServiceLocator;
import cn.com.domain.WeatherEntity;
import com._6617.fhs.IPService.Weather_x0020_WebService;
import com._6617.fhs.IPService.Weather_x0020_WebServiceLocator;
/**
* Mar 30, 2009
*@author shdxiahui@163.com
*/
public class WebUtil {
public static String getIp(String ip) throws RemoteException, ServiceException {
Weather_x0020_WebServiceLocator webImple = new Weather_x0020_WebServiceLocator();
Weather_x0020_WebService service = (Weather_x0020_WebService) webImple;
//String address = service.getWeather_x0020_WebServiceSoapAddress();
Object[] address = service.getWeather_x0020_WebServiceSoap().getIPLocation(ip);
StringBuffer buffer = new StringBuffer();
for(int i=0; i<address.length; i++){
buffer.append(address[i]).append(",");
}
buffer.deleteCharAt(buffer.length()-1);
return buffer.toString();
}
public static Map<String,String> getCityCodes() throws RemoteException, ServiceException{
WeatherWebServiceLocator weather = new WeatherWebServiceLocator();
WeatherWebService service = (WeatherWebService) weather;
String[] provice = service.getWeatherWebServiceSoap().getSupportCity("all");//所有支付的城市
Map<String,String> provide = new HashMap<String, String>();
int t1,t2;
for(int i=0; i<provice.length; i++){
t1 = provice[i].indexOf("(");
t2 = provice[i].indexOf(")");
provide.put(provice[i].substring(t1+1, t2), provice[i].substring(0, t1-1));
}
return provide;
}
public static String getWeather(String cityCode) throws RemoteException, ServiceException {
WeatherWebServiceLocator weather = new WeatherWebServiceLocator();
WeatherWebService service = (WeatherWebService) weather;
String[] provice = service.getWeatherWebServiceSoap().getSupportCity("all");//所有支付的城市
String[] citys = service.getWeatherWebServiceSoap().getWeatherbyCityName(cityCode);
Map<String,String> provide = new HashMap<String, String>();
int t1,t2;
for(int i=0; i<provice.length; i++){
t1 = provice[i].indexOf("(");
t2 = provice[i].indexOf(")");
provide.put(provice[i].substring(t1+1, t2), provice[i].substring(0, t1-1));
}
WeatherEntity entity = new WeatherEntity();
entity.setTemperature(citys[5]);
entity.setSituation(citys[6]);
entity.setWind(citys[7]);
entity.setBeginGifPath(citys[8]);
entity.setEndGifPath(citys[9]);
entity.setActually(citys[10]);
entity.setExpand(citys[11]);
System.out.println(entity.toString());
return entity.toString();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -