我使用Apache Camel CXF作爲生產者調用SOAP Webservice。我不使用Spring配置,但以編程方式執行所有操作(我是初學者,希望避免學習Spring和Apache Camel)。 Webservice使用帶有自簽名證書的SSL。我把它添加到信任,並希望能夠將它添加到CxfEndpoint類似我如何與https4做到了:Apache Camel CXF:以編程方式添加TlsClientParameters
KeyStoreParameters ksp = new KeyStoreParameters();
ksp.setResource("src/main/resources/truststore.jks");
ksp.setPassword("...");
KeyManagersParameters kmp = new KeyManagersParameters();
kmp.setKeyStore(ksp);
kmp.setKeyPassword("...");
SSLContextParameters scp = new SSLContextParameters();
scp.setKeyManagers(kmp);
CamelContext context = new DefaultCamelContext();
context.addRoutes(routeBuilder);
HttpComponent httpComponent = context.getComponent("https4", HttpComponent.class);
httpComponent.setSslContextParameters(scp);
- 但似乎不與CxfComponent工作。我發現了很多關於使用Spring添加TlsClientParameters和配置CxfEndpoint的文檔,例如:apache camel cxf https not working 和Calling secure webservice using CXF and Camel。但是我沒有找到關於如何爲我做了https4甚至在路線定義,這是一個信任簡單地添加到組件的任何提示:
from(ENDPOINT_URI)
.setProperty(SecurityConstants.PASSWORD, constant(PASSWORD))
.setProperty(SecurityConstants.USERNAME, constant(USERNAME))
.to("cxf://" + SERVICE_URL + "?" +
"wsdlURL=" + WSDL_URL + "&" +
"serviceName=" + SERVICE_NAME + "&" +
"portName=" + PORT_NAME + "&" +
"dataFormat=CXF_MESSAGE&" +
"synchronous=true&" +
"defaultOperationName=" + DEFAULT_OPERATION_NAME)
.streamCaching();
我想這一定是一個很簡單的問題,所以我仍然期望有一些簡單的方法可以簡單地添加信任庫(或者甚至接受任何證書,因爲它在我們的用例中並不相關)。如果有一個簡單的編程方法,我會非常高興。有人知道嗎?