Showing posts with label web service. Show all posts
Showing posts with label web service. Show all posts

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")]

Wednesday, December 9, 2009

Sending XML input to a web method expecting a string

Submit this story to DotNetKicks

I'm working on a project where I receive data in XML format. So far I have been using the auto-generated .asmx front-end form to send inn small XML one-liners just for testing my parsing logic.

But when I wanted to use soap UI to send in larger portions, not to mention being able to save the whole scenario for later use, I ran into a problem. Whatever I sent in I only got "#status# HTTP/1.1 400 Bad Request".

Even just sending just the XML declaration gave me this problem!

But when I sent the exact same string from the auto-generated form, it was working perfectly. Which led me to believe there was (as usual) someone working behind the scenes, doing things without asking me.

Finally I found a post with the answer I was looking for.

In short, wrap your XML inside a CDATA section, and you're good to go.