Hi, All,
I have a very simple webmethod:
[WebMethod]
public string HelloWorld(int i)
{
return i.ToString();
}
when someone call this service to pass a empty string and I got the nasty
error like:
System.ArgumentException: Cannot convert Test to System.Int32.
Parameter name: type ---> System.FormatException: Input string was not in a
correct format.
at System.Number.ParseInt32(String s, NumberStyles style,
NumberFormatInfo info)
at System.String.System.IConvertible.ToInt32(IFormatP rovider provider)
at System.Convert.ChangeType(Object value, Type conversionType,
IFormatProvider provider)
at System.Web.Services.Protocols.ScalarFormatter.From String(String value,
Type type)
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.ScalarFormatter.From String(String value,
Type type)
at
System.Web.Services.Protocols.ValueCollectionParam eterReader.Read(NameValueC
ollection collection)
at System.Web.Services.Protocols.UrlParameterReader.R ead(HttpRequest
request)
at System.Web.Services.Protocols.HttpServerProtocol.R eadParameters()
at System.Web.Services.Protocols.WebServiceHandler.In voke()
at System.Web.Services.Protocols.WebServiceHandler.Co reProcessRequest()
Is there a way to override the behavior? I tried the SoapExtension and try
to change the empty string