I have a question,
I can to configure spring-integration (or Spring Batch) to get a ZIP file and write the payload to a ZIP file?
I want to use HTTP Client 4.1 to provide credentials (username and password)
Thanks
--Marino
I have a question,
I can to configure spring-integration (or Spring Batch) to get a ZIP file and write the payload to a ZIP file?
I want to use HTTP Client 4.1 to provide credentials (username and password)
Thanks
--Marino
Last edited by mborra; Jan 18th, 2013 at 03:38 PM.
Write a custom Service (invoked by a <service-activator/>) that writes to a ZipOutputStream. There's also a ZipInputStream for reading zips.
I am not sure what relevance HTTP authentication has to this discussion.
Gary P. Russell
Spring Integration Team
SpringSource, a division of VMware
Thank you for your relpy Gary,
As I wrote in the subject, in fact my first problem is to configure Spring Integration to execute HTTP GET to download a ZIP file and only after this, write the payload (zip file) to a file.
With <service-activator/> i can get input-stream (payload) from <int-http:*inbound*/>
The authentication is required to perform the download.I am not sure what relevance HTTP authentication has to this discussion.
Last edited by mborra; Jan 18th, 2013 at 03:40 PM.
You have to run the Spring Integration HTTP inbound gateway in a Web Container (e.g. Tomcat); the container handles the authentication and it has nothing to do with Spring Integration.
If the zip file already exists, why do you need Spring Integration? Just return it as a static web resource.
If you need to create the file dynamically based on the request, do as I said, and write a service to get the request from the gateway, process it, create the zip file and return it.
Gary P. Russell
Spring Integration Team
SpringSource, a division of VMware
Hi!
As I understand you need to invoke external service who returns you a ZIP.
So, I recommend something like this:
Take care,HTML Code:<bean id="messageSender" class="org.springframework.ws.transport.http.HttpComponentsMessageSender"> <property name="credentials"> <bean class="org.apache.commons.httpclient.UsernamePasswordCredentials" c:userName="username" c:password="password"/> </property> </bean> <bean id="clientHttpRequestFactory" class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory" depends-on="messageSender" p:httpClient="#{messageSender.httpClient}"/> <http:outbound-gateway request-channel="getZipChannel" http-method="GET" expected-response-type="byte[]" url="http://host/ext-service?zipName={zipName}" request-factory="clientHttpRequestFactory"> <http:uri-variable name="zipName" expression="payload"/> </http:outbound-gateway>
Artem
Hi,
Yes! This is my problem.
Thank you Cleric, this is a good starting point, I imagined a similar solution, but i don't know how I can schedule outbound-gateway at fixed (cron) time, and then I've discarded my solution.So, I recommend something like this:
HTML Code:<bean id="messageSender" class="org.springframework.ws.transport.http.HttpComponentsMessageSender"> <property name="credentials"> <bean class="org.apache.commons.httpclient.UsernamePasswordCredentials" c:userName="username" c:password="password"/> </property> </bean> <bean id="clientHttpRequestFactory" class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory" depends-on="messageSender" p:httpClient="#{messageSender.httpClient}"/> <http:outbound-gateway request-channel="getZipChannel" http-method="GET" expected-response-type="byte[]" url="http://host/ext-service?zipName={zipName}" request-factory="clientHttpRequestFactory"> <http:uri-variable name="zipName" expression="payload"/> </http:outbound-gateway>
--Marino
Have a look at this section of the reference manual:
http://static.springsource.org/sprin...espace-inbound
You can define an inbound-channel-adapter with a cron-based poller that is upstream (e.g. its "channel" could be the "request-channel" of an outbound-gateway), and it can even include just an expression rather than ref+method if sufficient.
Mark Fisher
Spring Integration Lead
SpringSource, a division of VMware
http://www.springsource.com
http://www.springsource.org/spring-integration
http://blog.springsource.com/main/author/markf
Sorry, your question was not clear to me; I thought you were talking about serving up a zip file to a client - as Mark and Cleric have pointed out, if your app is the client then you can use an http outbound adapter.
Gary P. Russell
Spring Integration Team
SpringSource, a division of VMware