Sunday, March 20, 2011

WCF Basic Authentication:Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.

I was testing the service to authenticate users with basic authentication over http (not https). To Achieve this, I used basicHttpBinding as binding and configured it for TransportClientCredentialOnly security mode.

<binding name="http_transport_basic">
<security mode="TransportCredentialOnly">
<transport clientCredentialType ="Basic"/>

Everything was looking good so far until I hit the f5 to visit the familiar yellow error page complaining about InvalidMexHttpPoint

But why. I am using basic authentication and basic authentication is enabled in the IIS. Thanx to the Mapelli for the post which points the cause of the problem. I removed the mex point and hit F5 again. There is no more error page. But now the question arises, Is there any way to include the mex point?. Answer is yes. I just replaced the mex binding from  “mexHttpBinding” to basicHttpBinding and created the bindingConfiguration similar to the service endpoint’s binding configuration. This change enabled me to use the mex point which is also configured for basic authentication.

WCF Error: The contract name ‘IMetadataExchange’ could not be found in the list of contracts implemented by the service

This is the most common error almost everyone receives when starts learning WCF and mostly because you have overlooked the configuration. It is easy to miss the typo mistake and specially when it is just matter of lower or upper case of a single character. We, developers, are normally used to capitalize the “D” of the “Data” and this is what we do with “IMetadataExchange” and type “IMetaDataExchange”. Remember configuration parser is case sensitive and it treats “IMetadataExchange” and “IMetaDataExchange” differently. WCF complains this typo mistake in this fashion.spelled wrong

This error clearly states that it is unable to find the contract. Now even after correcting the mistake you still can face another yellow screen of error


This happens because

  • You have not defined serviceMetadata behavior. Go to configuration file and add following configuration sample.
    <behavior name="default">
    <serviceMetadata httpGetEnabled="true" />

  • You have defined the service behavior but have not set the service behavior configuration name. Set the behaviorConfiguration attribute of the service to the name of the service behavior you defined.
<service name="Service" behaviorConfiguration ="default">

Sunday, February 20, 2011

Amazon Route 53: .Net library is here.

At the end of the year 2010, Amazon has launched a new web service called “Amazon Route 53” which is focused on operating DNS. Addition of this web service in the stack of Amazon web service suite has made hard for the competitors to stand near the Amazon.
Amazon Route 53 is designed to be fast, easy to use, easy to program and cost effective.  An easy to use API has made it easy to integrate this service into an existing application and let you offer the UI of your own choice to your users.   
What is Amazon Route 53?
The name Amazon Route 53 comes from the fact that port 53 is used to entertain the DNS queries. According to Amazon
“Amazon Route 53 is a highly available and scalable Domain Name System (DNS) web service. It is designed to give developers and businesses an extremely reliable and cost effective way to route end users to Internet applications”.
It also provides a programmatic access to work with DNS like adding, modifying or deleting DNS records.
Amazon Route 53 and .Net
Amazon has exposed an XML  RESTful web service API for programmatic access. Dealing with the raw RESTful request and response is very much painful and prone to errors. But thanks to the WCF architecture which enables .net developers to deal with this raw data as strongly typed classes and takes care of the complicated coding part itself. But the real art is how to configure and code WCF to lessen the pain and increase the gain.
Here is my library with source code for you. Amazon.Route53 is now moved to codeplex. It is free to use.
If you find any better way to code Route 53 or any bug in my code then please let me know.