Axis2 WebService Client
发布时间:2020-12-17 00:26:58 所属栏目:安全 来源:网络整理
导读:public class TestClient{public static void main(String[] args) throws AxisFault{execute();}public static void execute() throws AxisFault {String url = "http://127.0.0.1:8080/projectName/services/webService";String ns = "http://service.soft
public class TestClient{ public static void main(String[] args) throws AxisFault{ execute(); } public static void execute() throws AxisFault { String url = "http://127.0.0.1:8080/projectName/services/webService"; String ns = "http://service.soft.cn"; String methodName = "webserviceMethod"; String paramValue = "d:/ftpdata"; //指定调用WebService的URL EndpointReference targetEPR = new EndpointReference(url); Options opt = new Options(); opt.setTo(targetEPR); opt.setAction("urn:getFileByWebService"); //命名空间 OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace(ns,methodName); //方法 OMElement method = fac.createOMElement(methodName,omNs); OMElement param = fac.createOMElement("paramName",omNs); OMText param_value = fac.createOMText(param,paramValue); param.addChild(param_value); method.addChild(param); method.build(); //发送请求 ServiceClient sender = new ServiceClient(); sender.setOptions(opt); OMElement result = sender.sendReceive(method); System.out.println("result = " + result); Iterator iter = result.getChildElements(); while(iter.hasNext()){ String str = ((Element)iter.next()).getText(); System.out.println("str = " + str); } } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |