Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Methods with Nullable Types not working in ASMX Web Service using GET

I have an ASMX Web Service set up to use the HTTP GET method. Simple methods which take basic String and Int parameters are working ok, and I can call MyService.asmx/MethodName?Param=Value and get a response back in XML.

However, when I have a method which has a nullable Int (i.e. int?), I get this error:

< Method Name > Web Service method name is not valid.

The error message is confusing, as the method does exist, just not in the GET scope. I presume this is because a nullable type is too complex to be passed via the URL, but I can't find any documentation or SO posts on this.

I appreciate that complex types like Lists or custom classes etc will not work using GET, but I would have assumed that a simple nullable int or nullable datetime could be handled natively, simply by detecting whether it was omitted from the URL. Guess it's not that simple!

Any advice or workarounds would be greatly appreciated.

Thanks, Tim

like image 281
TimS Avatar asked Mar 14 '11 16:03

TimS


1 Answers

nullable int is not too complex. it should produce

  <s:element minOccurs="1" maxOccurs="1" name="Param" nillable="true" type="s:int" /> 

in WSDL. Check out this post. The error could be for something else, perhaps?

like image 62
Bala R Avatar answered Nov 11 '22 05:11

Bala R