以下のコードを使用して、Web サーバーから添付ファイルを取得しています。この場合のクライアントは Web ブラウザです。そのため、現在、ユーザーは Web サーバーに添付ファイルのリクエストを行っています。Web サーバーは、別のサーバーに添付ファイルの MTOM 要求を行います。その Web サーバーは、添付ファイルがダウンロードされるのを待ってから、その添付ファイルを応答に書き出します。ユーザーは、ファイルを取得するために 2 倍の時間待機しています。Axis2 コードを利用して一時ファイルにアクセスし、作成中にユーザーにストリーミングできるようにするにはどうすればよいですか? これが最善の方法とは思えないことは承知していますが、これは要件です。最大 2GB の大きなファイルを扱っているので、ファイルを受信するまで 2 倍の時間を待ってもうまくいきません。
Options options = new Options();
options.setTo(new EndpointReference(this.endpointUrl));
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
options.setProperty(Constants.Configuration.CACHE_ATTACHMENTS, Constants.VALUE_TRUE);
options.setProperty(Constants.Configuration.ATTACHMENT_TEMP_DIR, this.tempDirectory);
options.setProperty(Constants.Configuration.FILE_SIZE_THRESHOLD, String.valueOf(this.tempFileSizeThreshold));
options.setTimeOutInMilliSeconds(this.serviceRequestTimeOut);
sender = new ServiceClient();
sender.setOptions(options);
OMElement result = sender.sendReceive(this.getAttachmentPayload(productId, attachmentId));
OMElement attachmentElement = result.getFirstElement();
Iterator<OMElement> elementIterator = attachmentElement.getChildElements();
String fileName = "";
DataHandler dataHandler = null;
while (elementIterator.hasNext()) {
OMElement element = elementIterator.next();
if (element.getQName().getLocalPart().equals("name")) {
fileName = element.getText();
} else if (element.getQName().getLocalPart().equals("attachment")) {
dataHandler = (DataHandler) ((OMText) element.getFirstOMChild()).getDataHandler();
}
}