import org.apache.axis.client.Call; import org.apache.axis.client.Service; import org.apache.axis.encoding.XMLType; import javax.xml.rpc.ParameterMode; /** * webservice call helper class * * @author baizhanshi on 2018/5/2. */ public class WebServiceUtil { /** * Obtain the returned url of the listening recording according to the remotely provided third-party address * * @param url third-party address * @param EnterpriseID Enterprise ID * @param user agent number * @param password agent password * @param SessionID session number * @return */ public static String getResponseResult(String url, String EnterpriseID, String user, String password, String SessionID) { try { String endpoint = url; // Directly reference the remote wsdl file // The following are routines Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(endpoint); call.setOperationName("queryRecordAddr");// Interface name described in WSDL call.addParameter("EnterpriseID", XMLType.XSD_STRING, ParameterMode.IN);// parameters of the interface call.addParameter("USER", XMLType.XSD_STRING, ParameterMode.IN);// parameters of the interface call.addParameter("PASSWORD", XMLType.XSD_STRING, ParameterMode.IN);// parameters of the interface call.addParameter("SessionID", XMLType.XSD_STRING, ParameterMode.IN);// parameters of the interface call.setReturnType(XMLType.XSD_STRING);// Set the return type String result = (String) call.invoke(new Object[]{EnterpriseID, user, password, SessionID}); // pass parameters to the method and call the method return result; } catch (Exception e) { return e.getMessage(); } } }
Reference blog: https://blog.csdn.net/qq_35124535/article/details/62226585