5. December 2011
ZeroKoll
WCF
Lately I have been working with a bit of WCF for a client, and one of the things I have had to do is to create a service behavior to handle some security things. However, due to the fact that this application needed to run in several different environments, it needed to have different configuration under different circumstances.
The real need was actually to be able to remove the behavior in some circumstances, and add it in some. But I didn’t really want to do it through a bunch of if-statements in my behavior. Instead I wanted it to be done through configuration so that I could turn it on and off using config transforms…
More...
Lately I have been working on an Azure project for a client (if you haven’t noticed from my Azure-centric blog posts as of late). A part of this, we have built a WCF service that exposes the functionality that we need. However, we are not actually building a client, only the service. So we don’t have a great way of testing the service. This is obviously where the “WCF Test Client” comes in.
For those of you who don’t know what this is, it is a small client that hooks up to any available service and creates a proxy for you. You can then use this proxy through the interface and call your service.
More...
Ok, so in my last post, I gave a brief introduction to WCF for the complete n00b. As a follow up to this, I would like to have a look at some different ways to consume these services.
The “normal” way to do it is obviously by adding a service reference to the project in VS, but there are alternatives that can make sense.
The samples I am going to use are specifically for Silverlight as they focus on simple bindings and features that Silverlight supports, but it can still be used for any .NET client.
More...
Ok…So I am more of a general .NET and Silverlight developer, but it is hard to get around the fact that WCF infiltrates most of the projects I ever work on. And after having read a substantial part of Juval Löwy’s book about WCF, I have realized that there was a lot that I didn’t know and didn’t fully understand. Not that I am saying that I get it all now, but I have a better understanding at least.
The thing is that WCF isn’t really very hard in most cases, but having a basic understanding makes it a lot easier. And to be honest, the basics will take you a long way when working with Silverlight, since Silverlight doesn’t support a lot of the more advanced features. To be honest, the WCF support in Silverlight is fairly basic, but it is enough…
So based on this, I thought I would try and write a down to earth and simple introduction to the main concepts in WCF.
Ok, so this post is definitely going down in the books as “why would you do that” for a lot of people, but it actually has its benefits in some cases. What I want to show, is how we can work with WCF services and service interfaces without having to add a service reference to Visual Studio and instead auto generate the required code using T4 templates…
So why would I want to do that? Well, in some cases it is kind of tedious and even complicated to spin up the service just to be able to update the service reference and in some cases it isn’t even possible to get access to the WSDL that is required to create it. And in those cases, this will help you… In my case, the services and service contracts are built by one dev, and the Silverlight stuff by me. To us, this way of working makes it a lot easier to handle changes to the service contracts as we go along… I can get changes by just checking out the changed interfaces without having to try and get my solution into a state where I can update my service reference.
More...
In my previous post, I showed how to host WCF services. In the kiosk application that I am working on, I have, as previously mentioned, decided to not have IIS run locally on the machine. I have also decided host the Silverlight application locally. I do not want it to be fetched from the server for different reasons. So how can I serve up a Silverlight application without a webserver? Well…I am already hosting WCF services in a windows application…why not let the windows application serve up the Silverlight application as well?
WCF actually gives us this possibility very easily, and here is how it is done. I’m going to re-use the application from the previous post, so if you haven’t read it, I recommend doing so…
More...
I’m currently working on a kiosk application for a company called TicketDirect. They sell tickets to different events all around New Zealand and have decided to create a kiosk based solution where customers can buy tickets. The application needs to be Silverlight based for a couple of reasons, and must run Silverlight 3 as 4 doesn’t have a go-live license yet. The problem with this is that the application needs to talk to a credit/debit card unit as well as a ticket printer. The problem as you probably realize quickly, is that these units are connected to the computer physically and therefore are not available to Silverlight. And yeah…as you know, printing support is “limited” in Silverlight, so printing custom ticket layouts to a special ticket printer will not work…
This is how I solved it. I created a couple of WCF services to run locally on the machine and then had Silverlight connect to those to access the local system. The problem was that I did not want to run IIS on the local machines. Why? Well, for different reasons…such as the need for simple XCopy deployment. So the services would be hosted by a Windows application instead.
More...
12. October 2008
ZeroKoll
EPiServer
I just spent some time trying to get my WCF Service to work on my EPiServer CMS 5 R2 installation. It was a lot more complicated than I thought it would be.
I had built this Silverlight application using a test application, launching it in the VS webserver and everything was working fine. It was a small Silverlight application that used a WCF service to get some data from the server. The epplication worked perfectly...until I decided to deploy it to my "real" site using IIS 7... The "real" site was an EPiServer application which caused some problems.
I deployedmy Silverlight app as well as my service to the site I was going to use. Deploying the application meant copying the xap file as well as the svc and assemmbly to the server. I also copied my service configuration to the web.config file. After this I opened my browser and browsed to localhost. And behold...a broken Silverlight application. The application started, but soon came to a screeching halt as it tried to connect to the service. Since the application actually loaded, I came to the conclusion that the IIS configuration for the Silverlight things were ok and that it was the service that was the problem.
More...