Paul Robichaux paulrobichauxnet OUCB304 Mobile devices are important They are ubiquitous They represent both a huge opportunity and a huge risk in the enterprise BYOD Bring Your Own Disaster ID: 735067
Download Presentation The PPT/PDF document "Developing Mobile Apps with Exchange Web..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1Slide2
Developing Mobile Apps with Exchange Web Services
Paul Robichauxpaul@robichaux.net
OUC-B304Slide3
Mobile devices are important
They are ubiquitous.
They represent both a huge opportunity and a huge risk in the enterprise.
BYOD: Bring Your Own Disaster
Building custom apps for mobile use…
provides a high-value path for integrating mobile access into your core business operations.
Supplements desktop and web access to your line of business applicationsSlide4
Mobile platforms
There
are many popular platforms but 3 of them
are the clear leaders
.
Google Android: Java-based with sandboxed
Dalvik
VM
Windows Phone: XAML/CSS or native .NET Framework code
Apple
iOS
: Objective-C
Each platform has its boosters and detractors
Each platform can host HTML5 “apps”
But native apps still offer
far more flexibility and capability: access to sensors, persistent rich storage, offline/disconnected operation…Slide5
Exchange as a development platform
Exchange ActiveSync has won the device sync war
Robust, mature, incredibly broad device support
Even major competitors license it from Microsoft
Exchange Web Services provides rich access to data items in Exchange store + services
Data: calendar
and mail items, metadata (free/busy, OOF), user photos, and more
Provisioning: manage rules, search data, offer impersonation, and moreSlide6
What this session is
Coverage of using Exchange technologies to build apps for Apple
iOS
devices
Using Exchange ActiveSync services
Using Exchange Web Services features
Using Apple’s native development tools
Practical look at using
iOS
with these services
Unlike Windows Phone, no OS-level support for most of what we want to doSlide7
What this session is NOT
Discussion of using Exchange technologies to build apps for other mobile operating systems
Android: no thank you
Windows Phone: see the excellent developer-track sessions here at
TechEd
BlackBerry
Other nascent or moribund platforms
A complete guide to
iOS
developmentSlide8
What about the Managed EWS API?
Extremely robust, powerful set of APIs for accessing EWS from managed code
Managed code support on
iOS
requires third-party tools
Trying to integrate .NET managed code and
Obj
-C can be tricky
Limited support resources in the community
Great for desktop Windows & Windows Phone
But not a topic of discussion for us todaySlide9
The basic pattern
Pre-create XML blobs that contain the data we want to send
Most efficiently done by
building static strings and subbing in parameters
at runtime
Contents defined by EWS schema as published on TechNet
Experimentally verified by using Fiddler to monitor a WP8 device while it syncs
Send them to the server as HTTP POST
AsiHTTPConnection
helper class… not the latest but still works well
Parse the resulting XML
GDataXMLNode
provides
best balance of speed and simplicity of implementationSlide10
Using the basic pattern
Autodiscover: find the server we want to talk to
This will get us the URLs of all the EWS service endpoints
Services: do whatever it is our app does
Consume services exposed as URLs from the Autodiscover manifest
This might include UM, calendar/contact/mail access, modifying inbox rules…Slide11
Using AutodiscoverSlide12
Using Exchange ActiveSync
Protocol
specification offered by Microsoft for how to talk to Exchange from mobile devices
Fully documented online
Mostly of interest when you’re developing an entire client
Except for
Autodiscover, which everyone needsSlide13
Autodiscover
Goal: ask user for e-mail address and password, then find everything else we need without user action
Works differently for domain-joined and non-domain-joined clients
We will ignore domain-joined Autodiscover
So no SCPs, Kerberos, or Active Directory interaction
from our
iOS
appsSlide14
Autodiscover work flow
Collect user credentials
This is easy
Query well-known Autodiscover service points, in order
This is also easy if you read the Autodiscover
spec
At each step
we will either get a valid response, an error, or an HTTP redirect
Errors may include authentication requestsSlide15
Autodiscover in depth
Try HTTPS POST to
domain.com
/
autodiscover
/
autodiscover.xml
autodiscover.
domain.com
/
autodiscover
/
autodiscover
If those requests fail, then try
Unauthenticated HTTP GET to
autodiscover.
domain.com
/
autodiscover
/
autodiscover
DNS SRV query for _
autodiscover
._
tcp.
domain
Slide16
Autodiscover responses
Server may respond
with
302 redirect
AutoD
manifest
AutoD
error
response
403 error
404 error
HTTP
error if you wrote bad request
code
Exchange 2007/2010 may also emit 451 redirect
Most devices don’t handle it properly, which is why Exchange 2013 doesn’tSlide17
Autodiscover resources
The Exchange 2007 Exchange
Web Services book is pretty good
http://
blogs.msdn.com
/b/
exchangedev
/archive/2011/07/08/
autodiscover
-for-exchange-
activesync
-
developers.aspxSlide18
Autodiscover sample
if ([autoD
connectToServer
]) { self.serverURL
= [
autoD
serverURL
];
[
self.oof
getCurrentOOFState
];
}
…it takes hard work to look this good!Slide19
Example: OOF management with EWSSlide20
Demo
ExOOF: managing OOF properties with EWSSlide21
Exploring the AutoD
class
The only way to see everything we want to see is in
Xcode
…Slide22
How’d we get the OOF state?
ASIHTTPRequest
*
oofRequest = [
ASIHTTPRequest
requestWithURL
:
appDelegate.serverURL
]
;
ExUser
*who =
appDelegate.theUser
;
[
oofRequest
setUsername:who.userName
];
[
oofRequest
setPassword
:
who.userPassword
];
[
oofRequest
addRequestHeader
:@"Content-Type"
value
:[
NSString
stringWithFormat
:@"text/xml
;
charset
=utf-8"]];
[
oofRequest
appendPostData
:[[self request
]
dataUsingEncoding:NSUTF8StringEncoding]];
[
oofRequest
startSynchronous
]
;Slide23
What the server returns
OOF data is an XML document based on a defined EWS schema
So all we need to do is parse itSlide24
The rest of getCurrentOOFState
Let’s take a look and see what happens here…
Retrieve data from URL result
Ask
GDataXMLDocument
to parse it
Use
nodesForXPath
: to pick out the parts we care about
Tie the results into the UISlide25
Setting the OOF state
…basically a giant printf
()
We have values associated with controls/fields in the GUI
Retrieve those values, format them per the EWS OOF schema, and POST the data backSlide26
Example: Calendar managementSlide27
Calendaring
Mobile devices include calendar apps…
…but suppose you have a LOB app that you want to use the Exchange
calendar
Scheduling appointments
Reserving
resourcesSlide28
Demo
ExCal: viewing and managing calendar itemsSlide29
Getting calendar items
FindItem will retrieve items subject to the parameters you set
Base
folder: calendar, Inbox, sub folders,
etc
Start
/ end times
Item type
In this case we’re searching for calendar items
for the week of
TechEd
,
max 500Slide30
FindItem results
FindItem
gives us an XML structure containing the items of interest, if
any
May also return errors
We just iterate over them and add them to our list
viewSlide31
Our FindItem
request
<
FindItem
Traversal=\"Shallow\" xmlns
=\"
http://schemas.microsoft.com/exchange/services/2006/messages\">
<
ItemShape
><
t:BaseShape
>
IdOnly
</
t:BaseShape
>
<
t:AdditionalProperties
>
<
t:FieldURI
FieldURI
=\"
calendar:Start
\"/>
<
t:FieldURI
FieldURI
=\"
calendar:End
\"/>
<
t:FieldURI
FieldURI
=\"
item:Subject
\"/>
</
t:AdditionalProperties
>
</
ItemShape
>
<
CalendarView
MaxEntriesReturned
=\"500\"
StartDate
=\"2013-06-03T00:00:00-08:00\"
EndDate
=\"2013-06-07T00:00:00-08:00\"/>
<
ParentFolderIds
><
t:DistinguishedFolderId
Id=\"calendar\"/></
ParentFolderIds
>
</
FindItem
>Slide32
Displaying returned items
Let’s
examine
this
in
Xcode
…Slide33
Adding calendar items
EWS CreateItem
to the rescue!
CreateItem
expects a
shape
, or template
We create a basic shape and add specific properties to itSlide34
Building an item shape
Let’s
examine
this
in
Xcode
…Slide35
Nifty Exchange 2013 Things You Can DoSlide36
Use the Unified Contact Store
Unified Exchange & Lync contacts
Stored as “Lync Contacts” folder as subfolder of user’s Calendar folder
Add, remove, read items there using new UCS-specific operations
e.g.
AddNewImContactToGroup
,
GetImItemsSlide37
Work with high-resolution photos
Retrieve photos at multiple resolutions and sizes
648x648 is my favorite
Stored as FAI once user uploads & approves photo
Accessible via URL:
https
:/
/
server
/
ews/Exchange.asmx/s/GetUserPhoto?email
=
alias
&
size=
HR648x648
Accessible via EWS through new
GetUserPhoto
item (see MSDN)Slide38
Work with e-discovery & retention
Archive items
in the user’s Personal Archive
Modify, create, update discovery searches
Get / set / review retention tags and policiesSlide39
Track resources
My blog:
http://
paulrobichaux.wordpress.com
Exchange
Team Blog:
http
://blogs.technet.com/b/exchange
/
MSDN New Features in EWS
in Exchange 2013:
http://
msdn.microsoft.com
/en-us/library/exchange/jj190903(v=exchg.150).
aspx
Twitter
:
Follow
@
MSFTExchange
Follow @
PaulRobichaux
Join the conversation: use #
IAmMEC
Check
out:
Microsoft Exchange
Conference 2014:
www.iammec.com
Office 365
FastTrack
: http://fasttrack.office.com/
/
Technical Training with Ignite
: http://ignite.office.com
/Slide40
msdn
Resources for Developers
http://microsoft.com/msdn
Learning
Microsoft Certification & Training Resources
www.microsoft.com/learning
TechNet
Resources
Sessions on Demand
http://channel9.msdn.com/Events/TechEd
Resources for IT Professionals
http://microsoft.com/technet Slide41
Evaluate this session
Scan
this QR code
to
evaluate this session.
Required Slide
*delete this box when your slide is finalized
Your MS Tag will be inserted here during the final scrub. Slide42
© 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.
The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.