Sidhartha's profileInherited from System.Ob...BlogLists Tools Help

Blog


    August 26

    Why should I travel Lufthansa next time?

    Or should I say, why should I travel Star Alliance next time?

    As much I wanted to refrain writing a rant, I could not resist myself with this blog. I've traveled with them twice and on both occasions they were consistent in one thing. They suck equally both the occasions.

    First time, I was traveling from Bangalore to Chicago in 2004:

    1. Reached Chicago around 6 hours late
    2. Return flight delayed and got a ticket from Frankfurt to Chennai and they did not book me from Chennai to Bangalore. So wasted 12 hours and couple of thousand rupees.

    Second time, I was traveling from Hyderabad to Seattle and Tampa to Hyderabad:

    1. Reached Seattle after 20 hours of the scheduled arrival. Wasted 20 hours and my baggage reached me after 3 days.
    2. Frankfurt-Hyderabad re-routed to Frankfurt-Delhi-Hyderabad. Wasted around 10 hours and damaged baggage. (Still at Frankfurt, so 10 hours is only the schedule - never know the actual).

    So, put together I wasted around 48 hours and couple of thousands in my life due to the sick service these airlines provide. I could travel to US (round trip) one more time in this time frame.

    I traveled BA earlier and I had a wonderful experience with them, everything was good except the number of hops I had to make. But hey, I reached my destinations on scheduled and as per my initial itinerary.

    I'd not travel with star alliance in my lifetime, even if they give me a free world trip ticket and I MEAN IT. I'd rather kill myself than flying with * again (Yeah.. I know I'm exaggerating here)

    The next time, captain says "Thanks for flying with Lufthansa, we wish to serve you in the future", I'd laugh out loud... in future... my foot *profanity*. *profanity* you guys have a 100% failure rate.

    Can anyone reading this give me one good reason for me to travel this sick airline again?

    Update: I reached Hyderabad now and with a damaged baggage. I spoke to Lufthansa and not to my surprise, they asked me to contact United Airlines as they believe it got damaged to them from United.

    August 22

    Method overloading in WCF

    WCF solves so many complex problems of the distributing computing, yet when it comes to simple things like overloading it fumbles. This is not what I say, but what I heard from some developers at my customer's site. So, I thought how can such a small thing could not be achievable in WCF when the underlying platform (.Net framework) support this by design.

    After little thought, it is all clear why it does not work the same way it works with compiled languages. Its all the underlying protocols that makes it complex. But, it is not really tough to get this to work.

    Here is the sample I worked on to get method overloading with WCF working like it does in C#.

    Step 1: I've created a simple service contract with two methods using method overloading.

    [ServiceContract()]
    public interface IMathService
    {
        [OperationContract]
        int AddNumbers(int num1, int num2);
        [OperationContract]
        double AddNumbers(double num1, double num2);
    }

    Step 2: Tried to run the service and this is what I WCF told me...

    image

    Step 3: As WCF does not allow me to do this in a direct way, I looked at the OperationContract attribute to see if there is something that can help me. To my confidence, there is this property called Name. I've set this value to a unique value for both of these methods. now, the service contract looks like this:

    [ServiceContract()]
    public interface IMathService
    {
        [OperationContract(Name="AddIntegers")]
        int AddNumbers(int num1, int num2);
        [OperationContract(Name="AddDoubles")]
        double AddNumbers(double num1, double num2);
    }
    

    Step 4: Tried to run the service and this is what WCF told me now...

    image

    The problem seemed to be solved. And indeed it is, the generated proxy does not show any discrimination towards these methods. They'll be just like any other method (overloaded methods). Now its all over... Method overloading in WCF is very much possible and is very much simple.

    I don't think I need to attach the source code as the only required change is already discussed here.

    August 20

    Getting away with client Config in WCF

    Downloads

    Download NoConfigClient.zip - 26.8 KB
    Download NoConfigWS.zip - 1.4 KB

    Introduction

    This weblog provides a solution to one of the most common problem faced by developers while developing their projects involving WCF Services using Visual Studio.

    Background

    To give you a little background on what this is all about… when you are working with WCF services and using Visual Studio for development, it becomes annoying as to how Visual Studio screws up the configuration settings. This is a small problem with an even smaller solution. Hence, it might be the smallest article.

    Using the code

    There are two attachments with this weblog.

    1. NoConfigWS.zip is the web service. You've to unzip the contents and create a web application using IIS. I'll not go into the details on doing that, you can figure out on your own if you are not familiar by searching the www.
    2. NoConfigClient.zip is the client that consumes the NoConfigWS web service. This is a console application that communicates with the service and displays the results back. All you need to do is to unzip the contents and change the app.config file to point your service.

    Problem

    This sample will help you in understanding the situation better.

    Before updating (add service reference and changing some values):

            <binding 
              name="BasicHttpBinding_IHelloWorldService" 
              closeTimeout="00:01:00"
              openTimeout="00:01:00" 
              receiveTimeout="00:10:00" 
              sendTimeout="00:01:00"
              allowCookies="false" 
              bypassProxyOnLocal="false" 
              hostNameComparisonMode="StrongWildcard"
              maxBufferSize="131072" 
              maxBufferPoolSize="524288" 
              maxReceivedMessageSize="131072"
              messageEncoding="Text" 
              textEncoding="utf-8" 
              transferMode="Buffered"
              useDefaultWebProxy="true">
              <readerQuotas 
                maxDepth="32" 
                maxStringContentLength="8192" 
                maxArrayLength="16384"
                maxBytesPerRead="4096" 
                maxNameTableCharCount="16384" />
              <security mode="None">
                <transport 
                  clientCredentialType="None" 
                  proxyCredentialType="None"
                  realm="" />
                <message 
                  clientCredentialType="UserName" 
                  algorithmSuite="Default" />
              </security>
            </binding>

    After changes (and updating service reference):

            <binding 
              name="BasicHttpBinding_IHelloWorldService" 
              closeTimeout="00:01:00"
              openTimeout="00:01:00" 
              receiveTimeout="00:10:00" 
              sendTimeout="00:01:00"
              allowCookies="false" 
              bypassProxyOnLocal="false" 
              hostNameComparisonMode="StrongWildcard"
              maxBufferSize="65536" 
              maxBufferPoolSize="524288" 
              maxReceivedMessageSize="65536"
              messageEncoding="Text" 
              textEncoding="utf-8" 
              transferMode="Buffered"
              useDefaultWebProxy="true">
              <readerQuotas 
                maxDepth="32" 
                maxStringContentLength="8192" 
                maxArrayLength="16384"
                maxBytesPerRead="4096" 
                maxNameTableCharCount="16384" />
              <security mode="None">
                <transport 
                  clientCredentialType="None" 
                  proxyCredentialType="None"
                  realm="" />
                <message 
                  clientCredentialType="UserName" 
                  algorithmSuite="Default" />
              </security>
            </binding>

    This becomes really painful if you had to change some settings (for example maxReceivedMessageSize or maxStringContentLength) to a different value than the default for some of the services. Every time you update the service reference, Visual Studio will replace the updated settings with the defaults. For situations where multiple developers are developing the services, this problem only grows exponentially.

    Solution

    There are several solutions for this problem, and the one presented here is just one of them.

    Whatever is your development environment to create your services, whether using Visual Studio or directly generate it, SVCUtil will generate multiple constructors for the proxy class (five to be exact). Guess what, one of them takes a Binding and EndpointAddress as parameters.

            public HelloWorldServiceClient()
            {
            }
            
            public HelloWorldServiceClient(string endpointConfigurationName) : 
                    base(endpointConfigurationName)
            {
            }
            
            public HelloWorldServiceClient(string endpointConfigurationName, string remoteAddress) : 
                    base(endpointConfigurationName, remoteAddress)
            {
            }
            
            public HelloWorldServiceClient(string endpointConfigurationName, EndpointAddress remoteAddress) : 
                    base(endpointConfigurationName, remoteAddress)
            {
            }
            
            public HelloWorldServiceClient(Binding binding, EndpointAddress remoteAddress) : 
                    base(binding, remoteAddress)
            {
            }
            
    Now, our job is to create these objects and create the proxy by passing these objects. 
                HelloWorldServiceClient helloWorldClient = new HelloWorldServiceClient(
                    ProxyHelper.GetBinding(),
                    ProxyHelper.GetEndpoint() );
    

    GetBinding() and GetEndpoint() are helper methods I’ve used to create those objects. The complete source code for this article is available as a download.

    With this approach, your final Config file would be as clean as follows:

    <configuration>
      <appSettings>
        <add key="webserviceURL" value="http://localhost/NoConfigWS/Service.svc"/>
      </appSettings>
    </configuration>

    Summary

    This, IMO, is much cleaner for your end user to maintain and by the way, who better knows the advanced Config settings than the developer (and ofcourse, the advanced network administrators)

    Once done, you can rest in peace… I mean work on your services without ever worrying about Visual Studio playing with your Config file anymore.

    August 19

    Writing Plugin for Windows Live Writer

    This is my first plugin for WLW... I named it Another Sick Plugin

    OK... so, here goes my 30 minutes effort this weekend.

    I've never developed plugin's for any tool so far. So, this makes it the first plugin ever. I wrote a tool which can accept plugins as a part of my work and several personal tools that'll improve my productivity... but never a plugin for any other tool. So, here goes my first one.

    If I come across some nice idea than this crappy marquee text, I'll do it and upload it to the gallery for the betterment of human race...
    Send across your ideas... your idea will be acknowledged accordingly.

    Now the effort split for the 30 minutes I spent.

    5 mins - think about what to do Saturday evening feeling sick of everything.
    5 mins - get SDK APIs for Windows Live Writer
    5 mins - go through the manual
    10 mins - create the project and get to print the input text to the blog post
    5 mins - test it and publish a blog with it.

    Hopefully, I'm up to something big here :)

    August 15

    Security the Banana way

    Tired of typing your password zillion times??? Tired of locking and unlocking your machine every time you step out???

    Gone are the biometric days... now this folks at the BananaSecurity ask me to change the way I do this shit. All I want is a webcam and a PC with Windows installed. Now you can install this small package that'll use the webcam to recognize your face and does an auto unlock. This seems to be pretty novel. Isn't it?

    It seems that there is a problem though, if someone holds your photograph in front of the webcam, it still unlocks your machine for them. But hey, it still claims what it is supposed to do in the first case. Only thing they've to improve upon would be to do a 3D face recognition. That'll end this issue... but wait... what if someone creates a mask similar to my face and puts it on and uses it to unlock my machine??? Ok... I'll stop now before you find and hunt me down.

    This one is a very cool tool and what's more... its absolutely FREE.
    The down side though is that they still don't have that Windows Vista Compatible sticker on that box. But some people claimed it works for them...

    Try it out yourself and the next time your computer unlocks your machine when you pop in... do thank me and the monkeys at the banana security... just kidding... enjoy this great product guys...

    Warning: I haven't tried this yet. I'll do this the first thing when I reach India and hook my webcam to my lappy. So, do it at your own risk.

    Source: http://www.bananasecurity.com

    image

    IE7 just got much better

    For whatever reason, Firefox attracts more number of plugin developers. So, the community developed numerous plugins for the browser. There were plugins for IE 6 before. But most of the were high end plugins and were developed by partner companies and were sold.

    Things seem to change off late... IE 7, has quite a few plugins. But, Firefox beats IE in this department still. Not anymore, you heard right... not anymore. There is this great plugin for IE 7 called IE7 Pro that is like the mother of all plugins. What could have been an dozen downloads in Firefox is just a single download for IE7, and you know what... all this for less than 1.5mb.

    IE7 Pro does the following... and it keeps getting better day after day.

    • Tabbed Browsing Management
    • Spell Check
    • Inline Search
    • Super Drag Drop
    • Crash Recovery
    • Proxy Switcher
    • Mouse Gesture
    • Tab History Browser
    • Web Accelerator
    • User Agent Switcher
    • Webpage Capturer
    • AD Blocker
    • Flash Block
    • Greasemonkey like User Scripts platform
    • User Plug-ins and many more power packed features (including weather and other goog stuff).

    I've installed it and am very much satisfied with their performance. This does not slow down my browser as it does with some of the firefox plugins.

    Hopefully, they'll add the winamp integration to this and I'll never use that Firefox again.