1. 程式人生 > 其它 >org.dom4j.DocumentException: Error on line 1 of document : 前言中不允許有內容。

org.dom4j.DocumentException: Error on line 1 of document : 前言中不允許有內容。

 

我收到的應答報文: 

00000827<?xml version="1.0" encoding="UTF-8"?><transaction>
  <header>
    <ver>1.0</ver>
    <msg>
      <rcvAppCd>UCP</rcvAppCd>
      <callTyp>SYN</callTyp>
      <msgCd>WWWK.00066661.01</msgCd>
      <refSndAppCd>UCP</refSndAppCd>
      <refSndDt>20220506</refSndDt>
      <replyToQ>REP.TCP.GWIN</replyToQ>
      <seqNb>24718917283998</seqNb>
      <refMsgCd>WWWK.00066660.01</refMsgCd>
      <sndTm>161158</sndTm>
      <sndDt>20220506</sndDt>
      <sndAppCd>WWWK</sndAppCd>
      <refSeqNb>2471835137</refSeqNb>
    </msg>
    <status>
      <desc>success</desc>
      <appCd>WWWK</appCd>
      <retCd>000000</retCd>
    </status>
  </header>
  <body>
    <response>
  <studentId>1</studentId>
  <studentName>aoligei</studentName>
  <studentSex>men</studentSex>
  <studentAge>15</studentAge>
</response>
  </body>
</transaction>

 

應答報文前面有個8位的報文長度的字串,把這個去掉就可以了