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();
}
}
}
java 通过axis调用天气预报的webservice
猜你喜欢
转载自chen106106.iteye.com/blog/1069463
今日推荐
周排行