一 使用axis调用webservice
1.导入包
activation.jar
axis.jar
commons-discovery-0.2.jar
commons-logging-1.0.4.jar
jaxrpc.jar
mail.jar
wsdl4j-1.5.1.jar
2.代码
private void getWeather(){ try{ // String url = "http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl"; String url="http://webservice.webxml.com.cn/WebServices/WeatherWebService.asmx"; String city="北京"; //命名空间 String soapaction="http://WebXml.com.cn/"; Service service = new Service(); Call call=(Call) service.createCall();
call.setTargetEndpointAddress(url); //方法名 // call.setOperationName(new QName(soapaction,"getSupportCityString")); call.setOperationName(new QName(soapaction,"getWeatherbyCityName")); //参数 call.addParameter(new QName(soapaction,"theCityName"), org.apache.axis.encoding.XMLType.XSD_STRING, ja