【问题标题】:How to consume an Apache CXF JAX-RS Client WebService如何使用 Apache CXF JAX-RS 客户端 WebService
【发布时间】:2015-01-03 22:42:01
【问题描述】:

他们说here 有 3 种方法可以在 apache cxf 中构建一个 REST 客户端

我的问题是:

1) 我遵循第一种方法 - 注入代理,我错过了什么吗?

2) 如何使用 apache cxf spring 配置使用 jax-rs webservice(安全签名证书)?

网络服务网址:

 http://localhost:8080/services/userSvc/getUserInfo?param1=value1&param2=value2"

UserInfoSvc.java:

   // What code should be written here

应用程序上下文.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>

【问题讨论】:

    标签: java spring web-services rest cxf


    【解决方案1】:

    您可以使用 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>
    

    注意:在我的情况下,http 管道适用于所有服务,因为我使用的是name="*.http-conduit",您可以自定义以用于 sepcifc 服务或代理以了解详细信息,请参阅 here

    http 和 sec 的命名空间是

    xmlns:http="http://cxf.apache.org/transports/http/configuration"
    xmlns:sec="http://cxf.apache.org/configuration/security"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多