Home
  Latest posts
  My Writings
  My Code
  My Gallery
  About me
 
  rssfeed Syndication
 
Bloggtoppen.se
 
 
Links
  Cornerstone
  SweNug
 
Post categories
  misc (48)
  Architecture (21)
  C# (19)
  Asp.Net (2)
  Vb.Net (2)
  Training (7)
  Data (19)
  Events (40)
  Platform (2)
  Orcas (4)
  Updates (3)
  Methods (10)
  Tools (6)
  Announcements (14)
  Languages (1)
  Patterns (6)
  Opinions (11)
  Fun (3)
  Ineta (1)
  Opinion (0)
  Practices (2)
  WCF (5)
 
 
 
WCF (5)
TIP: WCF Bindings Update for Visual Studio 2008 Tuesday, February 12, 2008

In the first version of WCF the protocols for security, reliable sessions and transactions was based on a draft of the standard protocols. In .NET Framework 3.5 Microsoft has updated the standard bindings to conform to the OASIS standards. To use the OASIS standards there is two new standard bindings called ws2007HTTPBinding and ws2007FederationBinding, who derives from wsHttpBinding but isn't compatible but will yield a security exception if not both server and client uses the OASIS binding.

MSDN documentation over here: http://msdn2.microsoft.com/en-us/library/system.servicemodel.ws2007httpbinding.aspx

Leave a comment Comments (0)
 
WCF As The Next Object Runtime in .NET? Friday, January 11, 2008

The more I work with Windows Communication Foundation the more I see it as an extraordinary piece of technology. With the ability to easily extend and intercept messages it's much more dynamic than any other programming stack for distributed applications I've come across (thus far). Apparently Juval Löwy is of the same opinion. Via UDI ( http://udidahan.weblogs.us/2007/12/29/wcf-everywhere-not-on-my-watch/ ) I found an ARCast with Juval and Ron Jacobs where Juval has the radical suggestion that WCF should be the object runtime of .NET, he wants every class to be a WCF service. You can see the full cast over here: http://channel9.msdn.com/ShowPost.aspx?PostID=347010

His argument is that in WCF it's really easy to apply cross-cutting concerns like transactions and security to objects without burdening the developer with the plumbing code. A lot of code that is being written is just plumbing and WCF can help you reduce the amount of plumbing code.

For instance; In a recent project, with just a couple of lines of code, I managed to extended the WCF message dispatch mechanism to automatically create a new LINQ To SQL DataContext and dispose it for every call to an operation. Once the code for handling the cross-cutting concern was written, it was really easy to apply a decorator for each operation that should have that particular behavior:

[AutomaticDataContext]
public List GetTop10Customers() { ? }

Now where have I've seen this capability before, I wonder?.

Oh wait I got it: In AOP!

I agree with Juvals argument that often the level of abstraction for plumbing is too low, it needs to be higher and we need a better way of applying cross-cutting concerns across our systems. But I'm not sure that WCF is the solution, not in its current state anyway.

WCF and the functionality there in is mainly architectured for distributed scenarios, Juval says it the best himself when he in the ARCast calls the WS-* specs for "Wire Specs" I.e what goes on the Wire. Well, YAGNI is all I have to say about that.

Instead, I would like to see Microsoft open the instantiation and dispatch mechanism of the CLR for extensibility. WCF would benefit from that, so would all the LINQ implementations and everything else you might come across that have cross-cutting concerns. Additionally we would at least be able to build intercepting runtimes even if it wouldn't be fully fledged AOP frameworks.




Leave a comment Comments (1)
 
Christian Weyer on WCF Hosting in IIS Thursday, August 16, 2007

Chrisitian Weyer, who spoke at Developer Summit this year (you can find his talk here: http://forum.cornerstone.se/blogs/devsum/archive/2007/06/19/presentation-christian-weyer-thinktecture.aspx), is one of the heaviest WCF advocates out there. Additionally to being a great guy (although he almost ate one of Stockholm's restaurants out of their bread supply ;) he also writes some cool articles.

The latest is co-written with Dominick Baier from Christians company thinktecture and Steve Maine from the Connected Framework team at Microsoft. It drills deep down in the IIS6/7 hosting model for WCF service. A most read for anyone working in the WCF / Connected Systems space.

Browse over to http://msdn.microsoft.com/msdnmag/issues/07/09/WAS/  for the good stuff.

Leave a comment Comments (0)
 
Passing data efficient to and from WCF Services Wednesday, July 04, 2007

I spend some time in the msdn forums on and off (http://forums.microsoft.com/MSDN/) and a couple of days ago a question about contract design in WCF appeared. The idea was to get the most out of the WCF services and handle change sets etc as efficient as possible. This post sums up my ideas and understanding about efficient contract design, there is also a recorded discussion where me and Ron Jacobs addresses the issues in pod-cast form (over here: http://files.skyscrapr.net/users/arcast/rr/ARCastTVRR-20070702-PassingData.mp3)

So to the ideas:

In WCF you really should go the DataContract path and have specified contracts, which you control, what data should be communicated and how. Data contracts has the benefit of giving you alto of options so you can explicitly define your intent.

I would also argue that the data contracts that defines the data that is communicated should be separate from the model you use for accessing data. The Data Contract should define the information flow between services and consumers and not the model used to implement the service itself.

Creating specific data contracts will allow for better service designs and helps you design around the UoW / Versioning issues and will also streamline the information sent over the wire.

For example,

I have a model with questions and answers. To the consumer I want to send complete question information for presentation. But when answering the question there is actually no point in sending full question information back from the consumer to the service to add the answers.

the contracts I use for this scenario looks similar to this:

To get the questions ( public GetSurveyResponse GetDefaultSurvey() {} ):

[DataContract(Namespace = "http://schemas.cornerstone.se/SurveyCollector/GetSurvey")]
    public class GetSurveyResponse {
        [DataMember]
        public Guid Id;
        [DataMember]
        public string Title;
        [DataMember]
        public List Questions = new List();
    }
 
  [DataContract(Namespace = "http://schemas.cornerstone.se/SurveyCollector/GetSurvey")]
    public class SurveyQuestionItem {
        [DataMember]
        public string Text;
        [DataMember]
        public int Weight;
        [DataMember]
        public QuestionTypes Type;
        [DataMember]
        public Guid Id;
    }

To send the answers ( public void AnswerSurvey(SurveyAnswerRequest request) {} )

[DataContract(Namespace = "http://schemas.cornerstone.se/SurveyCollector/AnswerSurvey")]
    public class SurveyAnswerRequest {
        [DataMember(IsRequired = true)]
        public string StudentEmail;
        [DataMember(IsRequired = true)]
        public string ClassNo;
        [DataMember]
        public List Answers;
    }
 [DataContract(Namespace = "http://schemas.cornerstone.se/SurveyCollector/AnswerSurvey")]
    public class SurveyAnswerItem {
        [DataMember]
        public Guid QuestionId;
        [DataMember]
        public object Value;
    }

This guarantees that  I just send the information necessary to complete the operation I'm calling.

The original scenario used DAAB as the persistence layer and the discussion went on to talk about how to utilize the data contract together with DAAB and get the data from the contracts into the database:

You will have to move it out of the DataContract objects either by hand or with some nifty O/DataSet mapping code. It's very much the same principles that you apply to your GUI, you don't create a NameTextBox control, you keep the data model and the UI controls separate. The idea is to keep the contracts and the implementation separate to ensure that the implementation don't influence the contracts to much.

This is how it's done in one of the methods of the example contracts in the post earlier (I don't use DAAB for this project, instead the implementation is built in a DDDish style with NHibernate as persistence layer)

 public void AnswerSurvey(SurveyAnswerRequest surveyAnswer) {
  using(SessionScope scope = new SessionScope()) {
                ISurveyRepository repository = new SurveyRepository(scope);
                ISurveyFactory factory = new SurveyFactory(repository);
                Survey answeredSurvey = factory.CreateFor(surveyAnswer.StudentEmail, surveyAnswer.ClassNo);
                foreach (SurveyAnswerItem answerItem in surveyAnswer.Answers) {
                    answeredSurvey.AnswerQuestion(answerItem.QuestionId)
                                  .With(answerItem.Value.ToString());
                }
                repository.Save(answeredSurvey);
            }
          }

Udi Dahan (http://www.UdiDahan.com) commented on this as:

"What you have here is not only layers, but tiers - client, app server, and database.

Translation code is good for you. It decouples your layers."

Which is a very nice summary for the need to have your contracts separate from the actual implementation of the WCF service.

The full conversation can be seen here:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1805743&SiteID=1

kick it on DotNetKicks.com
Leave a comment Comments (0)
 
Example: Validation Application Block and WCF Friday, June 29, 2007

I'm currently investing a lot of work in both WCF and Enterprise Library 3. It will probably turn out as a couple of blogposts.

This post however is just a placeholder for my Validation Application Block integration sample with WCF.

It uses VAB and the custom WCF binding to validate incoming datacontracts based on configuration.

It's attached to this post and the feed readers need to get to the site to fetch it (anyone got any good links on how to add attachments to RSS?)

kick it on DotNetKicks.com
Attached file: WCFValidationBlock.zip
Leave a comment Comments (2)