My customers are using iPhone/Android, but I'm a Microsoft Guy.
- 2. My Customers Are Using iPhone/Android but I'm a Microsoft Guy/Gal Now What?DPR304Simon GuestDirector, Mobility SolutionsNeudesic, LLC
- 26. To give you the tools and knowledge to integrate iPhone, iPad, and Android devicesinto an existing Microsoft development environment
- 29. “Can I make an existing web site work on iPhone and Android?”
- 31. User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3; MS-RTC LM 8)HTTP RequestHTTP ResponsePagesWindows 7 / IE8.0
- 32. UserAgent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5HTTP RequestHTTP ResponsePagesiPhone OS 4.3
- 33. Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.3.1 Mobile/7B334b Safari/531.21.10HTTP RequestHTTP ResponsePagesiPad OS 4.3
- 34. Mozilla/5.0 (Linux; U; Android 2.3; en-gb; Nexus One Build/FRF50) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1HTTP RequestHTTP ResponsePagesAndroid 2.3
- 35. if (useragent contains ”MSIE”)…User-Agent: Mozilla/4.0 (compatible; MSIE8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3; MS-RTC LM 8)Windows 7 / IE8.0Pagesif (useragentcontains ”Android”)…Mozilla/5.0 (Linux; U; Android2.3; en-gb; Nexus One Build/FRF50) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1PagesAndroid 2.3
- 36. if (useragent contains ”MSIE”)…User-Agent: Mozilla/4.0 (compatible; MSIE8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3; MS-RTC LM 8)Windows 7 / IE8.0ViewCSSControllerif (useragentcontains ”Android”)…Mozilla/5.0 (Linux; U; Android2.3; en-gb; Nexus One Build/FRF50) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1ViewCSSAndroid 2.3
- 37. if (useragent contains ”MSIE”)…User-Agent: Mozilla/4.0 (compatible; MSIE8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3; MS-RTC LM 8)Windows 7 / IE8.0ViewCSSControllerif (useragentcontains ”Android”)…Mozilla/5.0 (Linux; U; Android2.3; en-gb; Nexus One Build/FRF50) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1ViewCSSAndroid 2.3
- 38. if (useragent contains ”MSIE”)…User-Agent: Mozilla/4.0 (compatible; MSIE8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3; MS-RTC LM 8)Windows 7 / IE8.0ViewCSSControllerASP.NET MVCViewEngineif (useragentcontains ”Android”)…Mozilla/5.0 (Linux; U; Android2.3; en-gb; Nexus One Build/FRF50) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1ViewCSSAndroid 2.3
- 39. Demo: Mobile View Engines in ASP.NET MVC 3All demos can be found on http://github.com/simonguest
- 41. User-Agent: Mozilla/4.0 (compatible; MSIE8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3; MS-RTC LM 8)Windows 7 / IE8.0ViewCSSControllerASP.NET MVCViewEngineMozilla/5.0 (Linux; U; Android2.3; en-gb; Nexus One Build/FRF50) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1ViewCSSAndroid 2.3
- 43. User-Agent: Mozilla/4.0 (compatible; MSIE8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3; MS-RTC LM 8)Windows 7 / IE8.0ViewCSSControllerASP.NET MVCViewEngineMozilla/5.0 (Linux; U; Android2.3; en-gb; Nexus One Build/FRF50) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1ViewCSSAndroid 2.3
- 44. Demo: Using jQueryMobile to create native look and feelAll demos can be found on http://github.com/simonguest
- 47. Use ASP.NET MVC 3 for improved HTML5 attributesWatch out for:Many different UI frameworks – choose carefully
- 48. MEAPs – Mobile Enterprise Application Platforms (auto gen’d UI from single source)
- 53. Native ApplicationISessionService.csREST [ServiceContract] public interface ISessionService {[WebGet(UriTemplate = "/Sessions", RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)] [OperationContract]SessionSummary[] GetData(); }iPad/iPhone OS 4.3 (ObjC)Android 2.3 (Java)
- 55. iPhoneClientViewController.m-(IBAction)callRESTService:(id)sender{ NSURL *url = [NSURL URLWithString:@"http://sguest01/TechEdDemoMVC/Services/REST.svc/Sessions"];NSMutableURLRequest *request = [NSMutableURLRequestrequestWithURL:url]; [request setHTTPMethod:@"GET"];connection = [[NSURLConnectionalloc] initWithRequest:requestdelegate:self]; if (connection) {NSLog(@"Connection was established");receivedData = [[NSMutableData data] retain]; }else {NSLog(@"Connection wasnull"); }}Native ApplicationRESTiPad/iPhone OS 4.3 (ObjC)Step 2: UseNSMutableURLRequest to call the service
- 56. iPhoneClientViewController.m- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{NSLog(@"Received response from the REST call"); [receivedData setLength:0];}-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{NSLog(@"Received data from the REST call"); [receivedDataappendData:data];}-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{NSLog(@"REST call failed with an error");}Native ApplicationRESTiPad/iPhone OS 4.3 (ObjC)Step 3: Handle callbacks
- 58. “REST appears to be fairly straightforward – but how about my services use SOAP?”
- 59. Native ApplicationiSOAP.cs [ServiceContract]public interface ISOAP{[OperationContract]List<SessionSummary> GetSessions();}SOAP (WS-I)iPad/iPhone OS 4.3 (ObjC)SOAP.svc.cspublic class SOAP : ISOAP{public List<SessionSummary> GetSessions(){// code to return active sessions}}Android 2.3 (Java)
- 65. iPhoneClientViewController.mBasicHttpBinding_ISOAPBinding *myBinding = [SOAP BasicHttpBinding_ISOAPBinding];myBinding.logXMLInOut= true;SOAP_GetTitleForCode*parameters = [[SOAP_GetTitleForCode new] autorelease];parameters.code= [[NSStringalloc]initWithString:[numberTextField text]];BasicHttpBinding_ISOAPBindingResponse*response = [myBindingGetTitleForCodeUsingParameters:parameters];NSArray*responseBodyParts = response.bodyParts;for (id bodyPart in responseBodyParts){NSString *message = [bodyPartGetTitleForCodeResult];}Native ApplicationSOAP (WS-I)iPad/iPhone OS 4.3 (ObjC)Option 3: wsdl2objc (http://code.google.com/p/wsdl2objc/)Version 0.7-pre1 recommended
- 66. Demo: Consuming REST and SOAP based services on iPhone/iPadAll demos can be found on http://github.com/simonguest
- 68. Native ApplicationRESTMain.javaHttpClienthttpClient = new DefaultHttpClient();HttpGetrequest = new HttpGet("http://sguest01/TRMobile/Services/REST.svc/Sessions");HttpEntityrestEntity= httpClient.execute(request).getEntity();String restResult= new BufferedReader(new InputStreamReader(restEntity.getContent())).readLine();Android 2.3 (Java)Step 1: UseHttpClient and HttpGet to makeconnection
- 69. Native ApplicationRESTMain.javaJSONArrayjArray = new JSONArray(restResult);for(inti=0; i<jArray.length(); i++){JSONObject session = jArray.getJSONObject(i);Log.i("Session retrieved", "Code: "+session.getString("Code")+" - "+session.getString("Title"));}Android 2.3 (Java)Step 2: Useorg.jsonlibraries to deserialize JSON
- 72. wsimportUsage: wsimport [options] <WSDL_URI>where [options] include: -b <path> specify jaxws/jaxb binding files or additional schemas (Each <path> must have its own -b) -B<jaxbOption> Pass this option to JAXB schema compiler -catalog <file> specify catalog file to resolve external entity references supports TR9401, XCatalog, and OASIS XML Catalog format. -d <directory> specify where to place generated output files -extension allow vendor extensions - functionality not specified by the specification. Use of extensions may result in applications that are not portable or may not interoperate with other...Native ApplicationSOAP (WS-I)Android 2.3 (Java)Youwouldthinkthatwsimportshouldwork
- 76. Main.javaString SOAP_ACTION = "http://tempuri.org/ISOAP/GetTitleForCode";String METHOD_NAME = "GetTitleForCode";String NAMESPACE = "http://tempuri.org/";String URL = "http://sguest01/TRMobile/Services/SOAP.svc";SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);request.addProperty("code","ARC310");SoapSerializationEnvelopeenv = new SoapSerializationEnvelope(SoapEnvelope.VER11);env.dotNet= true;env.setOutputSoapObject(request);HttpTransportSE transport = new HttpTransportSE(URL);transport.call(SOAP_ACTION, env);SoapPrimitivereturnedTitle = (SoapPrimitive)env.getResponse();Native ApplicationSOAP (WS-I)Android 2.3 (Java)
- 77. Demo: Consuming REST and SOAP based services on AndroidAll demos can be found on http://github.com/simonguest
- 89. REST request for listing all containersREST Endpoint:http://[account].blob.core.windows.netGET http://iostest.blob.core.windows.net/?comp=list&include=metadatax-ms-date: Thu, 14 Apr 2011 20:30:00 GMTx-ms-version: 2009-09-19x-ms-blob-type: BlockBlobAuthorization: SharedKeyiostest:[ComputedHash]Blob Storage
- 90. …but how do I get that computed hash?REST Endpoint:http://[account].blob.core.windows.netTo calculate the computed hash:AccountKey: /9seXadQ9HwOpXUO1jKxFN8q…Request: GETx-ms-blob-type:BlockBlobx-ms-date:Thu, 14 Apr 2011 20:30:00 GMTx-ms-version:2009-09-19/iostest/comp:listinclude:metadataHash = HMACSHA256(UTF8Encode(Request), Base64Decode(AccountKey))photosBlob StorageAccount Key: /9seXadQ9HwOpXUO1jKxFN8q…
- 91. GET http://iostest.blob.core.windows.net/?comp=list&include=metadatax-ms-date: Thu, 14 Apr 2011 20:30:00 GMTx-ms-version: 2009-09-19x-ms-blob-type: BlockBlobAuthorization: SharedKeyiostest:[ComputedHash]<?xml version="1.0" encoding="utf-8"?><EnumerationResultsAccountName="http://myaccount.blob.core.windows.net/"> <Prefix>c</Prefix> <MaxResults>3</MaxResults> <Containers> <Container> <Name>container1</Name> <Url>http://iostest.blob.core.windows.net/photos</Url> <Properties> <Last-Modified>Sun, 14 Apr 2011 20:09:03 GMT</Last-Modified> </Properties> </Container> </Containers>REST Endpoint:http://[account].blob.core.windows.netphotosBlob Storage
- 92. REST request (PUT) for adding a new photoREST Endpoint:http://[account].blob.core.windows.netPUT http://iostest.blob.core.windows.net/photos/myphoto.jpgx-ms-date: Thu, 14 Apr 2011 20:30:00 GMTx-ms-version: 2009-09-19x-ms-blob-type: BlockBlobAuthorization: SharedKeyiostest:[ComputedHash]{...binary representation of photo...}photosBlob Storage
- 94. Demo: Windows Azure Toolkit for iOS(http://github.com/microsoft-dpe)All demos can be found on http://github.com/simonguest
- 96. Token LengthPayload LengthJSON formattedAppRegistrationSend Message Payload0032deviceToken034messageApple Push Notification Servicegateway.sandbox.push.apple.comNative ApplicationAzure Role optimized for backgroundtasksWorker RoleiPad/iPhone OS 4.3.1User Acceptance
- 98. AppRegistrationSend Message PayloadApple Push Notification Servicegateway.sandbox.push.apple.comNative ApplicationWorker RoleRequestChangedSessionDetailsWindows Azure QueueiPad/iPhone OS 4.3.1Web RoleSessionUpdatedthrough WebUser AcceptanceUpdate QueueReceive Message, LaunchApp
- 99. Demo: Apple Push Notifications from ASP.NET MVCAll demos can be found on http://github.com/simonguest
- 103. Get a good development environment setup with Fiddler/CharlesWatch out for:Asyncvs Sync operation. Both iOS and Android support sync, but don’t use it!
- 105. “Many of Microsoft’s server products also expose REST/SOAP. What options exist for consuming these?”
- 107. Custom: Native Client to Services or Mobile Web Middle TierPackaged: Use AppStore/Market ClientiPad/iPhone OS 4.3Basic: Use OOB Mobile RenderingSharePoint Server2007/2010Android 2.3
- 110. Basic: Use OOB Mobile RenderingPros: Easy to setup, works out of the box (with SPS2010)Cons: Basic, non-native CSS. No support for browser-based NTLM from Android. No caching of username/password credentials.iPad/iPhone OS 4.3SharePoint Server2007/2010Android 2.3
- 111. Custom: Native Client to Services or Mobile Web Middle TierPackaged: Use AppStore/Market ClientiPad/iPhone OS 4.3Basic: Use OOB Mobile RenderingSharePoint Server2007/2010Android 2.3
- 115. Packaged: Use AppStore/Market ClientPros: Cheap ($10 – $20 per client). Multiple authentication schemes. Cached credentials. Some offline/sync support.Cons: All site content for mobile users. Leaf nodes are mostly read only HTML (e.g. Announcements). Most solutions are iPhone only (limited Android)iPad/iPhone OS 4.3SharePoint Server2007/2010Android 2.3
- 116. Custom: Native Client to Services or Mobile Web Middle TierPackaged: Use AppStore/Market ClientiPad/iPhone OS 4.3Basic: Use OOB Mobile RenderingSharePoint Server2007/2010Android 2.3
- 118. SPWeb (2007)ODATA (2010)iPad/iPhone OS 4.3Mobile Web Rendering of informationuseful to Mobile clientsASP.NET MVCMiddle Tier(jQueryMobile)SharePoint Server2007/2010Android 2.3
- 119. SPWeb (2007)ODATA (2010)iPad/iPhone OS 4.3Mobile Web Rendering of informationuseful to Mobile clientsASP.NET MVCMiddle Tier(jQueryMobile)SharePoint Server2007/2010Android 2.3
- 120. SPWeb (2007)ODATA (2010)Custom: Native Client or Middle Web TierPros: Complete custom solution. Can even hide fact that back end is SharePoint-based.Cons: More expensive option. Limitations with SOAP client libraries for iPhone/Android.iPad/iPhone OS 4.3Mobile Web Rendering of informationuseful to Mobile clientsASP.NET MVCMiddle Tier(jQueryMobile)SharePoint Server2007/2010Android 2.3
- 122. Custom: Native Client to Services or Mobile Web Middle TierPackaged: Use AppStore/Market ClientiPad/iPhone OS 4.3Basic: Use OOB Mobile RenderingDynamics CRM4.0/2011Android 2.3
- 124. iPad/iPhone OS 4.3Dynamics CRM4.0/2011Android 2.3http://www.microsoft.com/downloads/en/details.aspx?FamilyID=f592ec6c-f412-4fd5-9a80-cd3bcbd26d8b
- 127. Basic: Use OOB Mobile RenderingPros: Easy to setup, works out of the box. Forms based authentication works with non-NTLM browsers.Cons: Basic, non-native CSS. Controls a little awkward. No user-agent detection. No caching of username/password credentials.iPad/iPhone OS 4.3Dynamics CRM4.0/2011Android 2.3
- 128. Custom: Native Client to Services or Mobile Web Middle TierPackaged: Use AppStore/Market ClientiPad/iPhone OS 4.3Basic: Use OOB Mobile RenderingDynamics CRM4.0/2011Android 2.3
- 132. Packaged: Use AppStore/Market ClientPros: Offline access. Cached credentials.Cons: All site content for mobile users. Most solutions are iPhone only (limited Android)iPad/iPhone OS 4.3Optimized renderingDynamics CRM4.0/2011CWR/TenDigitsMiddle TierAndroid 2.3
- 133. Custom: Native Client to Services or Mobile Web Middle TierPackaged: Use AppStore/Market ClientiPad/iPhone OS 4.3Basic: Use OOB Mobile RenderingDynamics CRM4.0/2011Android 2.3
- 134. SOAP Web Services (4.0)REST Endpoint (2011)Updated Web Services (2011)ODATA (2011)iPad/iPhone OS 4.3Dynamics CRM4.0/2011Android 2.3
- 135. SOAP Web Services (4.0)REST Endpoint (2011)Updated Web Services (2011)ODATA (2011)iPad/iPhone OS 4.3Dynamics CRM4.0/2011Android 2.3Neudesic CRM Accelerator for iOS – http://neudesic.com
- 136. SOAP Web Services (4.0)REST Endpoint (2011)Updated Web Services (2011)ODATA (2011)iPad/iPhone OS 4.3Dynamics CRM4.0/2011Android 2.3
- 137. Custom: Native Client or Middle Web TierPros: Complete custom solution. Can even hide fact that back end is Dynamics-based.Cons: Limitations with SOAP client libraries for iPhone/Android. On CRM 2011, REST endpoint only provides limited CRUD. Web Service (SOAP) endpoint uses WS-Security with Kerberos.SOAP Web Services (4.0)REST Endpoint (2011)Updated Web Services (2011)ODATA (2011)iPad/iPhone OS 4.3Dynamics CRM4.0/2011Android 2.3
- 142. Custom is (IMO) the most interesting to customersWatch out for:Mobile Web is very basic
- 145. CRM 2011 Web Service uses WS-Security w/ Kerberos tokens“You’ve mentioned ODATA many times. What’s the story?”
- 149. Native ApplicationODATA.svc public class ODATA : DataService<SessionModelContainer>{ public static void InitializeService(DataServiceConfigurationconfig){config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;}}ODATAiPad/iPhone OS 4.3 (ObjC)WCFDataServiceEDMXSQL Server
- 152. iPhoneClientViewController.m-(IBAction)callODATAService:(id)sender{SessionModelContainer *proxy = [[SessionModelContaineralloc] initWithUri:@"http://sguest01/TRMobile/Services/ODATA.svc" credential:nil];QueryOperationResponse *response = [proxy execute:@"Sessions"];NSMutableArray *sessions =[response getResult]; for (id session in sessions) {NSLog(@"Session Code: %@",[session getCode]);NSLog(@"Session Title: %@", [session getTitle]); }NSLog(@"Complete");}Native ApplicationODataiPad/iPhone OS 4.3 (ObjC)WCFDataServiceEDMXSQL Server
- 156. Note: Must be done with the full JSE version of Restlet.jarlibraries (no generator in the Android version)!Native ApplicationProxy Generationlib Simon$ java -cp org.restlet.jar:org.restlet.ext.xml.jar:org.restlet.ext.atom.jar:org.restlet.ext.freemarker.jar:org.restlet.ext.odata.jar:org.freemarker.jar org.restlet.ext.odata.Generator http://sguest01/TRMobile/Services/ODATA.svc ~/Desktop/ARC310/restlet-proxy/---------------------------OData client code generator---------------------------...The source code has been generated in directory: /Users/Simon/Desktop/ARC310/restlet-proxyODATAAndroid 2.3WCFDataServiceEDMXSQL Server
- 157. Main.javaTrmobileWebModelsServiceservice = new TrmobileWebModelsService();Query<sessionmodel.Session> query = service.createSessionQuery("/Sessions?$filter=startswith(Code,'VIR')%20eq%20true");for (Session session : query){// do work}Native ApplicationODataAndroid 2.3WCFDataServiceEDMXSQL Server
- 158. Demo: Consuming an OData service on iPhone and AndroidAll demos can be found on http://github.com/simonguest
- 161. Easy to consume lists exposed by SharePoint 2010Watch out for:Anything that looks like SQL library on device
- 164. “…but I don’t want to learn Objective C or Java!”“I just want to do C#...”
- 165. Mono 1.0(C# 1.0)1.2(C# 2.0)2.0(C# 3.0)2.8(C# 4.0)MonoTouch 1.0MonoDroid 1.0SharpDevelopFull AOTMonoTouch 2.0/3.01.120042005200620072008200920102011
- 167. Demo: A simple application using MonoTouchAll demos can be found on http://github.com/simonguest
- 170. Features of .NET that are easier than ObjC and Java (LINQ, XML Parsing, Generics)Watch out for:No benefits for UI (UI Kit or main.axml)
- 175. Knowledge and tools to ensure that your apps are able to take full advantage of the Microsoft platform
- 177. Simon GuestDirector, Mobility Solutionssimon.guest@neudesic.comhttp://simonguest.com© 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista 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.