Citrus-Framework Soap over SSL 示例

Citrus-Framework Soap over SSL sample

我正在尝试使用 Citrus 框架来设置回归测试,因为我们将 Talend ESB 路由升级到最新版本。我们的路线主要是 Soap over SSL,由我们的本地 CA 保护并需要证书进行授权。我关注了 sample-soap 项目并让它暂时覆盖了证书要求。我迷路了,试图让它为客户端调用我们的 ESB 路由使用证书。我在 citrusframework.org 上找到了 sample-https 项目,但它似乎是为 Rest 服务制作的,我无法让它与我的 soap 有效负载一起使用。

我的最终目标是调用现有路由,然后调用最新版本的路由,并将返回的 XML 与某种 groovy 代码进行比较,以验证它们是否相同。

是否存在 Soap over SSL 示例,可以帮助我了解我的项目中做错了什么?

我试图将 sample-https 代码添加到我的 soap 项目,但没有成功。我得到的错误是 ssl-handshake 错误,我知道它与证书相关,因为我确定我没有在我的有效负载中附加有效证书。

您的配置必须与 https 示例略有不同。您必须在 Citrus SOAP Web 服务客户端上设置消息发件人:

<bean class="com.consol.citrus.samples.todolist.config.SoapClientSslConfig"/>

<citrus-ws:client id="todoClient"
                    request-url="https://localhost:8443"
                    message-sender="sslRequestMessageSender"/>

证书是在 http 客户端 SSL 上下文中配置的。

@Configuration
public class SoapClientSslConfig {

    @Bean
    public HttpClient httpClient() {
        try {
            SSLContext sslcontext = SSLContexts.custom()
                    .loadTrustMaterial(new ClassPathResource("keys/citrus.jks").getFile(), "secret".toCharArray(),
                            new TrustSelfSignedStrategy())
                    .build();

            SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(
                    sslcontext, NoopHostnameVerifier.INSTANCE);

            return HttpClients.custom()
                    .setSSLSocketFactory(sslSocketFactory)
                    .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                    .addInterceptorFirst(new HttpComponentsMessageSender.RemoveSoapHeadersInterceptor())
                    .build();
        } catch (IOException | CertificateException | NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) {
            throw new BeanCreationException("Failed to create http client for ssl connection", e);
        }
    }

    @Bean
    public HttpComponentsMessageSender sslRequestMessageSender() {
        return new HttpComponentsMessageSender(httpClient());
    }
}

示例代码现在也可在 github 上获得:https://github.com/christophd/citrus-samples/tree/master/sample-soap-ssl