I have a REST API exposed on the AWS infrastructure on the behalf of API Gateway. In a Lambda function in Java I need to call the associated endpoints. The AWS documentation recommends to generate a client using the API Gateway console. However, the generated client has several dozens of classes, perhaps even 100 ! Of course, this couldn't be the way.
Did anyone succeed to call API Gateway exposed endpoints using RESTeasy or CXF clients ? Or even Apache HTTP Client ?
Many thanks in advance.
I'm answering my own question. Finally, I confirm that using JAX-RS clients works as expected with API Gateway. In my case, I preferred RESTeasy, but it should work with CXF as well or even with the Apache HTTp Client. Here is what I did:
Maven dependencies:
Please notice the exclusions meant to workaround the maven-shade-plugin which will overload different versions of the same artifacts.
maven-shade-plugin configuration:
Java client code:
Please notice that using JAX-RS pure client as below:
won't work and will raise the following exception:
Hence, in order to work around this, I needed to use RESTeasy (non JAX-RS) specific stuff, which isn't good. This is a RESTeasy bug and is supposed to have been solved in 4.5. However, due to some deprecations and refactorings (class ResteasyClientBuilderImpl doesn't exist any more, etc.) I preferred stay with the 4.4.
So, doing like this works as expected, the Lambda functions successfully call the REST endpoints exposed through API Gateway and I don't need to use the huge Java library generated with AWS console.