解决Axis2 服务器端与客户端 复合参数传递问题
网上看到说Axis2服务器端与客户端传递参数只支持数组和对象,但是想借助list传递多个参数,或参数不固定时,需转换成OMElement格式传递,我试了很多遍没成功。 所以自己想到办法,先将多个参数放到list中,到提交时,将list中的参数取出来放到数组中,能过数组进行传递,方便,快捷! 下面看代码 服务端: public class UCallWsInterface { 客户端: public class TestClent { /** * @param args */ public static void main(String[] args) throws Exception{ // TODO Auto-generated method stub UCallWsWebStub stub = new UCallWsWebStub(); UCallWsWebStub.CSPAction csp = new UCallWsWebStub.CSPAction(); UCallWsWebStub.CSPActionReq req = new UCallWsWebStub.CSPActionReq(); List<String> InParamList = new ArrayList<String>(); req.setActionCmd("CheckSmartcard"); String InParam1 = "aaa"; String InParam2 = "bbb"; String InParam3 = "ccc"; InParamList.add(InParam1); InParamList.add(InParam2); InParamList.add(InParam3); String [] InParamArray = new String[InParamList.size()]; for(int i=0;i<InParamList.size();i++) { InParamArray[i] = InParamList.get(i); } req.setInParam(InParamArray); csp.setActionReq(req); CSPActionRes res = stub.CSPAction(csp).get_return(); String ActionCmd = res.getActionCmd(); String [] OutParam = res.getOutParam(); System.out.println("---ActionCmd---"+ActionCmd); System.out.println("---ReturnCode---"+res.getReturnCode()); System.out.println("---ReturnMsg---"+res.getReturnMsg()); for(int i=0;i<OutParam.length;i++) { System.out.println("---OutParam"+i+"--"+OutParam[i]); } } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |