问题描述
各位大侠帮帮忙,我需要把原始交易报文转换为xml格式。例子如下:原始交易报文:01/1108:32:02[DEBUG]MainframeEsbSAO:esb-sendData[1294705922102107]=CompositeData{"SYS_HEAD":CompositeData{"TRAN_TIMESTAMP":Field{type=FieldType[string]length=9scale=0value={083202119}}"MODULE_ID":Field{type=FieldType[string]length=4scale=0value={BOCP}}"SERVICE_SCENE":Field{type=FieldType[string]length=2scale=0value={02}}"USER_LANG":Field{type=FieldType[string]length=20scale=0value={CHINESE}}"TRAN_DATE":Field{type=FieldType[string]length=8scale=0value={20110111}}"CONSUMER_ID":Field{type=FieldType[string]length=6scale=0value={646429}}"CONSUMER_SEQ_NO":Field{type=FieldType[string]length=52scale=0value={000000}}"SERVICE_CODE":Field{type=FieldType[string]length=30scale=0value={01001000006}}}"BODY":CompositeData{"CCY":Field{type=FieldType[string]length=3scale=0value={RMB}}"CHARGE_TYPE":Field{type=FieldType[string]length=2scale=0value={1}}"AMT":Field{type=FieldType[double]length=20scale=4value={800.0}}"CASH_PROJECT_NO":Field{type=FieldType[string]length=4scale=0value={1110}}"CARD_NO":Field{type=FieldType[string]length=19scale=0value={6222980013108453}}"ACCT_TYPE":Field{type=FieldType[string]length=6scale=0value={5103}}"COMMISSION":Field{type=FieldType[double]length=20scale=4value={0.0}}"REMARK":Field{type=FieldType[string]length=300scale=0value={活期现金存入}}}"APP_HEAD":CompositeData{"BIZ_SEQ_NO":Field{type=FieldType[string]length=52scale=0value={CI00000003964084}}"USER_ID":Field{type=FieldType[string]length=30scale=0value={LIANGFENGJIN001}}"BRANCH_ID":Field{type=FieldType[string]length=9scale=0value={042}}}}01/1108:32:02[DEBUG]MainframeEsbSAO:esb-getData[1294705922102107]=CompositeData{"LOCAL_HEAD":CompositeData{}"SYS_HEAD":CompositeData{"TRAN_TIMESTAMP":Field{type=FieldType[string]length=10scale=0value={083202385}}"SERVICE_SCENE":Field{type=FieldType[string]length=2scale=0value={02}}"ORG_SYS_ID":Field{type=FieldType[string]length=0scale=0value={}}"TRAN_DATE":Field{type=FieldType[string]length=10scale=0value={20110111}}"CONSUMER_ID":Field{type=FieldType[string]length=6scale=0value={646429}}"CONSUMER_SEQ_NO":Field{type=FieldType[string]length=6scale=0value={000000}}"RET_STATUS":Field{type=FieldType[string]length=8scale=0value={S}}"ESB_SEQ_NO":Field{type=FieldType[string]length=42scale=0value={20110111809037585}}"RET":Array[1]{0:CompositeData{"RET_CODE":Field{type=FieldType[string]length=6scale=0value={000000}}"RET_MSG":Field{type=FieldType[string]length=4scale=0value={交易成功}}}}"SERVICE_CODE":Field{type=FieldType[string]length=11scale=0value={01001000006}}}"BODY":CompositeData{"SEQ_NO":Field{type=FieldType[string]length=52scale=0value={0001044411}}}"APP_HEAD":CompositeData{"APPR_USER_ID_ARRAY":Array[0]{}"QUERY_KEY_ARRAY":Array[0]{}"AUTH_USER_ID_ARRAY":Array[0]{}"SERV_SEQ_NO":Field{type=FieldType[string]length=50scale=0value={0001044411}}"USER_ID":Field{type=FieldType[string]length=15scale=0value={LIANGFENGJIN001}}"BRANCH_ID":Field{type=FieldType[string]length=3scale=0value={042}}}}需转换的xml:<?xmlversion="1.0"encoding="UTF-8"?><service><sys-header><dataname="SYS_HEAD"><struct><dataname="TRAN_TIMESTAMP"><fieldtype="string"length="9"scale="0">083202119</field></data><dataname="MODULE_ID"><fieldtype="string"length="4"scale="0">BOCP</field></data><dataname="SERVICE_SCENE"><fieldtype="string"length="2"scale="0">02</field></data><dataname="USER_LANG"><fieldtype="string"length="20"scale="0">CHINESE</field></data><dataname="TRAN_DATE"><fieldtype="string"length="8"scale="0">20110117</field></data><dataname="CONSUMER_ID"><fieldtype="string"length="6"scale="0">646429</field></data><dataname="CONSUMER_SEQ_NO"><fieldtype="string"length="52"scale="0">000000</field></data><dataname="SERVICE_CODE"><fieldtype="string"length="30"scale="0">01001000006</field></data></struct></data></sys-header><app-header><dataname="APP_HEAD"><struct><dataname="BIZ_SEQ_NO"><fieldtype="string"length="52"scale="0">CI00000003964084</field></data><dataname="USER_ID"><fieldtype="string"length="30"scale="0">LIANGFENGJIN001</field></data><dataname="BRANCH_ID"><fieldtype="string"length="9"scale="0">042</field></data></struct></data></app-header><local-header><dataname="LOCAL_HEAD"><struct></struct></data></local-header><body><dataname="BODY"><struct><dataname="CCY"><fieldtype="string"length="3"scale="0">RMB</field></data><dataname="CHARGE_TYPE"><fieldtype="string"length="2"scale="0">1</field></data><dataname="AMT"><fieldtype="double"length="20"scale="4">800.0</field></data><dataname="CASH_PROJECT_NO"><fieldtype="string"length="4"scale="0">1110</field></data><dataname="CARD_NO"><fieldtype="string"length="19"scale="0">6222980013108453</field></data><dataname="ACCT_TYPE"><fieldtype="string"length="6"scale="0">5103</field></data><dataname="COMMISSION"><fieldtype="double"length="20"scale="4">0.0</field></data><dataname="REMARK"><fieldtype="string"length="300"scale="0">活期现金存入</field></data></struct></data></body></service>
解决方案
解决方案二:
该回复于2011-03-12 09:27:37被版主删除
解决方案三:
该回复于2011-03-12 09:11:53被版主删除
解决方案四:
这涉及语法解析的东西就会变得很复杂呢
解决方案五:
该回复于2011-03-14 08:56:39被版主删除