How can i call a windows service using silver light?
If it's a managed service that's in your control, you could host a WCF service in it for silverlight to communicate with.
Here's how to do that.
Using WCF is, as noted, the simplest solution. An alternative, if you don't want the (substantial) overhead introduced by WCF, is to use sockets, as demonstrated, for instance, here. If you control both sides of the equation, a framework like SocketsLight can take some of the pain out of sockets programming.
Related
So, I've been using WCF Ria services for a few months now and I am wondering why would anyone use WCF basicHttp webservice over using WCF RIA Services?
Someone told me that RIA Services is not good for Enterprise Level Applications and I am wondering why?
W/out RIA it seems you have to write validation logic in 2 areas, client and server. Also, RIA handles roles and membership fairly easily.
How much extra work is involved if you want to use WCF basicHttp webservice? What is the benifit over using RIA? and.. Does anyone have any good examples of an enterprise level silverlight application using wcf basicHttp webservice?
Thanks!
The issues with WCF support in Silverlight relates to the limited subset of the .NET Framework embedded in the Silverlight plug-in as it's essentially a scaled down version of the .NET Framework. As a result of the scaled down .NET runtime in the Silverlight plug-in, it does not have the same full support for WCF that you get from standard .NET projects. This was done to make the initial download of SL quick from a client perspective and increase time-to-market of SL as a product. Keep in mind that the SL plug-in has no dependency on an existing .NET framework being installed which is why Linux, Windows Phone 7, and OS X versions are on the market.
As time has progressed they continue to add in-demand features in. For example, Silverlight 5 will support WS-Trust (see here for a complete list of new features in 5).
I recommend you read this resource to see what you may miss out on by trying to call WCF Services from the client:
http://msdn.microsoft.com/en-us/library/cc896571(v=vs.95).aspx
Keep in mind you could very easily proxy out calls to more complex WCF services through RIA Services endpoints which are in effect calling the service directly from server-side.
As for using standard WCF instead of RIA ... there are advantages when your middle tier has multiple client types, though with RIA you could simply expose your endpoints out as SOAP 1.1 endpoints and require people to connect using that paradigm instead of WCF. You do not have to use RIA or nothing; you could mix and match to meet your requirements as you see fit. Personally I am big on just using RIA if at all possible.
It's fair to say RIA Services has had its growing pains. Some of my biggest bugbears with it (such as not having the ability to return complex objects that aren't entities from Invoke methods, and the lack of decent support for being used in an MVVM way) have mostly been fixed in RIA Services SP1. Some people I know using it in huge enterprise applications have had major headaches with it (at least in the early days). I'm not quite sure where things stand now in that respect, as to whether their particular problems have been resolved yet.
That said, I personally think it's a fantastic technology. It makes tasks that are painful with standard WCF services easy (my favourite is being able to specify queries on the client on methods in your domain service that return IQueryable, that execute on the server - making sorting/filtering/grouping/paging a breeze). Whether it's right for you depends on your scenario. It's designed primarily to make performing CRUD operations on entities easy, so if that's primarily what you need then its perfect. RIA Services is designed to be consumed by Silverlight application only however (at least for the moment). You can access them from other clients, but you don't get all the features that makes them so good. So if you need to support other client platforms, it may not be the right fit.
I think RIA Services is awesome, but ultimately it depends on your scenario as to whether they are right for your project. As a technology, it's geared towards particular scenarios, and isn't intended to solve all the world's software development problems. Some people who might complain about it possibly aren't using it in the way it was intended, and pushing its limits (that said, it isn't perfect either, and has had its issues). If you can possibly provide some more details (such as the scale of the application, the client platforms it needs to support, and the number of developers on the project), I'd probably be able to give you some more helpful advice.
Hope this helps...
Chris
(Using Visual Studio 2008, and Silverlight 3)
-I've really looked around for this one, and now I'm just confused by all the solutions that simply won't work for me.
I'm trying to call a WCF service from a Silverlight client, which is no problem, but I can't get the service to handle sessions (I want to remember a few things about the callee between calls)
I've gathered that basicHttpBinding is no good for sessions, and I haven't managed to make wsHttpBinding work... what's the matter? I would have thought this was a pretty basic thing people would want in their WCF services, or am I just completely muddle-headed not to see how it can be done?
okay, seems like "Silverlight-enabled WCF Services" (WCF service with
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
and basicHttpBinding instead of wsHttpBinding) can do sessions with Silverlight:
http://www.dotnetspider.com/Silverlight-Tutorial-317.aspx
Cheers, Alex
I'm using hessian protocol for communication betwee server (java) and various client applications. Now I started to develop Windows Phone 7 client. I downloaded hessian C# implementation but it does not compile for windows phone 7/silverlight.
Does anyone managed to make it work on WP7/Silverlight? It's looks like there is many thing to be done/changed to make it work, which I'd like to avoid if it has been done by someone already.
Thanks.
What is it that does not compile? I'm guessing that the implementation is probably using sockets. Please keep in mind that Silverlight (and thus, wp7) limits the kinds of network connections you can open ... preferring asynchronous web requests (via the WebRequest class) or WCF services.
Chances are the code you downloaded is having problems with the compact framework version of the network classes available on the phone/silverlight. See this msdn article for more information about the socket support:
http://msdn.microsoft.com/en-us/library/cc296248%28VS.95%29.aspx
If you want to communicate directly between the phone and a server running the hessian protocol the easiest way will probably be to proxy communication via a wcf service running on an asp.net server.
So answer is you have to rewrite hessian C# implementation as Silverlight 4 doesn't have lot of stuff from .net mobile framework, mainly Proxy class.
Or do I need a Silverlight client?
Yes, RIA services can be used from WPF, or in fact any NET Framework client. However many of the client-side controls typically used with RIA are Silverlight specific, so your mileage may vary.
You may want to look at WCF Data Services too.
I'm still learning the differences so not quite yet ready to compare the two.
How do I go about hosting a silverlight 3.0 application inside of a wpf application in which I can pass data between the two? It needs to run without internet connectivity.
I have a project I'm working on to do that. It's very experimental right now...Hell I really haven't even announced it yet.
http://silverlightviewport.codeplex.com
-Jer
There is no known control that can do this seamlessly out there as yet. To do something like this, you will need to host a web control and use javascript to communicate with the host for interop. Which by the way is not at all recommended.