I want to build a WCF Service
application, which is supposed to use a library of mine in order to make all the library's methods available for the service's client. There must be a better way than explicitly writing an OperationContract
for each method of my library, which acts as some kind of proxy and calls the library's actual method on the server's side in order to get the returnvalue and deliver it back to the client.

- 3,004
- 3
- 25
- 41
-
You can try to combine relevant methods. But that's not always possible of course. But when it comes down to it, if you want to be able to call that method, you have to have an operation contract for it. Maybe giving us an idea of what you're working with could help us suggest other paths. – ernest Jun 28 '13 at 12:58
-
I have a library, which provides some methods to administrate my domain's active directory and I want to make it available via WCF. This way the library could stay where it is and still could be used remotely via a WCF client. – wodzu Jun 28 '13 at 13:05
-
You just repeated what you said above. If you want access to those methods, you'll have to have an operation contract per method. – ernest Jun 28 '13 at 13:27
2 Answers
There must be a better way than explicitly writing an OperationContract for each method of my library
No, not really.
Also remember a library often is stateful, i.e. you instantiate an object, and when you call instance methods against that object, you preserve state as you saved private members at instance level.
Only static
methods could be 'directly' mapped to service operations.
Most probably, you might want to entirely write your WCF contract from scratch to make it service-friendly (i.e. stateless), and possibly interoperable (faults instead of exceptions...etc.)

- 48,145
- 10
- 116
- 176
If you want access to those methods, you'll need to create operation contracts for them.
You can make this easier by creating a small app that loops through the code files, finds and the method signatures, and then formats them for the interface. Then you'd just need to copy that code into the interface.

- 1,633
- 2
- 30
- 48
-
not quite what I was looking for, but still thanks. So there is no nice way without workarounds – wodzu Jun 28 '13 at 14:13
-
Yeah, it's not ideal, but it shouldn't take more than 10-15 minutes to make the loop. You could probably generate the methods for the .svc file and the code to call your other methods at the same time. – ernest Jun 28 '13 at 16:01