I have a set of web service methods returning a ActionResult class holding the following properties:
object returnValue
bool success
string message
the returnValue is used to hold different types of return values depending on the web methods used.
The problem I have on the client is that if a web method is returning an internal class in the returnValue I can’t cast it due to the client don’t recognize the type.
I can fejk methods to be able to expose the class “Issue” I need.
Ex:
Issue ExposeIssueType()
{
return null;
}
But isn’t there any other way?
While I’m waiting for your answer to my comment, I’ll tell you that this is a very bad web service design. Each web service operation should return the data it is meant to return. There is no point in creating a class that can hold all possible return values.
Additionally, you should not be using a string message to return errors from a web service. The SOAP protocol has a “SOAP Fault” mechanism for that purpose.
Since you’re using WCF, you have complete support for SOAP Faults. Example:
In the service contract:
In the service:
Data contract for the data returned in the fault: