Sunday, March 28, 2010

Consuming Exchange Web Service from Java – Proxy Generation

Download the WSDL and supporting files from your exchange server. Replace https://www.outlook.com/ with your exchange server details.

Add service definition to Services.wsdl file

<wsdl:service name="ExchangeServices">
    <wsdl:port name="ExchangeServicePort" binding="tns:ExchangeServiceBinding">
      <soap:address location="https://www.outlook.com/EWS/Exchange.asmx"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

Modify the import statement in types.xsd file as follows.

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

Now we are good to build the proxy files. Issue the following command to generate the ANT build file and java source files. Once you make further changes to the schema files and do not want to overwrite the build.xml file, you can use ‘--noBuildXML’ option for wsdl2java.

wsdl2java -u -uri Services.wsdl

When you build the files using, ANT, it gives compilation errors. I am not sure, why Axis fail to generate the files correctly. What I have done is to define the member variable for ‘localPathTracker’ in each of those files.

1 comment:

  1. Hi; I am having the same issue, can you advise on your last point which files and how to construct the localPathTracker ?? Your help would be much appreciated.

    ReplyDelete