If I have a WebMethod that takes a parameter, what is the correct way to
validate it? I could throw an exception, but that does not seem right.
public DataSet TestMethod( string MyString )
{
// Validation Code
if ( MyString =="InvalidValue" )
Throw SoapException();
// Real code starts here
return ds;
}
RobertP - 23 Mar 2005 00:19 GMT
Totally missed the post by Mark yesterday. I with the information posted
there unless anyone has any additional words of wisdom to add.
Thanks!
> If I have a WebMethod that takes a parameter, what is the correct way to
> validate it? I could throw an exception, but that does not seem right.
[quoted text clipped - 8 lines]
> return ds;
> }
Manohar Kamath - 23 Mar 2005 00:33 GMT
You could throw an exception, but any exception you throw comes back as a
SOAP exception. You could do one of the two things:
1. Throw a custom exception on the server-side, and parse the SOAP
exception's message on the client to check the name of the exception.
http://www.devx.com/vb2themax/Tip/19505
2. Use a helper class on the server to wrap the exception, and throw this
instead:
http://www.microsoft.com/belux/nl/msdn/community/columns/jtielens/soapexceptions.mspx

Signature
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
> If I have a WebMethod that takes a parameter, what is the correct way to
> validate it? I could throw an exception, but that does not seem right.
[quoted text clipped - 8 lines]
> return ds;
> }