Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Aws lambda Java中的AWS Lambda:如何调用API网关中公开的REST端点_Aws Lambda_Aws Api Gateway_Resteasy_Cxf Client - Fatal编程技术网

Aws lambda Java中的AWS Lambda:如何调用API网关中公开的REST端点

Aws lambda Java中的AWS Lambda:如何调用API网关中公开的REST端点,aws-lambda,aws-api-gateway,resteasy,cxf-client,Aws Lambda,Aws Api Gateway,Resteasy,Cxf Client,我代表API网关在AWS基础设施上公开了一个REST API。在Java中的Lambda函数中,我需要调用关联的端点。AWS文档建议使用API网关控制台生成客户端。然而,生成的客户端有几十个类,甚至可能有100个!当然,这不可能 是否有人使用RESTeasy或CXF客户端成功调用API网关公开的端点?甚至Apache HTTP客户端 非常感谢。我在回答我自己的问题。最后,我确认使用JAX-RS客户端与API网关的预期效果一样。在我的例子中,我更喜欢RESTeasy,但它也应该与CXF一起使用,甚

我代表API网关在AWS基础设施上公开了一个REST API。在Java中的Lambda函数中,我需要调用关联的端点。AWS文档建议使用API网关控制台生成客户端。然而,生成的客户端有几十个类,甚至可能有100个!当然,这不可能

是否有人使用RESTeasy或CXF客户端成功调用API网关公开的端点?甚至Apache HTTP客户端


非常感谢。我在回答我自己的问题。最后,我确认使用JAX-RS客户端与API网关的预期效果一样。在我的例子中,我更喜欢RESTeasy,但它也应该与CXF一起使用,甚至与ApacheHTTP客户机一起使用。以下是我所做的:

Maven依赖项:

  ...
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-bom</artifactId>
        <version>4.4.1.Final</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  ...
  <dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-client</artifactId>
    <version>4.4.1.Final</version>
    <exclusions>
      <exclusion>
        <groupId>org.jboss.spec.javax.xml.bind</groupId>
        <artifactId>jboss-jaxb-api_2.3_spec</artifactId>
      </exclusion>
      <exclusion>
        <groupId>com.sun.activation</groupId>
        <artifactId>jakarta.activation</artifactId>
      </exclusion>
    </exclusions>
  </dependency>
  <dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jaxb-provider</artifactId>
    <exclusions>
      <exclusion>
        <groupId>org.jboss.spec.javax.xml.bind</groupId>
        <artifactId>jboss-jaxb-api_2.3_spec</artifactId>
      </exclusion>
      <exclusion>
        <groupId>com.sun.activation</groupId>
        <artifactId>jakarta.activation</artifactId>
      </exclusion>
    </exclusions>
  </dependency>
  <dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jackson2-provider</artifactId>
  </dependency>
  ...
请注意,使用JAX-RS纯客户端如下:

...
private static Client client = ClientBuilder.newClient();
...
将不工作,并将引发以下异常:

javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x7933f1c0: Failure in SSL library, usually a protocol error
因此,为了解决这个问题,我需要使用RESTeasy(非JAX-RS)特定的东西,这是不好的。这是一个RESTeasy错误,应该在4.5中解决。然而,由于一些不推荐和重构(类ResteasyClientBuilderImpl不再存在,等等),我更喜欢使用4.4


因此,这样做正如预期的那样有效,Lambda函数成功地调用了通过API网关公开的REST端点,我不需要使用AWS控制台生成的巨大Java库。

这与其说是一个问题,不如说是一个讨论。我建议使用Lambda代理集成,而不是现在从API网关调用Lambda函数的“传统”方式。通过这种方式,您可以在自己的代码中处理路径(端点)逻辑。这是一个更好的体验。您只是在使用Swagger定义来生成Java客户机吗?我有点困惑,因为这与Lambda或API网关无关。一个高度复杂的API可能确实生成了100个类,尽管通常一个设计良好的API应该生成更少的类,而不管实现环境如何。@BjörnRaupach您不理解这个问题。我不从API网关调用Lambda函数,相反,我从Lamda函数调用通过API网关公开的端点。请确保你理解了你要问的问题:-)@stdunbar:既然你感到困惑,我会再解释一遍。这和大摇大摆没有任何关系,我也不知道你从哪里看到过大摇大摆的说法。API网关控制台有一个专用功能,可以为公开的端点生成客户端。您可以选择所需的语言,然后下载包含100个类的Java归档文件。在我看来,这个归档文件不仅包含调用API的客户端,还包含许多其他您不需要的东西,这使得这个“客户端”无法使用。因此我的问题是:是否有人为此使用Resteasy或CXF?
...
private static Client client = ClientBuilder.newClient();
...
javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x7933f1c0: Failure in SSL library, usually a protocol error