What are the methods of communication between Silverlight and server side? - silverlight

Background:
I have basically no experience in Silverlight, i was asked to start reading up on the tech and provide some insight for client which may want to rebuild the UI of their .Net Desktop application in silverlight. So my experience is what i have been able to google (which surprisingly is not easy) and the few tutorials i have done.
I am aware Silverlight could use ASMX Web Service , WCF Services or REST to do communications with the server.
Question:
Are there any other official or non-official mothods of communication anyone knows of?
Thank you in advance,
David

Start here:
http://msdn.microsoft.com/en-us/library/dd470099(VS.95).aspx
http://videos.visitmix.com/MIX08/T13
http://videos.visitmix.com/MIX09/T42F
I am somewhat biased having worked on the technology :), but I would urge you to consider WCF.
This method gives you great usability: It literally takes a few minutes to "Add New... Silverlight-enabled WCF Service" to your project and have everything up-and-running. In Silverlight 3, this uses a very performant binary XML protocol under the covers, which can be easily switched to regular text XML for debuging with just a 2-line config change. And it integrates nicely with most authentication models that you would want (see the security section in the doc link above).
Of course, you can roll-your-own communication using HttpWebRequest, WebClient, or even sockets. Using WebClient is probably best if you want to go with REST on the server. Keep in mind that some things that are normally possible in REST (such as using PUT and DELETE HTTP verbs) are not possible in browser plugins such as Flash and Silverlight due to browser restrictions.
Finally, there's .NET RIA Services. It's a bit too heavy-weight for some scenarios and doesn't have some of the WCF features (like binary and duplex), but it's more than just a way to communicate with the server: It gives you a whole perscriptive framework for building SL apps with server-side data, and gives you a lot of nice features like validation, paging, etc. for free.

Related

Where do I start with developing a Silverlight app using Windows Workflow Foundation?

We are starting out with the development of a Silverlight app that will make use of Windows Workflow Foundation (WF4). Our workflows are long-running. We plan to use the tracking and persistence functionality of WF. We will probably need to also store data related to each workflow instance in another DB (I suspect running reporting against the workflow persistence store would be tricky). Our workflows may change with time so we would probably also need some strategy to implement versioning on them.
So specifically, are there any resources you can point me to or direction you can give me on where to start, taking into account that we need to implement tracking, persistence and versioning of workflows?
Based on your question, I'm assuming that you already have experience with WWF and are really just asking about how it interacts with Silverlight. The short answer is that it would not be noticeably different from how you would implement a WWF-enabled application in traditional ASP.NET. Remember that Silverlight is only a UI client that usually lives on top of a traditional ASP.NET web application. Your WWF-related logic and code would live in the ASP.NET layer -- not in Silverlight at all.
So if you already know how to make a WWF-enabled application in ASP.NET, all you really need to learn is how to wire up a shiny Silverlight interface to an ASP.NET web app. For that, you of course only need to hit up http://silverlight.net/, which you're probably already doing.
Good luck!

Creating basic push-style notification app using WPF and WCF?

I'm an asp.net developer with very little experience in WPF. I'm looking to create a very basic application, one that would be distributed to a couple clients and allow any given client to send a basic message to all of the others running the application.
I'm not exactly sure where to start or what to look for, being that I'm new to the WPF world. Could someone point me in the direction I need? Would it involve MSMQ? I'd like to stay away from polling if possible, but what generally would I need to know to get started? Thanks.
You could take advantage of the classes in the System.Net.PeerToPeer Namespace.
I did some push notification with WPF and WCF in 2006 using the framework classes from .NET 3.0 which were deprecated by System.Net.PeerToPeer in .NET 3.5 / 4.0, but the old system worked well, so I can only assume that the new classes in the framework are even better :-)
We used push notifications for the majority of data that didn't matter if it was missed by a client, but MSMQ for sending important occasional messages that absolutely could not be lost. You don't necessarily need MSMQ though - we were running mission-critical apps which demanded it, so we played it safe.
Click here to read the MSDN Magazine article that was published to introduced the new P2P namespace in 2007.

While porting a windows application to web, is it better to stick to conventional web technologies or adoping RIA is wise?

The web based application I am working on currently is a port from a windows application. This application is very data intensive. There are scores of modules and each of these modules have number of forms (data entry screens) and reports whereas the forms have many many fields and likewise the reports.
I have been trying to identify the most suitable architecture for the presentation tier. There are many functions that are not very easily portable, for example printing (this too is very complex). For most of the others, I am planning to us "Ext JS" library which looks like capable of handling about 70% of complexity out of the box while for the remaining I would be custom coding or extending Ext JS.
Having said that (sorry for being so descriptive), I wonder, if this is an Intranet application, why not port the entire application to SilverLight? While I am good at .Net, I'm somewhat alien to SilverLight. Considering I know my target audience and that the software will be used per seat license, would it be better to ride on SilverLight or is it better to stick to conventional web (XHTML, JS, CSS, etc)? Further, I have to support multiple devices in future and considering that SilverLight plug-ins for many devices are yet not out, would it be a risk?
IMO, if you are developing a web application, then yes, develop it as an RIA.
The choice of technology is up to you. I prefer jQuery and have never used ExtJS. But I've taken a look at it, and if your aplication is a port of a windows application and has a lot of conventional UI elements like forms, input boxes, toolbars, menus, button etc, then go for ExtJS.
As for some controls that are not available in ExtJS, you can easily extend ExtJS.
Regarding .NET: ExtJS is completely server-technology agnostic, so you can develop your application in .NET and still use an ExtJS UI. In fact, I would prefer to do such an implementation.
Regarding Silverlight: I am slightly against using silverlight, primarily because it requires a plugin to be installed that is not available on all platforms. But since your application is an intranet application, your user base will be in your control. But you should make sure that any future decision regarding the workstation platform will not affect your application's working.
Cheers
Whether to use Silverlight over HTML/JS etc. in this case would depend on 2 key factors.
What are you familar with already
What type and range of devices you need to reach.
If you are already comfortable with HTML + ExtJS then that has to be huge pro in its favor.
The range of devices that Silverlight is possibly going to be available (Windows Phone 7 for example as well as Moonlight, I've even heard that there may be port for Andriod and Symbian) is growing. However its really early days for that and not all may materialise in a form useful to you.
Having said that it should be acknowledged that a UI designed for use on desktop does not work well on a small device. Hence you would need to develop some task specific UI for other devices regardless of the technology you use. This in turn means that there is no reason for you to try to stick with single technology for all devices.
I think you should look very carefully into WCF, REST and OData first. Good layering of the application into useful models using these would more easily enable the use of a variety of front-end technologies for the client.
If you are into .NET and other Microsoft tech then you should seriously consider using JQuery and ASP.NET MVC as another potential front end technology.
I think that you need to ponder the inconveniences of a solution based solely in Silverlight. Like Flash it needs a plugin to be installed in every station, so it loses some of the premises of web applications (run everywhere with the only requirement of a browser). Besides although Silverlight has taken great advances, it is not yet a widely supported standard, and it is in control of a company who later may decide for you in very important matters regarding the platform you use, and made it outdated or useless (in the worst case).
Ext JS is a great library developed entirely in Javascript, so you can touch anything that suits your needs. If the Windows applications you are basing on is well-layered, then your work may not be that hard.
If you are an asp.net developer you could take a look on asp.net mvc, a great set of tools that implements MVC pattern to web applications using the same old C# or VB. Besides the developers behind asp.net mvc, have taken a lot of work to make it suitable to work with javascript libraries like jQuery
Happy coding!!!

Is RIA Services right for our Silverlight app at this point?

I'm looking at Silverlight architectures and RIA Services looks interesting, but I am a bit concerned about its prelease status and how the feature set will change.
We need our client app to be as responsive as possible over a slow network link, so a high priority is a solid sync system for pushing model state changes from the client back to the server. Will RIA Services help us in this regard or will I have to roll my own logic to do this ? Are there any other frameworks that can assist with this? Is the feature set involved in these requirements liable to change much in the next couple of months?
If it makes any difference, our frontend is 100% Silverlight, so we dont need to worry about exposing SOAP APIs from the server or anything like that. It appears to me that RIA so far is a bit more mature for Silverlight use. Is this correct?
I am using SL 3, .NET RIA and EF. Still trying to figure out how to load, and update data effectively and best in performance. Little information that I have so far how to improve the performance issue that I face. Still need more time to get these frameworks to be mature. Hopefully, there are more resources and insight in the near future.
My take is if you are handling very light data application, silverlight can be a good choice. Once you have loaded the application in to your machine, it is like loading application within your box.
I would look into some of the ORM's / IoC Frameworks which help create a separation of interests. A couple examples are Castle Windsor IoC, they have a sample Silverlight 4 application that utilizes the Castle Windsor Framework. Another common ORM for Silverlight is
BL Toolkit. These have been around for a while in the Java arena but are newer in the .NET area. They basically help to move the complexities of the relational data model out of the UI code and delegate it to the Framework.

What are the topics to ramp-up on when starting Silverlight\Web development?

I've been asked to do some work on an existing Silverlight project, mainly extending it a bit and doing bug fixes as needed. But there are a couple of ASP.Net pages too and a WCF service to deal with too. My background is desktop development with .Net so I think this is a good opportunity to start getting more involved in Web development.
So I'm trying to figure out what background knowledge I need for a project like this. Clearly I need to get familiar with Silverlight, but I'm not sure what other Web technologies, etc I need to ramp up on for this project. Obviously I would like to know as much as possible but in reality with limited time and resources I really need to focus on what I important in the near term for this project. Then expand my knowledge as things arise.
The things I'm thinking that are important in the immediate future are:
The basics of Web Development (I'm thinking this might be the most important\fundamental area to build a good foundation)
But what are consided the basics?
What is technology\language independent?
What is important for Silverlight?
The basics of ASP.Net (since there is some ASP.Net code)
What are the basics? ASP.net seems so huge, I have a 1000+ pg book here which seems daunting.
If you focus on Silverlight is knowing ASP.Net important, or is ASP.Net something I will continually run into?
How does ASP.Net MVC fit into the overall development picture and especially as related to Silverlight?
The basics of WCF
As compared what?
Any suggestions\comments on the list above?
What other topics\technologies will I run into if I continue doing Web development?
Note: Beyond this project I would focus on the Microsoft stack.
Generally speaking the amount of knowledge of ASP.Net you need to do Silverlight development is very very low.
Silverlight applications are hosted in a browser, usually via the <object> tag. This can sit on an asp.net page or a html page. The Silverlight template creates that for you, so you can forget its there and just get on with the Silverlight app.
Of course if you are integrating into an ASP.net environment (for example, islands of Silverlight sprinkled through an ASP.net site) then thats another thing. There are ways to get Silverlight talking to the HTML dom via the HTML Bridge but its not necessary. Really depends on what you are developing and integrating with. (new site vs existing)
I avoided ASP.net for as much as i could as the richness compared to desktop (WPF) just wasnt there. Silverlight changed all that. Its a Rich world on the web now!
Best place to start learning Silverlight is www.silverlight.net on the getting started part of the site. great Quickstarts and tutorials there.
Good luck
Only cursory knowledge of traditional web technologies (css, html, js, etc.) are necessary for silverlight development. As a consequence, you also don't need to understand the many cross-browser dependencies as well.
Here is my list of things that you must get a really good understanding of to be proficient at Silverlight development:
Understanding WCF (the Silverlight-supported parts) is essential. It can be a configration nightmare, but once working it is pretty stable/ reliable
You need to understand serialization used by WCF and how to debug the mysterious 404 errors. Get good at Fiddler and/or Firebug.
You must understand multi-threaded applications and how do debug them. Silverlight makes extensive use of threading to not block the UI thread. This creates numerous opportunities for race conditions that create what appear to be "magical" results. That said, it is incredibly powerful and IMHO one of the dominant reasons to use Silverlight.
What you learn about serialization and WCF will ultimately help you cache some data in IsolatedStorage. Learn about IsoStorage, it will reduce our bandwidth requirements and cost and improve your user experience
Learn about Linq - again this is one of the most powerful features of Silverlight. Combined with a smart client-side caching strategy you can offload lots of processing to the client.
Figure out how you going to support printing. SL3 does not at all and you will need a server side component. SL4 beta does, but it is not go live
Understand the Silverlight Roadmap as much as possible and plan out your roadmap to match/ sync with it as best as possible. I first built a SL2 app and I spent a lot of time building things by hand that were ultimately released in SL3. As it is getting more mature, there is less of this.
Download the Silverlight Toolkit and use it. But more importantly examine the source code, the structures, its build process. There is not better real world place to look for inspiration & best practices.
Good luck.

Resources