package cn.com.client.test;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.service.Service;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import cn.com.webxml.ArrayOfString;
import cn.com.webxml.DataSet;
import cn.com.webxml.GetWeatherbyCityName;
import cn.com.webxml.WeatherWebServiceHttpPost;
import cn.com.webxml.WeatherWebServiceSoap;
import cn.com.webxml.GetSupportDataSetResponse.GetSupportDataSetResult;
public class ClientTest {
public static void main(String[] args) throws Exception{
// getStockInformation();
// getWeatherInformation();
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setAddress("http://www.webxml.com.cn/WebServices/WeatherWebService.asmx");
factory.setServiceClass(WeatherWebServiceSoap.class);
WeatherWebServiceSoap wwss = (WeatherWebServiceSoap) factory.create();
// ArrayOfString aos = wwss.getSupportProvince();
// List aList = aos.getString();
// for (int i = 0; i < aList.size(); i++) {
// System.out.println(i+"-洲或国内省份的名称-"+aList.get(i));
// }
// ArrayOfString b = wwss.getSupportCity("ALL");
// List bList = b.getString();
// for (int i = 0; i < bList.size(); i++) {
// System.out.println(i+"-城市名称(城市代码)-"+bList.get(i));
// }
// ArrayOfString c = wwss.getWeatherbyCityNamePro("深圳", "商业用户Id编号");
// List cList = c.getString();
// for (int i = 0; i < cList.size(); i++) {
// System.out.println(i+"-天气情况-"+cList.get(i));
// }
// GetSupportDataSetResult obj = wwss.getSupportDataSet();
ArrayOfString d = wwss.getWeatherbyCityName("深圳");
List dList = d.getString();
for (int i = 0; i < dList.size(); i++) {
System.out.println("-----"+dList.get(i));
}
}
public void asdf()throws Exception{
}
public static void getWeatherInformation()throws Exception{
HttpGet get = new HttpGet("http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName?theCityName=广州");
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(get);
InputStream is = response.getEntity().getContent();
byte b[] = new byte[1024];
StringBuilder sb = new StringBuilder();
while(is.read(b)!= -1){
sb.append(new String(b,"utf-8"));
}
System.out.println("----天气信息:"+sb.toString());
}
public static void getStockInformation()throws Exception{
HttpGet get = new HttpGet("http://www.webxml.com.cn/WebServices/ChinaStockWebService.asmx/getStockImageByCode?theStockCode=");
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(get);
InputStream is = response.getEntity().getContent();
FileOutputStream fos = new FileOutputStream("E:/stock.gif");
BufferedInputStream bis = new BufferedInputStream(is);
BufferedOutputStream bos = new BufferedOutputStream(fos);
int b = 0 ;
while((b=bis.read()) != -1){
bos.write(b);
}
bis.close();
bos.close();
}
}
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.service.Service;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import cn.com.webxml.ArrayOfString;
import cn.com.webxml.DataSet;
import cn.com.webxml.GetWeatherbyCityName;
import cn.com.webxml.WeatherWebServiceHttpPost;
import cn.com.webxml.WeatherWebServiceSoap;
import cn.com.webxml.GetSupportDataSetResponse.GetSupportDataSetResult;
public class ClientTest {
public static void main(String[] args) throws Exception{
// getStockInformation();
// getWeatherInformation();
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setAddress("http://www.webxml.com.cn/WebServices/WeatherWebService.asmx");
factory.setServiceClass(WeatherWebServiceSoap.class);
WeatherWebServiceSoap wwss = (WeatherWebServiceSoap) factory.create();
// ArrayOfString aos = wwss.getSupportProvince();
// List aList = aos.getString();
// for (int i = 0; i < aList.size(); i++) {
// System.out.println(i+"-洲或国内省份的名称-"+aList.get(i));
// }
// ArrayOfString b = wwss.getSupportCity("ALL");
// List bList = b.getString();
// for (int i = 0; i < bList.size(); i++) {
// System.out.println(i+"-城市名称(城市代码)-"+bList.get(i));
// }
// ArrayOfString c = wwss.getWeatherbyCityNamePro("深圳", "商业用户Id编号");
// List cList = c.getString();
// for (int i = 0; i < cList.size(); i++) {
// System.out.println(i+"-天气情况-"+cList.get(i));
// }
// GetSupportDataSetResult obj = wwss.getSupportDataSet();
ArrayOfString d = wwss.getWeatherbyCityName("深圳");
List dList = d.getString();
for (int i = 0; i < dList.size(); i++) {
System.out.println("-----"+dList.get(i));
}
}
public void asdf()throws Exception{
}
public static void getWeatherInformation()throws Exception{
HttpGet get = new HttpGet("http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName?theCityName=广州");
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(get);
InputStream is = response.getEntity().getContent();
byte b[] = new byte[1024];
StringBuilder sb = new StringBuilder();
while(is.read(b)!= -1){
sb.append(new String(b,"utf-8"));
}
System.out.println("----天气信息:"+sb.toString());
}
public static void getStockInformation()throws Exception{
HttpGet get = new HttpGet("http://www.webxml.com.cn/WebServices/ChinaStockWebService.asmx/getStockImageByCode?theStockCode=");
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(get);
InputStream is = response.getEntity().getContent();
FileOutputStream fos = new FileOutputStream("E:/stock.gif");
BufferedInputStream bis = new BufferedInputStream(is);
BufferedOutputStream bos = new BufferedOutputStream(fos);
int b = 0 ;
while((b=bis.read()) != -1){
bos.write(b);
}
bis.close();
bos.close();
}
}