import org.apache.axis.client.Call; import org.apache.axis.client.Service; import org.apache.axis.encoding.XMLType; import javax.xml.rpc.ParameterMode; /** * webservice 調取幫助類 * * @author baizhanshi on 2018/5/2. */ public class WebServiceUtil { /** * 根據遠程提供第三方地址獲取返回的調聽錄音url * * @param url 第三方地址 * @param EnterpriseID 企業編號 * @param user 坐席號 * @param password 坐席密碼 * @param SessionID 會話編號 * @return */ public static String getResponseResult(String url, String EnterpriseID, String user, String password, String SessionID) { try { String endpoint = url; // 直接引用遠程的wsdl文件 // 如下都是套路 Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(endpoint); call.setOperationName("queryRecordAddr");// WSDL裏面描述的接口名稱 call.addParameter("EnterpriseID", XMLType.XSD_STRING, ParameterMode.IN);// 接口的參數 call.addParameter("USER", XMLType.XSD_STRING, ParameterMode.IN);// 接口的參數 call.addParameter("PASSWORD", XMLType.XSD_STRING, ParameterMode.IN);// 接口的參數 call.addParameter("SessionID", XMLType.XSD_STRING, ParameterMode.IN);// 接口的參數 call.setReturnType(XMLType.XSD_STRING);// 設置返回類型 String result = (String) call.invoke(new Object[]{EnterpriseID, user, password, SessionID}); // 給方法傳遞參數,而且調用方法 return result; } catch (Exception e) { return e.getMessage(); } } }
參考博客:https://blog.csdn.net/qq_35124535/article/details/62226585java