【发布时间】:2021-01-04 02:00:35
【问题描述】:
我需要使用 XML 数据。 我的 XML 片段:
<TallyTransferResponse>
<Response>
<TransactionDocumentNo>iut-1</TransactionDocumentNo>
<FromLocation>Bangalore</FromLocation>
<ToLocation>Noida</ToLocation>
</Response>
<Response>
<TransactionDocumentNo>iut-2</TransactionDocumentNo>
<FromLocation>Bangalore</FromLocation>
<ToLocation>Mumbai</ToLocation>
</Response>
</TallyTransferResponse>
这是实体类的代码:
@Entity
public class TallyTransferResponse{
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
private String transaction_document_no;
private String from_location;
private String to_location;
public TallyTransferResponse() {}
/**
* @param transaction_document_no
* @param from_location
* @param to_location
*/
public TallyTransferResponse(String transaction_document_no, String from_location, String to_location) {
this.transaction_document_no = transaction_document_no;
this.from_location = from_location;
this.to_location = to_location;
}
//Getters and Setters
}
我不知道如何编写服务和控制器来使用这个 XML。
【问题讨论】:
-
您好,您能否详细说明一下您希望如何使用它,我的意思是是否有一个 REST 服务产生这个 XML 作为响应,或者文件系统中有一些文件,或者这个XML 数据来自其他来源,例如队列?
-
嗨,我正在尝试使用 XML 作为来自 Tally 的响应。
标签: java xml spring-boot jackson