Hi Matt:
> [WebMethod]
> public bool IsValidProduct(int prod)
> {
> // return true if valid, false if not
> }
This is good (if you don't want to pass a status message back).
> [WebMethod]
> public bool IsValidProduct(int prod, out string Error)
> {
> // return true if valid, false if not, and populate Error
> // with meaningful string
> }
Hmm... You won't be able to consume this web method from a VB.NET client
(you will have to use an initialized ByRef parameter). Also, you will need
to specify the SoapRpcMethod attribute with this web method, making it
non-conformant with WS-I Basic Profile 1.1
A better way is:
class Status
{
public bool isValid;
public string message;
}
public Status IsValidProduct (int productId)
{
//...
}
> [WebMethod]
> public void ValidateProduct(int prod)
> {
> // if product is not valid, raise exception
> }
Don't use exceptions for program flow.
Hope this helps,
Mujtaba.
mabster - 20 Dec 2004 03:45 GMT
> Hi Matt:
>
>>public bool IsValidProduct(int prod)
>
> This is good (if you don't want to pass a status message back).
Yeah, but it's pretty useless to the end-user if I don't. Next ...
>>public bool IsValidProduct(int prod, out string Error)
>
> Hmm... You won't be able to consume this web method from a VB.NET client
> (you will have to use an initialized ByRef parameter). Also, you will need
> to specify the SoapRpcMethod attribute with this web method, making it
> non-conformant with WS-I Basic Profile 1.1
Sounds like work :) Next ...
> A better way is:
>
[quoted text clipped - 5 lines]
>
> public Status IsValidProduct (int productId)
Ok, that sounds reasonable. Does the FCL define a type similar to your
'Status' example above for this sort of thing? It sounds like a common
enough task.
>>[WebMethod]
>>public void ValidateProduct(int prod)
[quoted text clipped - 3 lines]
>
> Don't use exceptions for program flow.
Yeah, I didn't like that last one either.
That said - it makes sense to raise an exception in the UpdateXXX method
if data is invalid, right? I mean, the UpdateXXX method *expects* valid
data - anything else has to be an exception.
Thanks for you reply!
Matt