1、服務
2、代碼
import javax.xml.namespace.QName; import org.apache.axis.client.Call; import org.apache.axis.client.Service; /** * @Author: * @Description: * @Date:Created in 10:11 2018/9/7 * @Modified by: **/ public class accessWeb { public static void main(String args[]) { test(); } public static void test() { String url = "http://15.23.25.21/spesvc/Ott/OttService.asmx";// 提供接口的地址 String soapaction = "http://oc.ctrchina.cn/";// 域名,這是在server定義的 String monitorDate = "2018-09-01"; Service service = new Service(); try { Call call = (Call) service.createCall(); call.setTargetEndpointAddress(url); call.setOperationName(new QName(soapaction, "GetPlayListGuidWithDate")); // 設置要調用哪個方法 call.addParameter(new QName(soapaction, "monitorDate"), // 設置要傳遞的參數 org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);// (標准的類型) call.setSOAPActionURI(soapaction + "GetPlayListGuidWithDate"); String res = String.valueOf(call.invoke(new Object[] { monitorDate }));// 調用方法並傳遞參數 System.out.println(res); } catch (Exception ex) { ex.printStackTrace(); } } }
2、應用jar包