I have two services I want to interact with through named pipes. I tried this two ways, both by creating two separate ServiceHosts, and by creating multiple endpoints on a single service. The first service works perfectly whether I have the second service or not. For the second service in both cases, I either get an endpoint not found error due to it not finding the named pipe (separate services) or an address filter problem (which setting to Any does not fix). I've checked and double checked my settings, but I'm stumped.
Both the server and client both use the same assembly that has the contract:
[ServiceContract(CallbackContract = typeof(IServiceCallback1), SessionMode = SessionMode.Required)]
public interface IService1
{
....
}
[ServiceContract]
public interface IService2
{
...
}
Here's the server side:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Reentrant, IncludeExceptionDetailInFaults = true)]
class Service1Impl : IService1
{
...
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, IncludeExceptionDetailInFaults = true)]
class IService2Impl : IService2
{
...
}
...
serviceHost1 = new ServiceHost(typeof(Service1Impl));
serviceHost2 = new ServiceHost(typeof(Service2Impl));
try
{
serviceHost2.Open();
serviceHost1.Open();
}
(Yes, I open them in the opposite order, since the client process assumes that Service2 is available if it can connect to Service1)
Here's my configuration for the services:
<system.serviceModel>
<services>
<service name="Service1Impl" behaviorConfiguration="myServiceBehavior">
<endpoint address="" binding="netNamedPipeBinding" contract="IService1"/>
<host>
<baseAddresses>
<add baseAddress="net.pipe://localhost/Service1"/>
</baseAddresses>
</host>
</service>
<service name="Service2Impl" behaviorConfiguration="myServiceBehavior">
<endpoint address="" binding="netNamedPipeBinding" contract="IService2"/>
<host>
<baseAddresses>
<add baseAddress="net.pipe://localhost/Service2"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="myServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Client-side I don't use configuration and use this for both:
public class Service2Client: ClientBase<IService2>, IService2
{
public Service2Client()
: base(new NetNamedPipeBinding(), new EndpointAddress("net.p开发者_JS百科ipe://localhost/Service2"))
{
}
}
Is there something I'm missing here? Like I said, I can connect and make calls on the first service just fine, but the second gets EndpointNotFoundException complaining that it couldn't find the named pipe.
精彩评论