Import java.util.LinkedList;
Import java.util.List;
Import Java.util.Map;
Import Java.util.Vector;
Import Javax.xml.namespace.QName;
Import Org.apache.axis.client.Call;
Import Org.apache.axis.client.Service;
public class Putweather {private String url= "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx";//provide an address for an interface Private String soapaction= "http://WebXml.com.cn/";
Domain name, which is the public putweather () {String city= "Beijing" defined in the server;
Service service=new service ();
try{call call= (call) Service.createcall ();
Call.settargetendpointaddress (URL); Call.setoperationname (New QName (SOAPAction, "getweatherbycityname")); Set which method to invoke Call.addparameter (new QName (SOAPAction, "Thecityname"),//Set parameters to pass Org.apache
. Axis.encoding.XMLType.XSD_STRING, Javax.xml.rpc.ParameterMode.IN); Call.setreturntype (New QName (Soapaction, "getweatherbycityname"), Vector.class);
The data type to return (custom type)//Call.setreturntype (Org.apache.axis.encoding.XMLType.XSD_STRING);//(Standard type)
Call.setusesoapaction (TRUE);
Call.setsoapactionuri (SOAPAction + "Getweatherbycityname");
Vector v= (vector) Call.invoke (new object[]{city});//call method and pass parameter for (int i=0;i<v.size (); i++)
{System.out.println (V.get (i));
}}catch (Exception ex) {ex.printstacktrace ();
} public static void Main (String args[]) {putweather pw=new putweather (); }
}