Question

I was trying to connect with groovy WSClient to Exchange server wsdl, but can't because i receive an empty file (when i want to parse the wsdl). I am using the following lines:

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()

It basically fails at proxy.initialize() because of the xml parsing error on an empty file. However when i use the browser, i have the complete wsdl file.

This is not the SSL handshake, because i have fought for hours to get it working. It was the first error i got...

I think this is the BasicAuthentication that is wrong for some reason. The reason i say that is: I can comment out the authentication line and i have the same result.

Any hints?

Was it helpful?

Solution

Ok, from another forum, i got my answer. This is a known limitation of apache CXF (the backend of groovy WSClient) and it uses the credential only when using the webservice, not when fetching the wsdl! Workaround is to load the wsdl locally and build the WSClient using:

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

for those using exchange webservice, it is not finished! You need to fix some errors as well:

  • download the messages.xsd and types.xsd together with the services.wsdl
  • fix the types.xsd replacing the line

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

by

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

and finally fix the services.wsdl adding a wsdl:service tag

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

That's it, it should now initialize properly!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top