views:

39

answers:

2

I have a Silverlight app that I want to access Azure storage. I have two projects in my solution: a SL project and a ASP web role.

The web role has a service. When I launch the project, I go to the service, and it works fine. (I am able to download the data.)

I'm not entirely sure what I can do through "Add Service Reference", but I suspect that might be what I'm supposed to do here to make use of the full power of WCF. I open the dialog box, and hit "Discover" to find services in my solution. Visual Studio finds my service, but when I click "Go" it fails with a 404 error. This is not terribly surprising, given that my ASP localhost server is not up at the moment.

It seems like I should be able to add the service reference when the devserver is running, but Visual Studio has the menu item to do so grayed out.

What am I supposed to do here? Am I completely confused about what service references are for? Should I just use WebClient, hardcode the URI, and de-serialize the XML into objects myself?

A: 

I think using WebClient is probably overkill. I wouldn't re-implement simply to get around a Visual Studio usability issue (even if it is tempting).

Try opening the projects separately. By this I mean opening two Visual Studios, one with the web service and one with the Silverlight application. Run the web service (so you cansee it working in a browser) and then create a service reference directly to the URL of the service running in debug mode in the other Visual Studio.

Once the service reference is created and all of the proxies are built you won't need to do this again unless you change the interface of the service.

James
A: 

James's answer will work. However, an easier option if you have both service and consumer projects in the same solution is to use the "Discover" button to the right of the "Go" button in the "Add Service Reference" dialog. If you click on the little arrow you will see it says "Services in Solution". This will then make VS search the solution for any valid services you have implemented and thus you don't need to have the service running at the time.

Another option is to run the service locally under IIS.

iamdudley