views:

434

answers:

3

I wrote a WCF service and I would like to call this the net pipe binding way. I have deployed this in a Windows service.

I wrote this method in my wcf service:

Add(2,1)

It should return 3

I don't know how to call the service hosted in windows in my client console application. I have started my service.


Note:

I would like to call this from a windows service.

A: 

You want something like this:

NetNamedPipeBinding binding = new NetNamedPipeBinding();
EndpointAddress address = new EndpointAddress("net.pipe://localhost/Foo");
ChannelFactory<IFoo> factory = 
    new ChannelFactory<IFoo>(binding, address);

IFoo foo = factory.CreateChannel();
int result = foo.Add(2, 1);
AgileJon
A: 

If IMyContract is your service contract, you can create a proxy to call your service using the ChannelFactory class:

var proxy = ChannelFactory<IMyContract>.CreateChannel(new NetMsMqBinding(), new EndpointAddress("net.msmq://..."))
proxy.Add(1, 2);
Ray Vernagus
A: 

you need to use ChannelFactory to create a proxy, and then you can use the proxy to perform wcf tasks.

http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication

wschenkai