Silverlight in the Mesh and the “Cloud” – Silverlight Mesh Enabled Web Application (Part 3) - DevCorner

Silverlight in the Mesh and the “Cloud” – Silverlight Mesh Enabled Web Application (Part 3)

Today I’ll talk about SMEWA (Silverlight Mesh Enabled Web Application) creation.

To create one (as for today) you need to be a member of Live Framework CTP. Invite to this CTP could be received through Microsoft Connect site.

After receiving the invitation key and redeeming it you will be able to download Live Framework SDK and Tools for Visual Studio and at Azure Services Developer Portal create new project – Live Framework CTP

image

After installing the Live Framework Tools for Visual Studio you will receive new project type (Live Framework) and will be able to create MEWA or SMWEA

image

I’ll create SMEWA. This creates 2 projects: one is actual Mesh Application, and another one is Silverlight application with references to 3 Live Framework DLL’s

image

Well, from here the things will be pretty easy (so I thought) and started to build my Cloud Store Management UI. I created pretty simple Silverlight application, which allows to see existing Blob objects, upload new file and delete exiting file. My UI final UI is looks like follows:

image

Giving the fact, that I created and tested all supporting web services already (in Part 2) the task was to create UI and connect it to those web services.

Well, I had the first “surprise” when tried to add reference to my “FileHandler” WebService (used web services description is here).

AddRef1

I’ve got proxy generation error:

AddRef2

Hmm… What is it… Why it failed?!?!? The test Silverlight app had no problem with it… I tried to learn from documentation, but frankly didn’t find any clear answer what is wrong. Here clearly stated, that “The Live Framework resource model is completely agnostic of any communication protocol or representation and no behavior is associated with the model. Live Framework resources, including FeedSync metadata, can be rendered to any wire format, such as POX, ATOM, RSS, or JSON.” So why not SOAP?

Well, I wanted to use existing services, so I had to find some solution… And I actually did – I removed 2 (out of 3) references to Live Framework and it worked:

AddRef4 AddRef5 AddRef6

Then I successfully added reference to my Cloud-based web service.

Basically, when I changed my WebMethods return parameters and input parameters to be simple .NET types (int, string, bool, etc. and not arrays, List<T>, etc.) I added the reference and called the WebService successfully.

Well – this was a small cheat, but what I will do in second SMEWA, when I will have to get the contents from the blob I just putted there and save it to Live Mesh Folder? Hmm… Stay tuned to the next part…

One small tip here – pay attention to web Service address being added to “ServiceReferences.ClientConfig”. You have to remove port (20000) before usage:

AddRef3

By removing the references to Live Framework I also lost an ability to use Live Services in my SMEWA. In next part I’ll deal with it also.

Actually, after all this trails with the management application I just removed created Silverlight application and added new standard Silverlight application. If you doing is you have to change references at Mesh Application also. When trying to debug this applications at the first time, you getting the dialog screen, which helps you to connect local application with Mesh Project:

image

The most important part there is Application Self-Link (it could be also added in Mesh Application project properties). After filling in the link Visual Studio upload the application to the Developer Mesh and opens it.

After my Silverlight application is loaded I’m executing asynchronous call to Web Service to get data:

//Create WebService SOAP Client
CloudStoreBL.FileHandlerSoapClient uploader = new ContentUploaderSilverlight.CloudStoreBL.FileHandlerSoapClient();
//Subscribe to completed events and handle returned data
uploader.GetFilesCompleted += (s, args) =>
{
    if (null != args.Error)
    {
      txtDebug.Text = "Error occured (" + args.Error.Message.ToString() + ")";
      txtDebug.Foreground = new SolidColorBrush(Colors.Red);
    }
    else
    {
      //assign returned results to list box
      lst.ItemsSource = args.Result;
      txtDebug.Text = "Ready";
      txtDebug.Foreground = new SolidColorBrush(Colors.Blue);
    }
};
//Perform the call
uploader.GetFilesAsync();

Here I got next problem – cross domain call exception. Well, it is pretty clear why I’m getting it – I’m running from https://developer.mesh-ctp.com/ and accessing web service at http://devcorner.cloudapp.net/.

All I have to do is to add clientaccesspolicy.xml to my Hosted Service:

image

After testing and debugging my SMEWA I was ready to upload it to the Mesh. I’ve uploaded the package and published the application:

image

All metadata about the application comes from Manifest.xml which is a part of package (and the Mesh Application project:

<?xml version="1.0" encoding="utf-8" ?>
<!-- 
The properties in the Manifest are applied when the application is uploaded through the Azure Services Developer Portal. 
They are not applied when debugging or running the application from Visual Studio. 
The following fields cannot be changed once the application is created:
      MultiInstance
      InstallReturnLink
      UnInstallReturnLink
      CallbackHomeLink
      RequireDelegation
If these fields are modified after the initial upload of the application, subsequent uploads will be rejected.
To successfully change these fields a new application must be created through the Developer Portal and 
the new Application Self-Link must be copied into the application’s project properties in Visual Studio.
-->
<Manifest xmlns="http://schemas.mesh.com/application/manifest/2008">
  <Name>Cloud Store Content Manager</Name>
  <Description>Cloud Store Content Management Application</Description>
  <PublisherName>DevCorner</PublisherName>
  <DisplayVersion>0.5</DisplayVersion>
  <MultiInstance>true</MultiInstance>
  <PrivacyPolicyLink>http://blogs.microsoft.co.il/blogs/alex_golesh</PrivacyPolicyLink>
  <SupportLink>http://blogs.microsoft.co.il/blogs/alex_golesh</SupportLink>
  <VendorLink>http://blogs.microsoft.co.il/blogs/alex_golesh</VendorLink>
  <RequireDelegation>false</RequireDelegation>
</Manifest>

Now I had to “install” this application to my Live Framework Mesh Desktop. I used “Install URL” from project properties page:

image

After giving myself permissions to use my application I created a new instance of it and gave it a name:

image

And now I had it on my Live Dsktop’:

image

Here the video of application execution:

Cloud Store Management SMEWA In Action

Well, this time I cheated a little bit – I created Silverlight application working in the Live Desktop  instead of real SMEWA with Live Services access… Next time I will have no choice but to deal with the problem I had today.

Stay tuned to the next part – I will create the real SMEWA with my Live Mesh folders access – my downloader UI will save the contents from Blob to the “Cloud Store Content” folder at my Live Desktop.

 

Enjoy,

Alex

Published Sunday, January 18, 2009 11:41 AM by Alex Golesh

Comments

# re: Silverlight in the Mesh and the “Cloud” – Silverlight Mesh Enabled Web Application (Part 3)

Hi,

A couple of related questions, which hopefully you could answer.

Q1. If I'm running a Silverlight app from www.mysite.com and accessing blobs from mysite.blob.core.windows.net do I need to add a clientaccesspolicy.xml to mysite.blob.core.windows.net?

Q2. I've successfully stored image tiles on mysite.blob.core.windows.net and have a Silverlight multiscaleimage correctly accessing the tiles and displaying the image.  But when I try to MANUALLY access the same tiles via WebClient.OpenReadAsync(uri) I'm unable to get beyond a SecurityException in the completion routing for the WebClient.  The tiles are available via mysite.blob.core.windows.net if I type the url directly into the browser address bar, so the problem isn't related to the public access setting for a folder.  

Should I be able to access blob storage via WebClient in Silverlight?

Thanks!

- Jay

Monday, January 19, 2009 9:32 AM by jaybo

# re: Silverlight in the Mesh and the “Cloud” – Silverlight Mesh Enabled Web Application (Part 3)

Hello Jay,

Thanks for the questions.

The answers are:

Q1. Yes, you must have clientaccesspolicy.xml to access it but you can't put it there - it is not a real site. I faced the same problem - wait for the next part to get the solution on it.

Q2. You cant do it because of absence of clientaccesspolicy.xml there. Short answer is - create cloud hosted service, and provide access to blob data through it.

Wait to part 4 - I'll show exactly how to deal with all this and some other problems.

Regards,

Alex

Monday, January 19, 2009 10:17 AM by Alex Golesh

# re: Silverlight in the Mesh and the “Cloud” – Silverlight Mesh Enabled Web Application (Part 3)

Q2, continued.  But how can the MultiScaleImage access the tiles?  Do Microsoft internal controls play by different rules, and ignore the need for ClientAccessPolicy.xml?

Monday, January 19, 2009 11:12 AM by Jay

# re: Silverlight in the Mesh and the “Cloud” – Silverlight Mesh Enabled Web Application (Part 3)

Jay,

Q2: They play the same rules I believe.

To get an access from multiscale image you have to build some functionality which will access the data and get you back whatever you need (the tiles) from one hand, and will be hosted somethere where you could have clientaccesspolicy.xml (Azure Hosted Services for example)

Regards,

Alex

Monday, January 19, 2009 12:54 PM by Alex Golesh

# Silverlight in the Mesh and the “Cloud” – Silverlight Mesh Enabled Web Application (Part 3)

Thank you for submitting this cool story - Trackback from DotNetShoutout

Thursday, January 22, 2009 2:00 AM by DotNetShoutout

# Silverlight in the Mesh and the “Cloud” – Silverlight Mesh Enabled Web Application and Azure Services (Part 4)

Hello, In previous parts ( Part 1 , Part 2 , Part 3 ) we have seen how to create Azure Hosted Service

Friday, January 23, 2009 9:54 AM by DevCorner

# re: Silverlight in the Mesh and the “Cloud” – Silverlight Mesh Enabled Web Application (Part 3)

Interessante Informationen.

Friday, March 06, 2009 6:04 PM by ...

# re: Silverlight in the Mesh and the “Cloud” – Silverlight Mesh Enabled Web Application (Part 3)

Sehr gute Seite. Ich habe es zu den Favoriten.

Friday, March 13, 2009 9:08 AM by ...

# re: Silverlight in the Mesh and the “Cloud” – Silverlight Mesh Enabled Web Application (Part 3)

Hello!!! blogs.microsoft.co.il is one of the best resourceful websites of its kind. I take advantage of reading it every day. All the best.

Monday, December 14, 2009 2:36 AM by cash advance

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: