Tuesday, October 12, 2010

ASP.NET Web service gotcha

Submit this story to DotNetKicks

The last 30 minutes spent debugging why suddenly my .asmx didn't show the default web service front end any more. I could not invoke the service through the browser.


Then I tried looking at the wsdl, which gave me a clue...
System.InvalidOperationException: Both System.String InsertNewUserInCRM(MBL.UserData.CobraMontelUser) and System.String InsertNewUserInCRM(System.String, System.String, System.String, System.String, System.String, System.String, System.String, System.String, System.String, System.String) use the message name 'InsertNewUserInCRM'.  Use the MessageName property of the WebMethod custom attribute to specify unique message names for the methods.

So now you see what I saw: I tried overloading web methods, which of course won't work. But there was no build error, no warning in VS and no error on the web page!

Fix: Either create a new name for the second method, or change the messagename, for example:
[WebMethod( MessageName ="InsertCobraMontelUser")]