By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,903 Members | 1,977 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,903 IT Pros & Developers. It's quick & easy.

Return value from webmethod problem

P: n/a
Hey. I have a function with a boolean return value, called IsInWarehouse,
which checks if a product is available in a warehouse, or not. But I need
security in the function too, so I have
[WebMethod][SoapHeader("soapHeader")]
public bool IsInWarehouse(string productName) {
if (Login(username, password)) {

// query db about available product

} else {
// ???
}
}

If the product is in stock, it returns true, or else it returns false.
But the caller of the web service needs to know if the login succeeded or
failed. (Because it's custom authentication in a web service, authentication
has to be done inside every procedure that needs it) What do I do with the
type of the return value? bool gives you 2 return values, I need 3.

Thanks for any help
Justin Dutoit

Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
raise a SOAP Exception when the login fails.

--- Nick

"Justin Dutoit" <an**@anon.com> wrote in message
news:eY*************@TK2MSFTNGP10.phx.gbl...
Hey. I have a function with a boolean return value, called IsInWarehouse,
which checks if a product is available in a warehouse, or not. But I need
security in the function too, so I have
[WebMethod][SoapHeader("soapHeader")]
public bool IsInWarehouse(string productName) {
if (Login(username, password)) {

// query db about available product

} else {
// ???
}
}

If the product is in stock, it returns true, or else it returns false.
But the caller of the web service needs to know if the login succeeded or
failed. (Because it's custom authentication in a web service, authentication has to be done inside every procedure that needs it) What do I do with the
type of the return value? bool gives you 2 return values, I need 3.

Thanks for any help
Justin Dutoit

Nov 16 '05 #2

P: n/a
"Justin Dutoit" <an**@anon.com> wrote:
[returning a boolean but wanting a tri-state]


In general, you can either create an enum for each possible state, and
return one of its members:

public enum QueryResult
{
InWarehouse, NotInWarehouse, QueryFailed
}

.... or use an 'out' parameter, to return more than one value:

public bool IsInWarehouse(string productName, out bool queryFailed)
{
queryFailed = false; // but set to 'true' on failure
...
return productFound; // separate true or false
}

P.
Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.