解决Axis2 服务器端与客户端 复合参数传递问题

网上看到说Axis2服务器端与客户端传递参数只支持数组和对象,但是想借助list传递多个参数,或参数不固定时,需转换成OMElement格式传递,我试了很多遍没成功。

所以自己想到办法,先将多个参数放到list中,到提交时,将list中的参数取出来放到数组中,能过数组进行传递,方便,快捷!


下面看代码


服务端:

public class UCallWsInterface {
// 测试连接
public String ConnectionCheck() {
String str = "连接成功";

return str;
}
// 业务功能
public CSPActionRes CSPAction(CSPActionReq actionReq) {



//加载xml文件中的内容
// XMLToBean ActionCmdbean = new XMLToBean();
// List<ActionCmd> actionList = ActionCmdbean.getActionCmd();
CSPActionRes actionRes = new CSPActionRes();
String ActionCmd = actionReq.getActionCmd();
List<String> OutParamList = new ArrayList<String>();
if("CheckSmartcard".equals(ActionCmd))
{
actionRes.setActionCmd("CheckSmartcard");
actionRes.setReturnCode("0");
actionRes.setReturnMsg("成功!");
String OutParam1 = "111";
String OutParam2 = "222";
String OutParam3 = "333";
OutParamList.add(OutParam1);
OutParamList.add(OutParam2);
OutParamList.add(OutParam3);
}
String [] OutParamArray = new String[OutParamList.size()];
for(int i=0;i<OutParamList.size();i++)
{
OutParamArray[i] = OutParamList.get(i);
}
actionRes.setOutParam(OutParamArray);
        return actionRes;
}

}


客户端:

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]);
}
}


}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值