I'm working on an old WCF service with many interfaces and services for a new system. I want to change return type of functions without changing all service interfaces and implementations as follow:
interface OperationResult
{
ErrorInfo Error { get; set; }
}
interface OperationResult<TResult> : OperationResult
{
TResult Result { get; set; }
}
// old service
interface IService
{
int TestMethod1(TestMethod1Input input);
void TestMethod2(TestMethod2Input input);
}
// Interface that client should see
interface IService
{
OperationResult<int> TestMethod1(TestMethod1Input input);
OperationResult TestMethod2(TestMethod2Input input);
}
I think I can handle exceptions with IOperationInvoker but I don't know how change return value of actual service, and I wanted to change the return type of the function in the WSDL using IWsdlExportExtension. But I couldn't find any well documentation or sample for either of them.
Can anyone suggest any sample or documentation or any other way that can save me the trouble of changing too many already existing services?
NOTE: I have another way of doing this by creating a custom ServiceHost that create a dynamic wrapper for actual service and pass it as service type to constructor of ServiceHost. But this should be last solution since it will generate many dynamic types.