I had a hard time to figure out, how to contact and query a MS Exchange Server 2010 (SP2) using the build in webservices interface. Maybe someone else can profit from my findings. Following a working Perl script.

#!/usr/local/bin/perl use warnings; use strict; use Carp; use Carp::Heavy; use feature ":5.10"; use Data::Dumper; use Authen::NTLM; use LWP::UserAgent; # Debugging Mode XML::Compile #use Log::Report mode => 'DEBUG'; # preparation use XML::Compile::WSDL11; # use WSDL version 1.1 use XML::Compile::SOAP11; # use SOAP version 1.1 use XML::Compile::Transport::SOAPHTTP; my $uri = 'https://mex.ms-testlab.mg5/EWS/Exchange.asmx'; my $wsdlfile = 'Services.wsdl'; my $wsdl = XML::Compile::WSDL11->new($wsdlfile); $wsdl->importDefinitions('Types.xsd'); $wsdl->importDefinitions('Messages.xsd'); #say $wsdl->printIndex(); #say $wsdl->explain('GetServerTimeZones', PERL => 'INPUT', recurse => +1); #say Dumper($wsdl->operation('GetEvents')); my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 }, keep_alive => 1, ); $ua->agent('check_mex'); $ua->cookie_jar({}); $ua->credentials( 'mex.ms-testlab.mg5:443', '', 'mex.ms-testlab.mg5\\Administrator' => 'YourPassword' ); # Debugging (on UA level , like a packetsniffer) #$ua->default_header('Accept-Encoding' => scalar HTTP::Message::decoda +ble()); #$ua->add_handler("request_send", sub { shift->dump; return }); #$ua->add_handler("response_done", sub { shift->dump; return }); my $http = XML::Compile::Transport::SOAPHTTP->new( user_agent => $ua, address => $uri, ); my $client = $wsdl->compileClient( 'GetServerTimeZones', transporter => $http, ); my ($answer, $trace) = $client->( RequestVersion => { Version => 'Exchange2010_SP2', }, ); say 'ANSWER: ' . "\n" . Dumper($answer); #say 'TRACE: ' . "\n" . Dumper($trace); __END__

In reply to Contact Webservices on Microsoft Exchange Server by LANTI

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.