Showing posts with label WCF. Show all posts
Showing posts with label WCF. Show all posts

Wednesday, May 25, 2011

Creating a Windows Phone 7 app using WCF, and SQL Azure

Last night I gave a presentation with demos for fwPASS creating a Windows 7 app displaying a list of gymnasts from a SQL Azure database using WCF (Windows Communication Foundation). The WCF service used the Entity Framework and the .Net Membership provider.

The application was surprisingly easy to create despite the fact that were a lot of moving pieces with integration between all the different components.

The presentation covered the following tools:

 

All that in 70 minutes. Yes, I talk fast. This was a first time presentation. Below is the demo script I used:

Marketplace

1. Preview App Hub http://create.msdn.com

· Show app details text, iconography

Database

1. SSMS – show local ChalkChimp database

· Show script for creating additional users?

2. http://windows.azure.com SQL management interface

· No query designer

3. SQL Azure Migration tool

· Scripts out db

· Shows unsupported features

· deploys

4. Azure limitations in SSMS

· No query designer

· Admin account (other users don’t have access to the master database)

WCF

1. Create new project WCF Application

· Highlight Framework version 3.5

· Change binding to basicHTTPBinding

2. New Item à ADO.Net Entity

· Azure connection

3. Switch to finished project

4. Modify Iservice.cs, modify Service.cs implementation

5. Show .Net membership bits in web.config

6. View in browser (copy url)

WP7 client

1. Open Visual Studio (another)

2. New Project à Windows Phone 7 application

3. New item à Phone portrait page

4. Add Service reference

· Show service methods

· Advanced show generate async methods

5. Switch to finished project

· Show xaml bindings

· Show async methods and completed event handlers

· switch device to emulator

6. Run it

Optional

· Show property pages and iconography

 

Thursday, April 7, 2011

File URI invalid for WCF HTTP Endpoint

System.ArgumentException: The provided URI scheme 'file' is invalid; expected 'http'.

disconnectedThe error occurred when debugging a Silverlight app that uses Windows Communication Foundation (WCF). When running the debugger, the IDE was launching the html file hosting the Silverlight application, but it was launching it in the browser using a file path, F:\Projects\MyLOBApp\Bin\Debug\TestPage.html, not through IIS as http://localhost/MyLOBApp/TestPage.html. The application was using the following code in a global application class to set the URL to the WCF service.

public static string WebServiceUrlPath
{
    get
    {
        Uri uri = new Uri(Application.Current.Host.Source, "../AppDataService.svc");
        return uri.AbsolutePath.ToString(); 
    }
} 

My solution consists of two projects:


  1. The Silverlight application project
  2. The WCF service project

Upon closer inspection of the file path, Visual Studio was launching the test page from the Silverlight project when it should have been launching the test html page from the WCF project. The simple solution was to set the WCF project as the StartUp Project. That should have been more obvious especially in light of the following message box that popped up before the debugger started, but it was initially overlooked because of the similar project names and html page filenames in the two projects.


image


photo credit: satemkemet / CC BY-SA 2.0