import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public static void main(String[] args) {
//new 一個服務
Service sv = new Service();
//創建一個call對象
Call call = (Call) sv.createCall();
//設置要調用的接口地址
call.setTargetEndpointAddress(new URL("http://10.88.81.26:7001/ahCardService/services/CardService?wsdl"));
//設置要調用的接口方法
call.setOperationName(new QName("getAZ03"));
//設置參數 第二個參數表示String類型,第三個參數表示入參
call.addParameter("user", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter("pass", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter("aac002", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter("aac003", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter("aab301", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
//返回參數類型
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
//開始調用方法並返回相應數據信息,以xml格式的字符串返回,也可以json格式主要看對方用什麼方式返回
Object result = call.invoke(new Object[]{"340800","G6oqoy8HdC","340827198302281337","齊舒亮","340800"});
System.out.println(result);//打印字符串
}
以上就是調用webservice接口的方法,希望對大家有所幫助,如有疑問或者問題可以在下方留言,樓主看到會第一時間回覆。