gpt4 book ai didi

ssl - WSClient 无法在 https 上连接交换 wsdl

转载 作者:太空宇宙 更新时间:2023-11-03 13:19:18 26 4
gpt4 key购买 nike

我试图用 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。我这么说的原因是:我可以注释掉身份验证行,我得到了相同的结果。

有什么提示吗?

最佳答案

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

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

对于那些使用 exchange webservice 的人来说,还没有结束!您还需要修复一些错误:

  • 下载 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>

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

关于ssl - WSClient 无法在 https 上连接交换 wsdl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4254642/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com