Click here to Skip to main content
15,908,768 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionMissing Parameters in call to WebService Pin
Miszou31-Jul-08 7:12
Miszou31-Jul-08 7:12 
I have a trivial webservice set up that takes a single parameter and returns a number of items according to the value of the parameter:

[WebMethod( Description="Returns the top 'count' latest articles.")]
public XmlDataDocument GetLatestArticles( int count )
{
	if (count < 1)
		count = 1;
	if (count > 100)
		count = 100;
	return ArticleCache.GetLatest( count );
}
I have some simple parameter checking, such that the method will always return at least one article and at most, 100 articles.

However, if the client does not provide the count parameter at all, a System.ArgumentException is thrown before the webmethod is called and an ugly error is returned to the client. I would like to be able to catch this exception and supply a 'default' value to the inner method call, so that the client continues to function.

I tried making the count parameter nullable, but then the default WsdlHelpGenerator.aspx doesn't display it, because "The test form is only available for methods with primitive types as parameters." This makes it rather difficult to test - especially as the services are for consumption by a third party developer.

Is there any (elegant and easy) way of catching the exception and handling it gracefully?

Thanks.


AnswerRe: Missing Parameters in call to WebService Pin
SomeGuyThatIsMe31-Jul-08 8:24
SomeGuyThatIsMe31-Jul-08 8:24 
QuestionCan't load WebControl from subfolder Pin
hajoshajo31-Jul-08 6:16
hajoshajo31-Jul-08 6:16 
AnswerRe: Can't load WebControl from subfolder Pin
Gayani Devapriya31-Jul-08 23:57
Gayani Devapriya31-Jul-08 23:57 
QuestionWeb.Config vs. Machine.Config Pin
KreativeKai31-Jul-08 5:13
professionalKreativeKai31-Jul-08 5:13 
AnswerRe: Web.Config vs. Machine.Config Pin
led mike31-Jul-08 5:31
led mike31-Jul-08 5:31 
Questionrequest project website from other PC in network Pin
piyush_patel111131-Jul-08 4:53
piyush_patel111131-Jul-08 4:53 
AnswerRe: request project website from other PC in network Pin
Bassam Saoud31-Jul-08 12:02
Bassam Saoud31-Jul-08 12:02 
GeneralRe: request project website from other PC in network Pin
piyush_patel11114-Aug-08 23:23
piyush_patel11114-Aug-08 23:23 
Questioncheck and click programmattically Pin
caradri31-Jul-08 4:21
caradri31-Jul-08 4:21 
QuestionRequired fields in a gridview [modified] - Answered Pin
Dan Neely31-Jul-08 4:07
Dan Neely31-Jul-08 4:07 
AnswerRe: Required fields in a gridview [modified] - Answered Pin
eyeseetee31-Jul-08 4:31
eyeseetee31-Jul-08 4:31 
QuestionRunning javascript from server side. Pin
JimBob SquarePants31-Jul-08 3:43
JimBob SquarePants31-Jul-08 3:43 
AnswerRe: Running javascript from server side. Pin
led mike31-Jul-08 4:44
led mike31-Jul-08 4:44 
GeneralRe: Running javascript from server side. Pin
JimBob SquarePants31-Jul-08 5:20
JimBob SquarePants31-Jul-08 5:20 
GeneralRe: Running javascript from server side. Pin
led mike31-Jul-08 5:27
led mike31-Jul-08 5:27 
GeneralRe: Running javascript from server side. Pin
JimBob SquarePants31-Jul-08 6:42
JimBob SquarePants31-Jul-08 6:42 
QuestionUse multiple queries to update a db from a gridview Pin
Dan Neely31-Jul-08 3:36
Dan Neely31-Jul-08 3:36 
Questionhow to make a Task Scheduler in asp.net Pin
dream_liner_7e731-Jul-08 1:33
dream_liner_7e731-Jul-08 1:33 
AnswerRe: how to make a Task Scheduler in asp.net Pin
Ashfield31-Jul-08 1:37
Ashfield31-Jul-08 1:37 
QuestionRe: how to make a Task Scheduler in asp.net Pin
dream_liner_7e731-Jul-08 1:56
dream_liner_7e731-Jul-08 1:56 
AnswerRe: how to make a Task Scheduler in asp.net Pin
Paddy Boyd31-Jul-08 2:12
Paddy Boyd31-Jul-08 2:12 
JokeRe: how to make a Task Scheduler in asp.net Pin
Brady Kelly31-Jul-08 2:53
Brady Kelly31-Jul-08 2:53 
GeneralRe: how to make a Task Scheduler in asp.net Pin
Paddy Boyd31-Jul-08 2:58
Paddy Boyd31-Jul-08 2:58 
GeneralRe: how to make a Task Scheduler in asp.net Pin
dream_liner_7e731-Jul-08 5:52
dream_liner_7e731-Jul-08 5:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.