At work, I want to create a WCF Windows Service that runs on a network server. Then I want to create a WPF application that can be installed on various machines on the network. This WPF application needs to be able to communicate with the WCF Windows Service on the network server.
Is this feasible? Is there a better way to accomplish what I want to do? Does anyone know of any resources that show examples of this? I found some tutorials how to setup a WCF service within a Windows service, but I am unsure how to communicate with it over a network.
Thanks for any advice!
Yes, a WPF application can host a WCF client just as well as (and in the same way as) any other .NET application. You may run into security limitations if your application is packaged as an XBAP for browser delivery, but otherwise it should all just work.
Similarly, a Windows service can host a WCF service. For an example see "How to Host a WCF Service in a Managed Windows Service" at http://msdn.microsoft.com/en-us/library/ms733069.aspx.
You can then communicate with it over the network by creating a client proxy -- the easiest way to do this is to use the Visual Studio Add Service Reference command.
I don't understand your question. You say you saw examples of WCF servers and clients, but you are unsure how to communicate with it over a network. But all of the examples you saw were about the clients and servers communicating over the network!
What's the difference between what you saw in the samples, and what you want to accomplish yourself?
Related
I have a concept for a WP7 app but I need to establish a connection to a SQL Server from the app. Problem is I cant the method to do this in the the 4.0 framework. I know how to do this in a desktop app but I dont have the same methods available to me when developing a windows 7 phone app. Anyone know how to do this? If the concept is wrong can you direct me to how it should be done?
Silverlight (either on a phone, or a browser) simply can not make such network connections. You're going to need a server to talk to, likely with WCF
Doesn't look like you can at the moment -
http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/7b6b8d0b-509d-4ecc-a28d-8804cc22e475
It would be a better practice to front your database server with some kind of web service as exposing a database directly to the internet is generally considered too much exposure for your database.
(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.
I've asked several questions on Silverlight the last day or two (I have no experience with it), and I've had some high-level questions answered. I have another high-level question. How is N-Tier development done with Silverlight? What I am considering is a browser based UI and then a c# back-end containing all the business logic and database code. How would a Silverlight client application communicate with such a back-end sitting on another server? Would it be done via Web service calls, WCF or something else? What is standard practice?
Thanks!
For the projects I've worked on. Typical practice is Silverlight providing a client and then communicating back to the back-end via WCF services.
The business logic is then spread/duplicated across the client and the backend.
You'll want to be looking at the WCF RIA Services for this. In combination with Entity Framework this will approach the sort of thing you need.
The Entity Framework creates model that you can extend and include some business logic.
The Domain Services then allow you to expose access to the model and any other range of operations you need via WCF.
The tooling that RIA Services adds to the Visual Studio will dynamically create in the Silverlight application the client side of this Domain service. There is even a provision for you create C# source that is shared by both by both Silverlight and the server code.
If its Silverlight 3 RIA is a better choice to work with. AnthonyWJones has pointed it right, There is a provision to have a shared Source between Client and Server usually Entities code should be shared in both Client and Server to get full advantage of RIA validation and other stuff.
I want to use a Silverlight application in a cloud on Azure. The communication between the Silverlight application and the WebRole is a WCF-Service with Basic-HTTP-Binding.
My problem is, that the communication doesn't work. I think the endpoint-address is not correct, but I'm not sure.
Can someone help me?
Have you tried using Fiddler that will at least tell you if the end point is correct.
It should also help if there are any permissions issues.
I found these samples cited by the Silverlight Web Services team blog. The Known Issues Wiki is also very helpful. These examples use a binary HTTP binding instead of BasicHttpBinding but they get the job done.
If you are running Vista, like I am, You may need to register the WCF MIME types for IIS 7. You can do this be running a command prompt in elevated mode and executing this command:
C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe -i
There is an issue with linking to Webservices in Azure. I would check the endpoint in the Silverlight application and make sure it is the same as the port used in your Azure application.
I came across the same issue when working through the Azure Labs and rewrote Excercise 3 (using WCF) so that it would work - that is now available on CodeProject (http://www.codeproject.com/articles/34612/Getting-WCF-to-work-with-Azure.aspx).
I based that on a posting from David Burela's House-o-blog and his description of the problem can be found on his blog.