package test;
import java.rmi.RemoteException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.types.Schema;
public class TestWeb {
public static void main(String[] args){
//自定义参数
String arg0= "";
String arg1= "";
try{
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new java.net.URL("WebService的链接"));
call.setOperation("方法名");
call.setUseSOAPAction(true);
call.setOperationName(new QName("http://tempuri.org/","方法名"));
call.addParameter(new QName("http://tempuri.org/",“arg0"),XMLType.XSD_STRING
, ParameterMode.IN);
call.addParameter(new QName("http://tempuri.org/","arg1"),XMLType.XSD_STRING
, ParameterMode.IN);
call.setReturnType(XMLType.XSD_SCHEMA);
call.setSOAPActionURI("写入soapactionURI地址");
Schema result = (Schema)call.invoke(new Object[]{arg0,arg1});
for(int i = 0; i<result.get_any().length; i++){
System.out.println(result.get_any()[i]);
}
}catch(ServiceException e){
System.out.println("异常");
e.printStackTrace();
}catch(RemoteException e){
System.out.println("RemoteException异常");
e.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}
}
}