Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / March 2005

Tip: Looking for answers? Try searching our database.

How do I validate a WebMethod's properties?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RobertP - 23 Mar 2005 00:07 GMT
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;
> }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.