Archive

Archive for the ‘.net’ Category

Flickr WCF Part II - Hosting WCF Components In-Process

February 16th, 2009

This is Part Two in an on-going series of articles about WCF components, all centered around a simple component I created to talk to the Flickr api. You can find Part I here.

Now that we’ve hosted the Flickr WCF component in IIS, let’s take the same service definition and implementation and do something more interesting with them than just spitting out a list of URLs. It would be cool if we could see each of the pictures and cycle through them. And, so that I can point out a potential WCF gotcha, let’s do this in a WinForms application.

Let’s also host the component in process. In process components should always use named pipes. I’ve found that the easiest possible way to host a component in process is by using Juval Lowy’s ServiceModelEx library. You can download the library at this link. We’ll use his InProcFactory class which he describes in some detail on pages 60-63 of his WCF Bible, “Programming WCF Services.”
With InProcFactory all you need to do is to add references to the class libraries which contain your component’s contracts and implementation.
Read more…

.net, servicemodelex, wcf , , ,

StackOverflow update

February 11th, 2009

I have recently had two of my WCF related answers to questions on StackOverflow rated as top answers!

Are Enterprise Level DataContracts a Good Practice?

Logic first, WCF security later?

I enjoy going through the StackOverflow questions that are tagged as WCF related on a near daily basis. I have learned an awful lot just reading other people’s answers and sometimes the questions inspire me to go learn something I hadn’t thought about.

Also, tonight I asked:

What are your favorite resources concerning RESTful WCF?

If you have a good answer, I’d love to hear it!

.net, stackoverflow, wcf , ,

Flickr WCF Part I - Basic Manual WCF Component

February 10th, 2009

This is the first part in a series of blog posts where I see how many different aspects of WCF I can exercise with the same basic component definition. In this article we’re going to define our contracts, create a service, create a IIS host, hand-code a proxy and have a Console app spit out URLs to the 100 most recent photos uploaded to Flickr.

This and subsequent articles assume some basic working knowledge of WCF. If you’ve worked your way through a couple of tutorials, you’ll be fine.

The basic logic of the calling out to Flickr and the extension method I use are described in the previous blog post which is a prelude to this series. Please take a look at that article if you have trouble following along.

For simple cases like the one we’re working on here, I find that hand coding all of the WCF logic is the easiest and most straightforward way to make my code work. Using the svcutil.exe or the Add Service Reference feature in VS 2008 works, but both methods add unnecessary cruft that add to the complexity and understanding of the code. So, here we go!

Read more…

.net, wcf

Calling the Flickr API getRecent method with c# and Linq to XML

February 7th, 2009

UPDATE: I have updated this article to now use the flickr.interestingness.getList method instead of getRecent. I love getRecent, but out of every 3 to 400 pictures there’s almost always one or two pictures that most audiences would consider offensive. All of the photos returned by flickr.interestingness.getList are artistic and very few of them would be considered offensive by most people.

One of my favorite features of Flickr is browsing through photos that have just been uploaded.  You can get a glimpse of this on Flickr’s home page, but I decided I’d write some code so I could look at a bunch of them all at once.  I also like making calls against other web API’s (like from Twitter, FriendFeed or delicious).

Read more…

.net, extensions, linq , , , , , , ,

Clicky Web Analytics