You need to know three things to call a WCF service:
- Address - where to call to - in your case
net.tcp://localhost:25488/MyDataAccessService/MyFirstBindingAddress
- Binding - what protocol and parameters to use (in your case:
netTcpBinding
) - Contract - the service contract (the
public interface IMyDataAccessService
) to define the service methods and parameters needed
Once you have these things, you can easily set up a client in code:
NetTcpBinding binding = new NetTcpBinding(NetTcpBinding.None);
EndpointAddress address = new EndpointAddress("net.tcp://localhost:25488/MyDataAccessService/MyFirstBindingAddress");
ChannelFactory<IMyDataAccessService> channelFactory = new ChannelFactory<IMyDataAccessService>(binding, address);
IMyDataAccessService _clientProxy = channelFactory.CreateChannel();
and now your _clientProxy
can easily call up the methods on the server, passing in the parameters etc.
Of course, for this to work, you must have the contract! E.g. you must have access to the file that define the service contract (and possibly the data contracts, too - the data types being sent back and forth). Since you're using the netTcpBinding
, I'm assuming both ends of the wire are built using .NET here.
Those items can easily be included into a separate class library project that both the service developers as well as the client-side developers can share and use.