welcome... infosys...to a talk about the exchange web services managed api code camp wellington 2009...
TRANSCRIPT
![Page 1: Welcome... infosys...to a talk about The Exchange Web Services Managed API Code Camp Wellington 2009 Adrian (Bert) Garrett-Tuck Infosys Limited 1](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649e855503460f94b88049/html5/thumbnails/1.jpg)
1
Welcome...
infosys
...to a talk about The Exchange Web Services Managed API
Code Camp Wellington 2009
Adrian (Bert) Garrett-TuckInfosys Limited
![Page 2: Welcome... infosys...to a talk about The Exchange Web Services Managed API Code Camp Wellington 2009 Adrian (Bert) Garrett-Tuck Infosys Limited 1](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649e855503460f94b88049/html5/thumbnails/2.jpg)
2
What we will cover
infosys
Welcome to Code Camp 2009!
• What is the Managed API?• The Exchange 2007 Web
Service• Interaction with the web
service via auto-gen’d proxy classes
• What is the EWS Managed API?• Why is it so much better?• Links and resources
![Page 3: Welcome... infosys...to a talk about The Exchange Web Services Managed API Code Camp Wellington 2009 Adrian (Bert) Garrett-Tuck Infosys Limited 1](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649e855503460f94b88049/html5/thumbnails/3.jpg)
3
The Exchange 2007 Web Service
infosys
• .NET 2.0 styles, SOAP web service.
• Is “the new guy” for Exchange 2007 interop
• Replaces WebDAV and CDOEX • Interact with it via VS
generated proxy classes. • Who’s done some work with it?
![Page 4: Welcome... infosys...to a talk about The Exchange Web Services Managed API Code Camp Wellington 2009 Adrian (Bert) Garrett-Tuck Infosys Limited 1](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649e855503460f94b88049/html5/thumbnails/4.jpg)
4
Interaction with the web service via auto-gen’d proxy classes
infosys
• Set up a binding• Create a request• Set request options (such as
folder, a view, whatever...• Set properties• Call the service & get a
response• Parse response
![Page 5: Welcome... infosys...to a talk about The Exchange Web Services Managed API Code Camp Wellington 2009 Adrian (Bert) Garrett-Tuck Infosys Limited 1](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649e855503460f94b88049/html5/thumbnails/5.jpg)
5
Interaction with the web service via auto-gen’d proxy classes
infosys
• Example 1 – Get inbox folder
GetFolderType request = new GetFolderType();
request.FolderShape = new FolderResponseShapeType();request.FolderShape.BaseShape =
DefaultShapeNamesType.AllProperties;
DistinguishedFolderIdType inboxId = new DistinguishedFolderIdType();
inboxId.Id = DistinguishedFolderIdNameType.inbox;
request.FolderIds = new BaseFolderIdType[] { inboxId };
GetFolderResponseType response = serviceBinding.GetFolder(request);
FolderInfoResponseMessageType responseMessage =response.ResponseMessages.Items[0] as
FolderInfoResponseMessageType;
if (responseMessage.ResponseClass == ResponseClassType.Success)
{ FolderType inbox = responseMessage.Folders[0] as
FolderType;}
![Page 6: Welcome... infosys...to a talk about The Exchange Web Services Managed API Code Camp Wellington 2009 Adrian (Bert) Garrett-Tuck Infosys Limited 1](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649e855503460f94b88049/html5/thumbnails/6.jpg)
6
Interaction with the web service via auto-gen’d proxy classes
infosys
• Example 2 – Find a folder called ‘Timesheet’
// Create the request and specify the traversal type.FindFolderType findFolderRequest = new FindFolderType();findFolderRequest.Traversal = FolderQueryTraversalType.Deep;
// Define the properties that are returned in the response.FolderResponseShapeType responseShape = new FolderResponseShapeType();responseShape.BaseShape = DefaultShapeNamesType.Default;findFolderRequest.FolderShape = responseShape;
// Identify which folders to search.DistinguishedFolderIdType[] folderIDArray = new DistinguishedFolderIdType[1];folderIDArray[0] = new DistinguishedFolderIdType();folderIDArray[0].Id = DistinguishedFolderIdNameType.msgfolderroot;
// Add the folders to search to the request.findFolderRequest.ParentFolderIds = folderIDArray;
// Send the request and get the response.FindFolderResponseType findFolderResponse = _binding.FindFolder(findFolderRequest);
if (findFolderResponse.ResponseMessages.Items[0].ResponseClass != ResponseClassType.Success){
throw new Exception(String.Format("Error:\r\n{0}\r\n{1}", findFolderResponse.ResponseMessages.Items[0].ResponseCode, findFolderResponse.ResponseMessages.Items[0].MessageText));
}
CalendarFolderType timesheetCalendarFolder = null;
foreach (BaseFolderType folder in ((FindFolderResponseMessageType)findFolderResponse.ResponseMessages.Items[0]).RootFolder.Folders){
if (folder is CalendarFolderType){
if (folder.DisplayName.ToLower() == "timesheet"){
timesheetCalendarFolder = (CalendarFolderType) folder;}
}}
if (timesheetCalendarFolder == null)return false;
// Form the FindItem request.FindItemType findItemRequest = new FindItemType();findItemRequest.ParentFolderIds = new[] {new FolderIdType()};findItemRequest.Traversal = ItemQueryTraversalType.Shallow;((FolderIdType) findItemRequest.ParentFolderIds[0]).Id =
timesheetCalendarFolder.FolderId.Id;findItemRequest.Item = _calendarView;
ItemResponseShapeType itemShapeDefinition = new ItemResponseShapeType();// Only need to retrieve the ItemId's in the find procedure...itemShapeDefinition.BaseShape = DefaultShapeNamesType.IdOnly;findItemRequest.ItemShape = itemShapeDefinition;
// Do the EWS Call...FindItemResponseType findItemResponse = _binding.FindItem(findItemRequest);// Check for errorsif (findItemResponse.ResponseMessages.Items[0].ResponseClass != ResponseClassType.Success){
throw new Exception(String.Format("Error:\r\n{0}\r\n{1}", findItemResponse.ResponseMessages.Items[0].ResponseCode, findItemResponse.ResponseMessages.Items[0].MessageText));
}
_findItemResponseMessage =(FindItemResponseMessageType) findItemResponse.ResponseMessages.Items[0];
_findCalled = true;return true;
70 Lines of Code to find a timesheet folder!
Another 30 lines to get some items out
![Page 7: Welcome... infosys...to a talk about The Exchange Web Services Managed API Code Camp Wellington 2009 Adrian (Bert) Garrett-Tuck Infosys Limited 1](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649e855503460f94b88049/html5/thumbnails/7.jpg)
7
What is the Managed API?
infosys
• Easier .NET Interop with Exchange 2007SP1 / 2010
• An additional assembly to reference
• Wraps up calls to the Exchange Web Service into simple methods.
• Significantly easier to use and manage than calling the web service via auto gen’d proxy directly
• 1.0 Beta • Will support all new features of
EWS as they become available.
![Page 8: Welcome... infosys...to a talk about The Exchange Web Services Managed API Code Camp Wellington 2009 Adrian (Bert) Garrett-Tuck Infosys Limited 1](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649e855503460f94b88049/html5/thumbnails/8.jpg)
8
Why is it so much better?
infosys
• Example 1
Folder inbox = Folder.Bind(service, WellKnownFolderName.Inbox);
• Example 2
Folder cal = Folder.Bind(service, WellKnownFolderName.Calendar); FolderView view = new FolderView(100);view.Traversal = FolderTraversal.Deep;view.PropertySet = new PropertySet(BasePropertySet.IdOnly);view.PropertySet.Add(FolderSchema.DisplayName);view.SearchFilter = new SearchFilter.ContainsSubstring(FolderSchema.DisplayName, "timesheet");FindFoldersResults result = service.FindFolders(cal.Id, view);Folder timesheetfolder = result[0];
![Page 9: Welcome... infosys...to a talk about The Exchange Web Services Managed API Code Camp Wellington 2009 Adrian (Bert) Garrett-Tuck Infosys Limited 1](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649e855503460f94b88049/html5/thumbnails/9.jpg)
9
Why it’s so much better!
infosys
• Saves a LOT of code!• Code is a lot more readable• Code is a lot more manageable
• Uses/wraps the Exchange 2007 Web Service – EWS here to stay
• Previously written web service proxy interop is not lost in vain
• Do upgrade when opportunity arises
![Page 10: Welcome... infosys...to a talk about The Exchange Web Services Managed API Code Camp Wellington 2009 Adrian (Bert) Garrett-Tuck Infosys Limited 1](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649e855503460f94b88049/html5/thumbnails/10.jpg)
Thanks and See Ya!
infosys
• Cheers for listening
Get slides fromhttp://www.infosys.co.nz
Links:• http://msdn.microsoft.com/en-u
s/library/dd633709.aspx
• http://blogs.msdn.com/mstehle/ (Matt Stehle, Exchange Team)