1

我试图用 groovy WSClient 连接到 Exchange 服务器 wsdl,但不能,因为我收到一个空文件(当我想解析 wsdl 时)。我正在使用以下几行:

Map mapClient=[
                    "https.truststore":"/path/jssecacerts",
                    "https.truststore.pass":"changeit",
                    "https.keystore":"/path/cacerts",
                    "https.keystore.pass":"changeit"
    ]

    def proxy=new WSClient("https://mail.exchangeserver:443/ews/services.wsdl", this.class.classLoader)
    proxy.setSSLProperties(mapClient)
    proxy.setBasicAuthentication("user","password")
    proxy.initialize()

由于空文件上的 xml 解析错误,它基本上在 proxy.initialize() 处失败。但是,当我使用浏览器时,我有完整的 wsdl 文件。

这不是 SSL 握手,因为我已经奋斗了几个小时才能让它工作。这是我遇到的第一个错误...

我认为这是出于某种原因错误的 BasicAuthentication 。我这么说的原因是:我可以注释掉身份验证行并且我有相同的结果。

有什么提示吗?

4

1 回答 1

2

好的,从另一个论坛,我得到了答案。这是 apache CXF(groovy WSClient 的后端)的一个已知限制,它仅在使用 web 服务时才使用凭证,而不是在获取 wsdl 时!解决方法是在本地加载 wsdl 并使用以下命令构建 WSClient:

new WSClient(this.class.classLoader.getResource("services.wsdl").toExternalForm(), 
             this.class.classLoader)

对于那些使用交换网络服务的人来说,它还没有完成!您还需要修复一些错误:

  • 下载 messages.xsd 和 types.xsd 以及 services.wsdl
  • 修复 types.xsd 替换行

    <xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
    

经过

 <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>

最后修复 services.wsdl 添加一个 wsdl:service 标签

  <wsdl:service name="ExchangeWebService">
     <wsdl:port name="ExchangeWebPort" binding="tns:ExchangeServiceBinding">
         <soap:address location="https://myserver/EWS/exchange.asmx" />
     </wsdl:port>
  </wsdl:service>

就是这样,它现在应该正确初始化了!

于 2010-11-24T11:19:08.467 回答