Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am creating a WCF service, which has many classes and many methods like GetCustomer, SaveCustomer, SaveTransaction etc. when we consume this service and call any method i want to return a generic response message. e.g. if i call SaveCustomer then in my response i want to send responseCode=SUC (its for request is successfuly came or not) result=Accepted, responseMessage="Customer data saved" so i created class like blow:
public string result { get; set; }
public string responseCode { get; set; }
public string responseMessage { get; set; }
and want to return that customer or transaction object also, if customer object came in request then my above class object plus customer that object if transaction object came then my above class object plus that trasaction object. there are many other classes also. and what should the output type of that all methods.
thanks

What I have tried:

public class clsBFCAPIResponse
{
public string result { get; set; }
public string responseCode { get; set; }
public string responseMessage { get; set; }
}
Posted
Updated 11-Feb-17 0:05am
v2
Comments
Jon McKee 10-Feb-17 1:36am    

Make a complex class and add objects of those classes as properties. Then instantiate object of this complex class and return that by assigning values.
 
Share this answer
 
You can make response class for each response type and let the response class inherit from clsBFCAPIResponse
e.g. class CustomerResponse: clsBFCAPIResponse{
Customer cust {get; set;}
}
class TransactionResponse: clsBFCAPIResponse{
Transaction trans {get; set;}
}
Such that each response will have it's specific type.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900