Java 如何在Camel';调用外部服务的http组件?

Java 如何在Camel';调用外部服务的http组件?,java,spring-boot,apache-camel,jsse,camel-http,Java,Spring Boot,Apache Camel,Jsse,Camel Http,下面是我用来调用外部服务的配置路由 services\u routes.xml <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context

下面是我用来调用外部服务的配置路由

services\u routes.xml

 <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">


    <routeContext id="servicesCommonRoutes"
        xmlns="http://camel.apache.org/schema/spring">

        <route id="Route">
            <from uri="direct:route" />
            <marshal>
                <custom ref="Request" />
            </marshal>
            <setHeader name="Content-Type" inheritErrorHandler="true">
                <constant>application/json</constant>
            </setHeader>
            <setHeader name="CamelHttpMethod">
                <constant>POST</constant>
            </setHeader>
            <to uri="{{svrRouteEndpoint}}" />
            <unmarshal>
                <custom ref="Response" />
            </unmarshal>
        </route>

    </routeContext>
</beans> 
Service.java

@Autowired
private ProducerTemplate template;
    
 @Value("${svrApiKey}")
private String svrApiKey;


public Response process(Request req, Map<String, Object> headers) throws CamelExecutionException {
    Response response = template.requestBodyAndHeaders("direct:route", req, headers, Response.class);
    return response;
}

 public Map<String, Object> createHeaders(String xWuExternalrefid) {
    Map<String, Object> headers = new HashMap<>();
    headers.put("x-api-key", svrApiKey);
    return headers;
}
@Autowired
私有产品模板;
@值(“${svrApiKey}”)
私有字符串密钥;
公共响应进程(请求请求、映射头)抛出CAMELEExecutionException异常{
响应=template.requestBodyAndHeaders(“direct:route”、req、headers、Response.class);
返回响应;
}
公共映射createHeaders(字符串xWuExternalrefid){
Map headers=newhashmap();
headers.put(“x-api-key”,svrApiKey);
返回标题;
}
问题:

现在,当我尝试使用提供的vpceURL访问AmazonAWS上托管的服务时,使用上述路径。我收到一个带有{“消息”:“禁止”}的禁止响应代码=“403”

除了“x-api-key”之外,访问该服务不需要其他头文件,因此有可能TLS版本在客户端与服务器端不匹配

我需要使用producerTemplate调用服务,但为此,我需要在Camel客户端上配置/确保TLSv1.2

那么,如何在中的我的路由上配置(xml)TLSv1.2 服务\u路由.xml(具有最低配置),以便producerTemplate/camel客户端能够访问该服务,并且将SSL强制为TLSv1.2


从浏览器/通用HTTP客户端调用vpce URI是否成功?有你?你有没有读过关于如何在与TLS相关的情况下使用vpce URI的内容,我不是很确定,因为在这方面应该存在连接问题,并且没有403禁止响应?IMO@RomanVottner,当使用带有提供头的PostAM/OKHttp客户机时,vpce URI是成功的,但当使用ApacheCamel从spring应用程序调用它时,它会给出禁止响应403,这表明客户端配置存在问题
@Autowired
private ProducerTemplate template;
    
 @Value("${svrApiKey}")
private String svrApiKey;


public Response process(Request req, Map<String, Object> headers) throws CamelExecutionException {
    Response response = template.requestBodyAndHeaders("direct:route", req, headers, Response.class);
    return response;
}

 public Map<String, Object> createHeaders(String xWuExternalrefid) {
    Map<String, Object> headers = new HashMap<>();
    headers.put("x-api-key", svrApiKey);
    return headers;
}