[英]How to consume an Apache CXF JAX-RS Client WebService
他们在这里说,有3种方法可以在apache cxf中建立一个休息客户端
我的问题是:
1)我遵循第一种方法-注入代理,我错过了什么吗?
2)如何通过使用apache cxf spring配置使用jax-rs Web服务(安全签名证书)?
网络服务网址:
http://localhost:8080/services/userSvc/getUserInfo?param1=value1¶m2=value2"
UserInfoSvc.java:
// What code should be written here
application-context.xml:
<jaxrs:client id="restClient"
address="http://localhost:8080/services/userSvc/getUserInfo"
serviceClass="com.example.client.UserInfoSvc"
inheritHeaders="true">
<jaxrs:headers>
<entry key="Accept" value="text/json"/>
</jaxrs:headers>
您可以使用http-conduit在application-context.xml中为您的客户端指定证书。
<http:conduit name="*.http-conduit">
<http:tlsClientParameters>
<sec:keyManagers keyPassword="${ssl.keystorepassword}">
<sec:keyStore type="JKS" password="${ssl.keystorepassword}"
file="${ssl.keystorefile}" />
</sec:keyManagers>
<sec:cipherSuitesFilter>
<sec:include>.*_EXPORT_.*</sec:include>
<sec:include>.*_EXPORT1024_.*</sec:include>
<sec:include>.*_WITH_DES_.*</sec:include>
<sec:include>.*_WITH_AES_.*</sec:include>
<sec:include>.*_WITH_NULL_.*</sec:include>
<sec:exclude>.*_DH_anon_.*</sec:exclude>
</sec:cipherSuitesFilter>
</http:tlsClientParameters>
<http:authorization>
</http:authorization>
<http:client AutoRedirect="true" Connection="Keep-Alive" />
</http:conduit>
注意:在我的情况下,由于我使用name="*.http-conduit"
,因此将HTTP管道应用于所有服务,您可以自定义以用于sepcifc服务或代理,有关详细信息,请参阅此处
http和sec的名称空间是
xmlns:http="http://cxf.apache.org/transports/http/configuration"
xmlns:sec="http://cxf.apache.org/configuration/security"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.