-1

I am trying to connect to third party system over HTTPS connection and post parameters to receive a response. This is gonna be a POC I will be doing for which I am already started researching. I have already done a client-server TCP connection with an outbound gateway using SI in my spring application. Does SI provide a way to achieve HTTPS connection or is there any easier way, RestTemplate?

I could see Spring Integration - how to send POST parameters with http outbound-gateway, but it talks about HTTP rather than HTTPS.

Note: A linux server already communicates to this third party system using CURL. I need to replicate this communication in my spring application. Here is the sample Req / Res shared.

Request data: ord=000000&term=022&storenum=00623&fgen=667&action=1024&ctime=072119:22:23:32&tmout=08&PLU=00007565604633&BC=10364678071919225000623&QTY= 1.000

Response: 000000022006231024ctime=072119:22:23:32&itmz=P---11NSFU-T&desc=JARU ALL MN LT UP DIAMOND&rmfsline=1&avqty=1.0&barcode=10364678071919225000623&qty=1.0&rcptqty=3.0000&rcptline=5&upc=7565604633&reqqty=1.0&unitprice=1.97&price=5.91&dept=92&resp=00&POST /RMFSWeb/LineAuthListener? HTTP/1.1

Also, the URL shared with me is https://xx-cert.keb.com:20143 but this doesn't have a class/method name in the URL. Is it not required for an HTTPS connection?

Please share your thoughts on how I can achieve https connection from spring with the data above. Thanks for your help

stack123
  • 37
  • 1
  • 10
  • There is no different between HTTP and HTTPS in the business logic or request/reply processing. Only a difference is an SSL/TLS wrapping around regular HTTP request/replies. It really already a matter of transport layer configuration. Typically we just need to have a proper `cacerts` in Java. You also may take a look in a more advance SSL configuration in the Apache Commons HTTP Client: https://www.baeldung.com/httpclient-ssl – Artem Bilan Sep 29 '19 at 14:13
  • @ArtemBilan Here are my takeaways from and questions to your comment. Please correct me if I am wrong 1. Spring Rest template is the way I can go ahead with and not SI in this case. 2. The ref url shared doesn't say anything about certificates / truststore. 3. Assuming the certificate of the https url has to be added to the truststore in the server where my application is deployed. 4 Shouldn't the https url I shared have a `https://domain:port/{someService}/{someMethod}` since you said req/reply processing is the same as http? Right now its just `https://domain:port`. Please guide. – stack123 Sep 29 '19 at 17:29
  • 1. No correct. Spring Integration `HttpRequestExecutingMessageHandler` is fully based on the `RestTemplate`. The SSL configuration is fully not related. – Artem Bilan Sep 30 '19 at 13:12
  • 2. That's correct. You just use an HTTPS schema and underlying client will select an appropriate certificate in the store to attache with a request. – Artem Bilan Sep 30 '19 at 13:13
  • 3. That's correct, too. The SSL client sends a *key* with a request and server matches it with a certificate it has in the trust store. – Artem Bilan Sep 30 '19 at 13:14
  • 1
    4. There is really no difference in URLs. The REST API you should use depends on your provider. That's not HTTP or HTTPS matter. – Artem Bilan Sep 30 '19 at 13:16

1 Answers1

0

RestTemplate with PostRequest will do all your job.

Refer an answer by 'Tharshan' in this post.

How to POST form data with Spring RestTemplate?