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); } } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。