我正在尝试使用Apache CXF从Exact Target SOAP API检索3000条记录。 每个响应最多返回2500条记录。因此我得到“MoreDataAvailable”,但我无法得到剩余的数据。
以下是代码:
// Retrieve data
RetrieveRequestMsg retrieveRequestMsg = new RetrieveRequestMsg();
retrieveRequestMsg.setRetrieveRequest( retrieveRequest );
RetrieveResponseMsg retrieveResponseMsg = stub.retrieve( retrieveRequestMsg );
//System.out.println( "\n [Sends][overall status message] " + retrieveResponseMsg.getOverallStatus() );
results = retrieveResponseMsg.getResults();
while (retrieveResponseMsg.getOverallStatus().equals("MoreDataAvailable"))
{
// FIXME: THis does not work for some reason :(
retrieveResponseMsg = stub.retrieve( retrieveRequestMsg );
results.addAll(retrieveResponseMsg.getResults());
}
它不起作用 - 只需添加更多旧记录......
非常感谢任何帮助!
答案 0 :(得分:0)
结果我必须做一个全新的请求并将setContinueRequest设置为上一个响应消息的ID:
if (retrieveResponseMsg.getOverallStatus().equals(
"MoreDataAvailable")) {
RetrieveRequest retrieveRequestCont = new RetrieveRequest();
retrieveRequestCont.setContinueRequest(retrieveResponseMsg
.getRequestID());
RetrieveRequestMsg retrieveRequestMsgCont = new RetrieveRequestMsg();
retrieveRequestMsgCont.setRetrieveRequest(retrieveRequestCont) ;
RetrieveResponseMsg retrieveResponseMsgCont = stub
.retrieve(retrieveRequestMsgCont);
System.out.println("[overall status message] "
+ retrieveResponseMsgCont.getOverallStatus());
apiObjectArray = retrieveResponseMsgCont.getResults();
} else {
cont = false;
}
我在这里找到了: https://code.exacttarget.com/question/how-get-more-2500-records-using-java