Java 无法使用jaxb将xml转换为pojo

Java 无法使用jaxb将xml转换为pojo,java,soap,jaxb,Java,Soap,Jaxb,我正在尝试将xml转换为pojo。 这些pojo是使用jaxb eclipse插件从xsd生成的 Xml是: <?xml version="1.0"?> <NIServicesResponse>   <header>     <version>1.0</version>     <msg_id>12345</msg_id>     <msg_type>ENQUIRY</msg_type>

我正在尝试将xml转换为pojo。 这些pojo是使用jaxb eclipse插件从xsd生成的

Xml是:

<?xml version="1.0"?>
<NIServicesResponse>
  <header>
    <version>1.0</version>
    <msg_id>12345</msg_id>
    <msg_type>ENQUIRY</msg_type>
    <msg_function>REP_CREDIT_CARD_BALANCE_ENQUIRY</msg_function>
    <src_application>MIB</src_application>
    <target_application>VISIONPLUS</target_application>
    <timestamp>2019-01-28T14:11:15.927+04:00</timestamp>
    <tracking_id>2213695</tracking_id>
    <bank_id>ADCB</bank_id>
  </header>
  <body>
    <srv_rep>
      <exception_details>
        <application_name>NITIB_TCC_BRK_ADCB_SS</application_name>
        <date_time>2019-01-28T14:11:15.927+04:00</date_time>
        <status>S</status>
        <error_code>000</error_code>
        <error_description>Success</error_description>
        <transaction_ref_id>2213695</transaction_ref_id>
      </exception_details>
      <rep_credit_card_balance_enquiry>
        <balance_enquiry>
          <card_no>5261XXXXXXXX5793</card_no>
          <card_brand>MASTERCARD</card_brand>
          <card_currency>AED</card_currency>
          <card_limit>40000.00</card_limit>
          <available_credit>42456.00</available_credit>
          <cash_limit>24000.00</cash_limit>
          <available_cash>25200.00</available_cash>
          <outstanding_balance>-456.00</outstanding_balance>
          <expiry_date>01/01/2021</expiry_date>
          <overlimit_flag>N</overlimit_flag>
          <overlimit_amount>0.00</overlimit_amount>
          <min_payment>0.00</min_payment>
          <due_date>09/11/2018</due_date>
          <unbilled_amount>0.00</unbilled_amount>
          <past_due_flag>N</past_due_flag>
          <past_due_amount>0.00</past_due_amount>
        </balance_enquiry>
      </rep_credit_card_balance_enquiry>
    </srv_rep>
  </body>
</NIServicesResponse>
使用以下代码将其解组:

JAXBContext jaxbContext = JAXBContext.newInstance(NIServicesResponse.class);
            Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
            NIServicesResponse niServicesResponse = (NIServicesResponse)unmarshaller.unmarshal(httpResponse.getEntity().getContent());
转换时会产生错误

javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"NIServicesResponse"). Expected elements are <{http://adcb.com/poc/wiremock}NIServicesResponse>

我曾尝试将简单的xml转换为pojo,但效果不错。但是无法找出我的pojo有什么问题。

您不需要使用名称空间=
如果没有xmlns=http://adcb.com/poc/wiremock 内部

感谢您的回复,但从@XmlRootElement中删除名称空间无效,并且出现了相同的错误occures@AmitSharma你确定你重新编译并重新部署了所有内容吗?@AmitSharma那么你确定你发布了最新的代码吗?我已经在IDE中使用unmarshaller.unmarshalnew对其进行了测试StringReaderyYour xml,其中@XmlRootElementname=NIServicesResponse,命名空间=http://adcb.com/poc/wiremock 它抛出完全相同的异常。对于@XmlRootElementname=NIServicesResponse公共类NIServicesResponse,它不会。因此,您应该尝试清理并重建项目。pojo中有很多行。也许把它修剪一下,只剩下必要的部分?
javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"NIServicesResponse"). Expected elements are <{http://adcb.com/poc/wiremock}NIServicesResponse>