调用工行接口1.0.0.11版本的XML格式拼接代码
[C#] 纯文本查看 复制代码 /// <summary>
/// 将对象拼接成XML格式,并且转成字符串
/// </summary>
/// <param name="tranData">ICBC核心对象</param>
/// <param name="orderInfo">ICBC订单对象 相当于订单明细 不能超过5条</param>
/// <returns></returns>
public static string SpliceTranData(ICBCTranData tranData, List<OrderInfo> orderInfo)
{
StringBuilder sb = new StringBuilder();
sb.Append("<?xml version=\"1.0\" encoding=\"GBK\" standalone=\"no\"?>");
sb.Append("<B2CReq>");
sb.Append("<interfaceName>" + tranData.InterfaceName + "</interfaceName>");
sb.Append("<interfaceVersion>" + tranData.InterfaceVersion + "</interfaceVersion>");
sb.Append("<orderInfo>");
sb.Append("<orderDate>" + tranData.OrderDate.ToString("yyyyMMddHHmmss") + "</orderDate>");
sb.Append("<curType>" + tranData.CurType + "</curType>");
sb.Append("<merID>" + tranData.MerID + "</merID>");
if (orderInfo != null)
{
sb.Append("<subOrderInfoList>");
foreach (OrderInfo item in orderInfo)
{
sb.Append("<subOrderInfo>");
sb.Append("<orderid>" + item.OrderId + "</orderid>");
sb.Append("<amount>" + item.Amount + "</amount>");
sb.Append("<installmentTimes>" + item.InstallMentTimes + "</installmentTimes>");
sb.Append("<merAcct>" + item.MerAcct + "</merAcct>");
sb.Append("<goodsID>" + item.GoodsID + "</goodsID>");
sb.Append("<goodsName>" + item.GoodsName + "</goodsName>");
sb.Append("<goodsNum>" + item.GoodsNum + "</goodsNum>");
sb.Append("<carriageAmt>" + item.CarriageAmt + "</carriageAmt>");
sb.Append("</subOrderInfo>");
}
sb.Append("</subOrderInfoList>");
}
sb.Append("</orderInfo>");
sb.Append("<custom>");
sb.Append("<verifyJoinFlag>" + tranData.VerifyJoinFlag + "</verifyJoinFlag>");
sb.Append("<Language>" + tranData.Language + "</Language>");
sb.Append("</custom>");
sb.Append("<message>");
sb.Append("<creditType>" + tranData.CreditType + "</creditType>");
sb.Append("<notifyType>" + tranData.NotifyType + "</notifyType>");
sb.Append("<resultType>" + tranData.ResultType + "</resultType>");
sb.Append("<merReference>" + tranData.MerReference + "</merReference>");
sb.Append("<merCustomIp>" + tranData.MerCustomIp + "</merCustomIp>");
sb.Append("<goodsType>" + tranData.GoodsType + "</goodsType>");
sb.Append("<merCustomID>" + tranData.MerCustomID + "</merCustomID>");
sb.Append("<merCustomPhone>" + tranData.MerCustomPhone + "</merCustomPhone>");
sb.Append("<goodsAddress>" + tranData.GoodsAddress + "</goodsAddress>");
sb.Append("<merOrderRemark>" + tranData.MerOrderRemark + "</merOrderRemark>");
sb.Append("<merHint>" + tranData.MerHint + "</merHint>");
sb.Append("<remark1>" + tranData.Remark1 + "</remark1>");
sb.Append("<remark2>" + tranData.Remark2 + "</remark2>");
sb.Append("<merURL>" + tranData.MerURL + "</merURL>");
sb.Append("<merVAR>" + tranData.MerVAR + "</merVAR>");
sb.Append("</message>");
sb.Append("</B2CReq>");
return sb.ToString();
}
此XML为工行1.0.0.11接口的XML格式拼接,tranData为工行接口实体
|