AXIS呼叫webservice(一)
阿新 • • 發佈:2018-12-20
public static String startWebService(String url,String operation,String account,String key,String xml){ String result = ""; try { Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(url); call.setOperationName(operation);// WSDL裡面描述的介面名稱 call.addParameter("account",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);// 介面的引數 call.addParameter("key",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);// 介面的引數 call.addParameter("xml",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);// 介面的引數 call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);// 設定返回型別 // 給方法傳遞引數,並且呼叫方法 result = (String) call.invoke(new Object[] { account,key,xml }); System.out.println("result is " + result); } catch (Exception e) { System.err.println(e.toString()); } return result; }