I wonder if it's possible to assign a default value for web service request input parameter. Here's my input parameter in the wsdl:
<element name="pensionType" default="0" type="int">
In the code side I check for the value of pensionType like this:
if (pensionType!=0)
{ TODO code here}
else
{ return warning that no data found}
I tested this in Mozilla Poster. So from this I expected that if I didn't supply any value to pensionType I'd get that warning. I get a long error:
System.Web.Services.Protocols.SoapException: Server was unable to read request. ---> System.InvalidOperationException: There is an error in XML document (13, 39). ---> System.FormatException: Input string was not in a correct format. at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.Xml.XmlConvert.ToInt32(String s) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read44_getFileTypesRequest(Boolean isNullable, Boolean checkType) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read45_getFileTypes(Boolean isNullable, Boolean checkType) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read62_getFileTypes() at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer24.Deserialize(XmlSerializationReader reader) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) --- End of inner exception stack trace --- at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle) at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters() --- End of inner exception stack trace --- at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters() at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest(
You can do like this:
if(pensionType != null)
{
if (pensionType!=0)
{ TODO code here}
else
{ return warning that no data found}
}
This may help you..!!