Am 2021-11-08 um 16:56 schrieb Oleg Kalnichevski:
On 11/8/2021 4:26 PM, Michael Osipov wrote:
Well, that is going to be a problem because the code in the low level
method looks like this:
CloseableHttpResponse downloadResponse =
httpClient.execute(downloadFile);
DataHandler dh = new DataHandler(new InputStreamDataSource(new
HttpResponseInputStream(
downloadResponse)));
dh is passed on to the return object and a high level class is
processing the response implicitly. I don't see way to make that work
in a closure.
Something like that. Give me a compilable code and will put the handling
logic into a closure.
```
Object result = httpclient.execute(downloadFile, response -> {
DataHandler dh = new DataHandler(new InputStreamDataSource(new
HttpResponseInputStream(response)));
return dh.handle();
});
```
I need to setup a small project next week. Give me a bit of time.
The above won't work because DataHandler is javax.activation.DataHandler
used with SOAP MTOM directly in the generated clients. I see no way to
return that input stream with a closure because it contrdicts the
closure concept.
I don't know how familiar you are with JAX-WS and MTOM, but those
DataHandlers are core concepts with are passed around with a readable
source either as input or output.
See also
https://docs.oracle.com/middleware/1212/wls/WSGET/jax-ws-mtom.htm#WSGET3485.
As of now, I am afraid that a closure will not be able to cover all
possible usecases.
Michael