Friday, September 24, 2010

Message Queue using cloud computing – Azure and Amazon

Recently I was involved in an assignment which involved using messagequeue. We ended up implementing both Amazon and Azure as Queue providers. With libraries available for both of them, its very easy to integrate both in application.

Amazon Web Services

Amazon provides SDK for many platforms such as Java, PHP, Python, Ruby and .Net. SDK makes it very easy to incorporate any cloud computing service in your application.

Three simple Steps to incorporate Amazon Queue in .Net apps:

  1. Download the SDK
  2. Reference AWSSDK.dll in your project
  3. Write code (Found the SDK samples to be very helpful and easy to understand)

Windows Azure

Just like Amazon, Azure provides SDKs for Java and .Net. I liked Amazons approach that they give you the code samples with SDK. Azure does give you some code samples but they don’t include samples for Queue and not for every services which it provides. To get all the samples, you can get them from here (Make sure to download samples which are marked as Additional C# Samples)

Same with Azure, simple steps to incorporate

  1. Download the SDK from here .
  2. Reference  Microsoft.WindowsAzure.StorageClient.dll in your project
  3. Write code

One thing I noticed is that Queue names has to be in a certain format else you’ll get an exception response. Naming conventions are found here.

Enjoy Cloud computing!

Monday, September 13, 2010

Remove Navbar from Blogspot

Was wondering if it’s possible to remove the Navbar and have found a video post which describes all you need to do. The css update which you need in your HTML is as follows:

   1: #navbar-iframe{
   2:     display: none !important; /*nav bar*/
   3: }

Video post link: http://blogger-templates.blogspot.com/2005/01/remove-navbar.html

Wednesday, September 8, 2010

Using windows authentication for WCF service in .Net 4.0

A friend of mine was building a WCF service with windows authentication and ran into a couple issues. He found the solution and posted the solution at http://stackoverflow.com/questions/1367653/wcf-service-windows-authentication

Tuesday, September 7, 2010

Default Namespace project property difference between C# and VB.Net

If you right click on a project in Visual Studio (2010), under application tab there is a property called Default namespace. Both C# and VB.Net treat it differently.

In VB.Net, by specifying default namespace project property, it is default root namespace of your library if you don't specify any for your class which is really what it should do I think. For instance, if you had a following class in file MyClass.vb and it had no namespace defined and your default namespace in project setting was set to MyApplication, you will access this class as MyApplication.MyClass.

   1: Class MyClass
   2:     Public Function MyMethod()
   3:         ' Do something
   4:     End Function
   5: End Class

In C#, default namespace property is only used as a namespace template name when you create new files. It does not effect the root namespace of your library (dll). For instance, If default namespace was set to MyApplication with following class then your class will end up in no namespace. To access your class in other projects, you just have to type MyClass which is not the solution one would want to keep, since all classes from this library will end up in default namespace (no namespace).



   1: class MyClass
   2: {
   3:     public void MyMethod()
   4:     {
   5:         // Do something
   6:     }
   7: }

Monday, September 6, 2010

Dependency Injection – Unity IoC Container

Had been looking around on the web to pick one of the dependency injection container and came across video from David Hayden. Its a great video for quick start and shows a lot of features of Unity.

You can watch the video at: http://www.pnpguidance.net/Screencast/UnityDependencyInjectionIoCScreencast.aspx

Wednesday, September 1, 2010

Using Fiddler to test WCF Post methods

By default, WCF only allows JSON and XML for post data. It'll not allow callers to post data using html forms unless mime type application/x-www-form-urlencoded is supported.

In order to post data, json or xml, view the service /help page which gives you the exact format. This message template can be used as fiddler Request Body under Request Builder Tab.

When mime type application/x-www-form-urlencoded is enabled from wcf service. past the query string in Request Body

For e.g. if your html link was like http://www.mysite.com/index.html?param1=1&param2=2&param3=3

In Fiddler Request Builder
- Set Method to Post
- url as http://www.mysite.com/index.html
- Request Header
    User-Agent: Fiddler
    content-type: application/x-www-form-urlencoded
- Request Body
    param1=1&param2=2&param3=3

Also if an object was excepted on wcf side, for instance following service contract
getData(Person p)

Where p is

class Person
{
    [DataMember]
    public string name;
    [DataMember]
    public string age;
}

Request Header will be the same as above but Request Body will be like:
Person.name=John Smith&Person.age=25

As a best practice, keep your Request Body case sensitive to avoid any issues.