`

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();
}
}
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics