我用java远程调用.net webservice服务,服务端接收到了请求,但是服务端接收到参数的为null呢?
public String callServiceEsbGFY(BsServiceDict bsdVo, String custIdValue, Map servParam)
throws SysException, AppException {
//System.out.println("servParam"+servParam.toString());
String retMsg = null;
String serviveCode = (String) servParam.get("code");
servParam.remove("code");
//String soapActionURI = "http://tempuri.org/selectVIN";
//处理入参
String str="<?xml version=\"1.0\" encoding=\"gb2312\"?>
Set keys = servParam.keySet();
if(keys != null) {
Iterator iterator = keys.iterator();
while(iterator.hasNext()) {
String key =iterator.next();
str=str+key+"="+"\""+servParam.get(key)+"\""+" ";
}
str=str+">";
}
String endpoint =bsdVo.getServiceAddress();
String methodStr = bsdVo.getMethodName();
String input = bsdVo.getInParam();
try {
input=input.replace(Constants.STRING_CHARACTER_GFY, str);
//用户密码替换
String password = ToolUtil.MD5Encrept(Constants.STRING_USERPASSWORD_INFO, Constants.INTEGER_FORMD5_32);
input=input.replace(Constants.STRING_USERPASSWORD_GFY, password);
//当前时间替换
Date date = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式
String dateFormat = df.format(date);
log.info("dateFormat@@@@@@"+dateFormat);
input=input.replace(Constants.STRING_CREATETIMEINFO_GFY, dateFormat);
/**
1、A = 变量用户MD5密钥值转为UTF8字符串
*2、B = 变量报文时间戳值转为UTF8字符串
*3、C = 变量业务逻辑
*3、D = A与B异或运算,运算时计算长度以A和B值中字符长度短的为准,将D的值转为BASE64字符串
*/
String baseInfo = ToolUtil.twoStringXor(password,dateFormat);
log.info("baseInfo#######333 : "+baseInfo);
//计算最后签名的值
String character = ToolUtil.changeToSHA(str,Constants.STRING_FORHASHCODE_256);
String sign = ToolUtil.changeToSHA(character+baseInfo,Constants.STRING_FORHASHCODE_256);
//将模板中的签名替换掉
input=input.replace(Constants.STRING_SIGNINPUT_GFY, sign);
//替换调用接口code
log.info("serviveCode$$$$$$$$$$$$"+serviveCode);
input=input.replace(Constants.STRING_SERVICECODE_GFY, serviveCode);
log.info("111111111111111111111111111111111111111111111111111111111111");
log.info("input=="+input);
log.info("222222222222222222222222222222222222222222222222222222222222");
AxisProperties.setProperty("axis.socketSecureFactory", "org.apache.axis.components.net.SunFakeTrustSocketFactory");
org.apache.axis.client.Service service = new org.apache.axis.client.Service();
Call call = (Call) service.createCall();
String endpoint1 = "http://IPMCH.ESB.TopSchemaV2";
call.setTargetEndpointAddress (new java.net.URL(endpoint));
call.setOperationName(new QName( endpoint1 , methodStr));
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://IPMCH.ESB.TopSchemaV2/CallESB");
call.addParameter( "arg0", org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
retMsg = (String) call.invoke(new Object[] {input} );
} catch (Exception e) {
retMsg = "10000";
e.printStackTrace();
throw new SysException("","XmlException:OrderReceive.buildOrderReceiveXML():"+e.getMessage(),e);
}
return retMsg;
}