Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create client proxy without svcutil or add service reference in wcf?

Tags:

wcf

How can I create a client proxy without svcutil.exe or add service reference in wcf? I want to create a client proxy at compile time.

like image 719
Embedd_0913 Avatar asked Jul 06 '09 11:07

Embedd_0913


People also ask

What is required by the client to generate proxy?

A metadata exchange endpoint is required to support the dynamic generation of proxy and configuration for client applications. You must explicitly enable metadata exchange by adding the endpoint and enabling the metadata exchange behavior.

Which of the following must be implement in order to create WCF proxy manually?

The WCF client proxy can be generated manually by using the Service Model Metadata Utility Tool (SvcUtil.exe) for more information see, ServiceModel Metadata Utility Tool (Svcutil.exe). The WCF client proxy can also be generated within Visual Studio using the Add Service Reference feature.

How do I change my WCF service reference?

In Solution Explorer, right-click the service reference and then click Update Service Reference.


1 Answers

If you have access to the service contract (the IService interface) in a separate DLL, you can add a reference to that service contract DLL and then do something like:

NetTcpBinding binding = new NetTcpBinding();
EndpointAddress address = new EndpointAddress("net.tcp://localhost:9000/YourService")

ChannelFactory<IService> factory = new ChannelFactory<IService>(binding, address);
IService proxy = factory.CreateChannel();

and then you have your programmatically created proxy, which you can now use as you wish.

like image 135
marc_s Avatar answered Oct 05 '22 08:10

marc_s