package cn.net.sj;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class WebserviceTest {
/**
* @param args
*/
public static void main(String[] args) {
try {
String endpoint = "http://172.24.176.29/hmsas/wsdl/hmsasserver.php?wsdl";
//直接引用远程的wsdl文件
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(endpoint);
call.setOperationName("getdatatoarray");//WSDL里面描述的接口名称
call.addParameter("datatable0", org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);//接口的参数
call.addParameter("begdate0", org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);//接口的参数
call.addParameter("enddate0", org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);//接口的参数
call.addParameter("elementstr0", org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);//接口的参数
call.addParameter("stanumstr0", org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);//接口的参数
call.addParameter("username", org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);//接口的参数
call.addParameter("userpass", org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);//接口的参数
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_ANYTYPE);//设置返回类型
String datatable0 = "Z_O_AWS_ST_C5_CQ";
String begdate0 = "2013070512";
String enddate0 = "2013070513";
String elementstr0 = "StationNum,ObservTime,AirTemp,RainFallHour,AirTemp";
String stanumstr0 = "'57517'";
String username = "zsl";
String userpass = "zsl";
String[] result = (String[])call.invoke(new Object[]{datatable0,begdate0,enddate0,elementstr0,stanumstr0,username,userpass});
//给方法传递参数,并且调用方法
System.out.println("result is "+result.length);
}
catch (Exception e) {
System.err.println(e.toString());
}
}
}