2

I wish to use proxy objects in c#. I will probably implement the networking through Windows Communication Foundation. So far I've just made a very basic WCF service which works on different processes of on the same computer. I want the client class to be able to use the real object on the same process and use a proxy object to access the real object across the internet. Now I can manually make an interface for all the methods, I want to use across the internet, manually make a proxy class which calls a service foe each of those methods, and manually create each of those services on both the service host and service client.

However is the any way I can get WCF or any software to automatically create the interface and the proxy class?

1 Answer 1

5

It sounds like what you want to use is svcutil.exe, which is intended to read a service's metadata and create C# classes.

Documentation is here: http://msdn.microsoft.com/en-us/library/aa347733.aspx

and more specifically here: http://msdn.microsoft.com/en-us/library/aa751905.aspx

There are a broad (very broad!) range of options controlling the proxy classes that are generated. At its simplest

svcutil http://service/metadataEndpoint

will read the metadata and create C# classes in one go.

Alternatively, if you're using Visual Studio 2005 or above, right-click on a project, choose "Add service reference..." and follow the dialogs to generate client proxies. This allows you to easily customise the proxy classes.

Note that you will need to publish metadata of some kind for the utility to work. See here: http://msdn.microsoft.com/en-us/library/ms734765.aspx for details on enabling this.

Sign up to request clarification or add additional context in comments.

3 Comments

As I understand it these methods only generate the client for the service, not the service itself. I was wondering if the service could be automatically generated in the way that Visual Studio auto generates an interface for a class through re-factoring.
How would it be able to generate the service? How does it know what methods of a class you want to expose?
In the same way you Visual Studio auto generates interfaces for classes. It just offer a list of methods and properties and asks you to tick the ones yuo want, or there's an option to use all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.