2

SOAP over https を使用して複数のデバイスと通信するサービスを構築しています。これらのデバイスは、同じ Web サービス API (同じ wsdl) を公開します。新しいデバイスは、実行時にいつでもこのスキームに追加できます。

これらの各デバイスと、将来追加される可能性のあるすべてのデバイスに対して、動的にクエリを実行する必要があります。これらの各デバイスには、ssl の自己署名証明書があります。私が構築しているサービスは、Spring Integration を使用して実装する必要があります。

上記を考えると、2つの主な質問があります。

  1. Spring Integration では、実行時に動的にサービス uri を割り当てるにはどうすればよいですか。
  2. すべての証明書を信頼するにはどうすればよいですか。

どんな助けでも大歓迎です。

4

2 に答える 2

1

ゲイリーとアルテムを助けてくれてありがとう。

動的 uri の問題は、スレッド ローカル変数と SPEL を使用して解決できました。

自己署名証明書を信頼するために、httpclient を使用して新しいメッセージ送信者を実装しました。HttpClient は TrustSelfSignedStrategy を提供します。これを使用して、すべての自己署名証明書を信頼しました。解決策は機能しているようです。以下は、将来同様のニーズがある場合のコードです。

    KeyStore trustStore  = KeyStore.getInstance(KeyStore.getDefaultType());

    InputStream instream = getClass().getResourceAsStream(trustStoreFile);

     try {
        trustStore.load(instream, trustStorePassword.toCharArray());
    } finally {
        instream.close();
    }

    SSLContextBuilder builder = new SSLContextBuilder();
    builder.loadTrustMaterial(trustStore, new TrustSelfSignedStrategy());
    SSLContext sslcontext = builder.build();

    SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext,SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
    HttpClientBuilder httpClientBuilder = HttpClients.custom();
    httpClientBuilder.setSSLSocketFactory(sslsf);
    httpClientBuilder.addInterceptorFirst(new RemoveSoapHeadersInterceptor());

    if (credentials!=null){
        CredentialsProvider credsProvider = new BasicCredentialsProvider();
        credsProvider.setCredentials(AuthScope.ANY,credentials);
        httpClientBuilder.setDefaultCredentialsProvider(credsProvider);
    }

    CloseableHttpClient closeableHttpclient = httpClientBuilder.build();
    setHttpClient(closeableHttpclient); 
于 2014-07-03T19:10:09.723 に答える
0

最初の質問は簡単です。XSD ドキュメントを参照してください。

The Destination URI for this Web Service Gateway. If the URI should be determined at runtime
(e.g. registry lookup), then configure a 'destination-provider' reference instead. Aternatively,
this URI may include {placeholders} whose values are determined by evaluating SpEL expressions
provided via 'uri-variable' sub-elements. The root object for those evaluations is the actual
request Message at runtime, i.e. you can access its payload or headers in the expression.

およびURI プレースホルダーに関するドキュメント

実行時にキーストア/トラストストアにキー/証明書を動的に追加できるかどうかはわかりません。私は試したことがない。

于 2014-07-02T20:25:09.763 に答える