Enterprise Integration Zone is brought to you in partnership with:

Enterprise Architect in HCL Technologies a $7Billion IT services organization. My role is to work as a Technology Partner for large enterprise customers providing them low cost opensource solutions around Java, Spring and vFabric stack. I am also working on various projects involving, Cloud base solution, Mobile application and Business Analytics around Spring and vFabric space. Over 23 yrs, I have build repository of technologies and tools I liked and used extensively in my day to day work. In this blog, I am putting all these best practices and tools so that it will help the people who visit my website. Krishna is a DZone MVB and is not an employee of DZone and has posted 64 posts at DZone. You can read more from them at their website. View Full User Profile

Doing HTTPS Communication with http:outbound-gateway

01.17.2013
| 3342 views |
  • submit to reddit

In Spring Integration if you have to do https communication when using http:outbound-gateway, you need to use the following trick,

<int-http:outbound-gateway id="my.outbound.gateway"
request-channel="request-channel" reply-channel="reply-channel"
url="https://localhost:8443/myservice/myService"
http-method="POST"
expected-response-type="java.lang.String">
</int-http:outbound-gateway>

Now you need to pass the keystore and trust store of the client and server as follows,

<bean id="trustStore">
<property name="targetObject" value="#{@systemProperties}" />
<property name="targetMethod" value="putAll" />
<property name="arguments">
<props>
<prop key="javax.net.ssl.trustStore"><jks key location></prop>
<prop key="javax.net.ssl.keyStorePassword">password</prop>
</props>
</property>
</bean>

<bean id="keystore">
<property name="targetObject" value="#{@systemProperties}" />
<property name="targetMethod" value="putAll" />
<property name="arguments">
<props>
<prop key="javax.net.ssl.keyStore"><jks key location></prop>
<prop key="javax.net.ssl.keyStorePassword">password</prop>
</props>
</property>
</bean>

There is also another way as mentioned in this article @ http://forum.springsource.org/showthread.php?115198-HTTPS-in-http-outbound-gateway

I hope this blog helped you.



Published at DZone with permission of Krishna Prasad, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)