Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not possible to stream attachments via WebServiceTemplate and WebServiceMessageSender #1211

Open
koen-serneels opened this issue Sep 25, 2021 · 0 comments

Comments

@koen-serneels
Copy link

Using ClientHttpRequestMessageSender and setting 'setBufferRequestBody' to false:
HttpWebServiceMessageSenderBuilder httpWebServiceMessageSenderBuilder = new HttpWebServiceMessageSenderBuilder();HttpWebServiceMessageSenderBuilder httpWebServiceMessageSenderBuilder = new HttpWebServiceMessageSenderBuilder(); httpWebServiceMessageSenderBuilder.requestFactory(() -> { HttpComponentsClientHttpRequestFactory httpComponentsClientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory( configureHttpClient(HttpClients.custom(), endpointConfiguration, messageContextHolder)); httpComponentsClientHttpRequestFactory.setBufferRequestBody(false); return httpComponentsClientHttpRequestFactory; });

There is an exception thrown:  UnsupportedOperationException("getBody not supported");Which is caused by ClientHttpRequestConnection#getRequestOutputStream calling: AbstractClientHttpRequest#getBody -> HttpComponentsStreamingClientHttpRequest#getBodyInternal 

When using HttpComponentsMessageSender instead, it seems hardcoded to use an mem buffer for the actual attachment:
@Override protected void onSendAfterWrite(WebServiceMessage message) throws IOException { httpPost.setEntity(new ByteArrayEntity(requestBuffer.toByteArray()));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant