首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

java 经过axis调用天气预报的webservice

2012-08-26 
java 通过axis调用天气预报的webservicepackage weatherwsimport javax.xml.namespace.QNameimport org.

java 通过axis调用天气预报的webservice
package weatherws;


import javax.xml.namespace.QName;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.types.Schema;



public class WeatherWS {

public static void main(String[] args) {
try {
String theRegionCode = "31124";

String endpoint = "http://www.webxml.com.cn/WebServices/WeatherWS.asmx";//

Service service = new Service();

Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));

call.setOperationName(new QName("http://WebXml.com.cn/",
"getSupportCityDataset")); //



call.addParameter(new QName("http://WebXml.com.cn/","theRegionCode"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);

call.setReturnType(org.apache.axis.encoding.XMLType.XSD_SCHEMA);

call.setUseSOAPAction(true);
call.setSOAPActionURI("http://WebXml.com.cn/getSupportCityDataset");//

Schema result =  (Schema)call.invoke(new Object[]{"31124"});

for (int i = 0; i < result.get_any().length; i++) {
System.out.println(result.get_any()[i]);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

热点排行
Bad Request.