Passing Nullable To Web Methods C#
Is it possible to pass a nullable parameter to a webservice ?
I tried with this method :
[WebMethod]
public Response<bool> IsAColor(bool? isRed, bool? isYellow, bool? isBlue, bool? isBlack)
{
...
}
And i get this error : System.FormatException: Value 'null' cannot be converted to type 'Boolea开发者_运维知识库n'.
Thanks !
After showing the way you are invoking your web service in SoapUI the problem is the following line:
<num:isRed>null</num:isRed>
That's invalid boolean value. Remove this tag completely if you want to pass null to the isRed
parameter.
Like this:
<num:IsAColor>
<num:isYellow>false</num:isYellow>
<num:isBlue>false</num:isBlue>
<num:isBlack>true</num:isBlack>
</num:IsAColor>
精彩评论