Matt Phillips
Matt Phillips

Reputation: 11499

Wrapping a web service around a library

I want to wrap a WCF web service around a client library that accesses a REST API. Currently I'm just copying the exact method names of the client class as webservice methods and all of the methods look like this

[OperationContract]
public <return-type-of-client-method> MethodName ()
{
    return client.MethodName();
}

Is there a way to wrap these calls more efficiently in WCF? I would really not like to have to define 200+ methods like this if there is an easier way to do it.

Upvotes: 2

Views: 690

Answers (1)

Robert Groves
Robert Groves

Reputation: 7738

I don't know if there is "a canonical solution," but if the client library in question is a .NET library you could write a code generator that use reflection to generate the necessary code. Just feed it a list of the library methods you'd like to expose, use reflection to get the return type of the client method and then just spit out that snippet of code for each method in the list.

Upvotes: 1

Related Questions