使用Grails Cxf Client Plugin设置disableCNCheck

时间:2013-06-14 21:37:11

标签: web-services grails https cxf grails-plugin

我正在尝试将disableCNCheck设置为true以用于我的Web服务。我正在使用Grails 2.2.0和Cxf Client插件。

我发现了这个问题:
wsdl2java CXF command line error about disableCNCheck option

使用这段代码:

protected void disableCNCheck(Object port) {
    Client client = ClientProxy.getClient(port)

    TLSClientParameters params = new TLSClientParameters()
    params.setDisableCNCheck(true)
    HTTPConduit httpConduit = (HTTPConduit) client?.getConduit()
    httpConduit?.setTlsClientParameters(params)
}

此代码属于哪个类,该方法将在何处调用?是否有我可以设置的Cxf客户端插件的配置参数?

1 个答案:

答案 0 :(得分:1)

您可以通过将以下xml配置添加到grails-app / conf / spring / resources.xml [Grails 2.2.3,cxf-client插件1.6.1

来代替代码来实现disableCNCheck。
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xmlns:http="http://cxf.apache.org/transports/http/configuration" 
       xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
            http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd
      "> 

  <http:conduit name="*.http-conduit"> 
    <http:tlsClientParameters disableCNCheck="true" /> 
  </http:conduit> 

</beans>