A Case of Deploying a web application which includes WCF, Silverlight and ASP.NET part 2

Published on Monday, July 23, 2012

About our case’s deployment, I have posted the part 1 here. This article is the part 2.

We have done the discuss for Web Server settings and WCF configuration. Here we start from the 3rd part: Silverlight project configuration.

C> Silverlight project:

The Silverlight project or application also need to be set since it communicates with WCF services. you have to specify your right WCF service URL to Silverlight project or application. However, our smart Microsoft does NOT provide a similar config file with WCF or other applications, there is NOT a configuration file for Silverlight. All configuration information were involved in a binary file, which is a .xap file, Normally, you can find it under ClientBin folder.

image[47]

So what you should do is try to find a way to change the config information in this .xap file. There are also some solutions on the internet to tell programmer to use other ways to set information for Silverlight application, but by now I have not found a ideal solution. Maybe we need to research more about this.

OK, let us come back to try to set for Silverlight. actually, the way is simple, the .xap file is actually a compress file, it is a true .zip file !, so, my friend, the magic is here! Haha… Just change the extension name .xap to .zip (or for more safe, just like me, copy the .xap file to a .zip file), and unzip using your normal way to expand it. 

image[48]

Bingo! now you can see the expanded folder which includes lots of secret files!

image

What we need to care about is the ServiceReferences.ClientConfig file only, so we can ignore all other files here. Please use any text edit tool such as notepad to open this file, you can see the content is like the following:

image

Now I think smart you know what should do, yes, just use a correct WCF service address to replace the above green box wrapped content, our case is http://www.yourdomain.com/WebStage/ConsWCFServices which mentioned in part 1. and save it. and close the editor tool.

OK, you fixed the Silverlight configuration, one more step: please DO NOT forget to recover the .xap file

What we should do is just compress all the folder to a zip file again. and change the extension name to .xap file, that is.! But, please DO NOT compress the files out side of the files’ folder, but inside the folder please! so that you can get a compress file which does not include the folder itself. otherwise your .xap file will not work.

Maybe I need to teach you more details here even though it is a very simple step:

Make sure you are inside of the files’ folder; and choose all files in this folder, and then right mouse, choose a compress way due to your compress tools installed, for Windows 7, you just simply choose “send to” a compress file.  Again: you should make sure you are inside the folder, so that the generated zip file will NOT include the folder itself. This is also very important!

image

Finally, Change your .zip file to .xap file using the original file name. that is! The configuration for Silverlight done!

D> Website Project:

The most simple part is website in our case, we do not need any configuration for our website project since most of settings have already done on previous projects.

All we need to do is copy all web files including Silverlight project content (Web developer should prepare a complete website deployment package first. the package include website and Silverlight project,  you should do the Silverlight part configuration just like what I told above), We should copy the content to the virtual folder on IIS web server which we created in the part 1, in our case, the URL is:
http://www.yourdomain.com/WebStage/WebTerminal2012/

If you have finished all configuration successfully, and you have started the WCF Service, and you have copy all website files on IIS web server, now you should be able to visit your website.

Let me leave for other stuff. I might come back for more support information, in case of I find more.

Good luck!