SOAP 応答は非常に大きく、Outofmemory 例外が発生する可能性があるため、Stream で SOAP 応答を提供する必要があります。エンティティが 20 のフィールドで構成されていて、10lakh 程度のレコードがないとします。誰もがそれを行う方法を知っています..???
public class ReportResponse{
private String name;
private String address;
private String number;
}
@WebService
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@SchemaValidation(handler = SchemaValidationCustomErrorHandler.class)
public class MyServiceEndpoint {
@Resource
private final ReportDispatcher dispatcher;
@Resource
WebServiceContext wsContext;
@WebMethod(operationName = "GetReport")
public List<ReportResponse> getReport()
throws GenericSoapFault {
final MessageContext messageContext = this.wsContext.getMessageContext();
final SAXParseException errorException = (SAXParseException) messageContext.get(SchemaValidationCustomErrorHandler.ERROR);
final SAXParseException fatalErrorException = (SAXParseException) messageContext.get(SchemaValidationCustomErrorHandler.FATAL_ERROR);
String errorMessage = null;
if (errorException != null) {
errorMessage = errorException.getMessage();
} else if (fatalErrorException != null) {
errorMessage = fatalErrorException.getMessage();
}
if (errorMessage != null) {
if (checkIfDateRangeError(errorMessage)) {
responseBuilder.withException(new ExceptionBuilder().withInvalidDatesError().build());
return responseBuilder.build();
}
throw new GenericSoapFault(errorMessage);
}
return this.dispatcher.generateReport();
}
}
ここで generateReport 関数は数十万程度の結果を提供します。そのために、ストリーミングを使用する必要があります... StreamingDataHandler クラスを見つけました...しかし、それを使用する方法がわかりません。