您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 信息化管理 > weservice接口调用
packagecom.icss.pepec.controller.bd;importjavax.xml.namespace.QName;importjava.util.ArrayList;importjava.util.List;importorg.apache.axis2.addressing.EndpointReference;importorg.apache.axis2.client.Options;importorg.apache.axis2.databinding.types.soapencoding.Array;importorg.apache.axis2.rpc.client.RPCServiceClient;importorg.dom4j.Document;importorg.dom4j.DocumentHelper;importorg.dom4j.Element;/***CreatedbyAdministratoron2016/8/3.*/publicclassTest1{publicstaticvoidmain(String[]agrs){Object[]xmlStr={参数};//参数Stringurl=url;Stringmethod=接口方法;StringnameSpace=nameSpace;Stringxml=;xml=invokeService(xmlStr,nameSpace,url,method);}publicStringinvokeService(Object[]xmlStr,StringnameSpace,Stringurl,Stringmethod)throwsException{Stringxml=null;Stringno=xmlStr[0].toString();RPCServiceClientserviceClient=newRPCServiceClient();Optionsoptions=serviceClient.getOptions();EndpointReferencetargetEPR=newEndpointReference(url);options.setTo(targetEPR);QNameopAddEntry=newQName(nameSpace,method);Object[]opAddEntryArgs=xmlStr;Class[]classes=newClass[]{String.class};xml=(String)serviceClient.invokeBlocking(opAddEntry,opAddEntryArgs,classes)[0];serviceClient.cleanupTransport();returnxml;}}
本文标题:weservice接口调用
链接地址:https://www.777doc.com/doc-2867224 .html