Note that there are some explanatory texts on larger screens.

plurals
  1. POSelf hosting two wcf interfaces (one of them is duplex)
    primarykey
    data
    text
    <p>I need to build a service that serves two interfaces. One interface uses basicHttpBinding, and the other should be netTcpBinding. The other one should also support duplex communication.</p> <p>basicHttp interface:</p> <pre><code>[ServiceContract(Name = "accesspointService")] [XmlSerializerFormat] public interface IVERAAccessPoint { [OperationContract] CompositeType GetDataUsingDataContract(MyClass obj); } </code></pre> <p>Implementation:</p> <pre><code> [ServiceBehavior(Name = "accesspointService", Namespace = "http://www.w3.org/2009/02/ws-tra")] public class VERAAccessPoint : IVERAAccessPoint { public CompositeType GetDataUsingDataContract(MyClass obj) { //something return composite; } } </code></pre> <p>duplex netTcpContract:</p> <pre><code>[ServiceContract(CallbackContract = typeof(IClientCallback))] public interface IVERAAPCS { [OperationContract(IsOneWay=true)] void Subscribe(ClientInfo info); [OperationContract(IsOneWay=true)] void Unsubscribe(ClientInfo info); } public interface IClientCallback { [OperationContract(IsOneWay = true)] void PushDocument(XDocument doc); } [DataContract] public class ClientInfo { public string id; } </code></pre> <p>And implementation:</p> <pre><code>[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession,ConcurrencyMode = ConcurrencyMode.Single)] public class VERAAPCS : IVERAAPCS { public void Subscribe(ClientInfo info) { //something } public void Unsubscribe(ClientInfo info) { //Something } } </code></pre> <p>I tried to self host both interfaces and this is the best i could do:</p> <pre><code>Uri baseAddress1 = new Uri("http://localhost:6544/hello"); //host the first interface using (ServiceHost host = new ServiceHost(typeof(VERAAccessPoint.VERAAccessPoint), baseAddress)) { // Enable metadata publishing. ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); smb.HttpGetEnabled = true; smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; host.Description.Behaviors.Add(smb); host.Open(); //Host the second (duplex interface) using (ServiceHost host2 = new ServiceHost(typeof(VERAAccessPoint.VERAAPCS))) { host2.AddServiceEndpoint(typeof(VERAAccessPoint.IVERAAPCS), new NetTcpBinding(), "net.tcp://localhost:6543/hello2"); host2.Open(); Console.ReadLine(); host2.Close(); } host.Close(); } </code></pre> <p>Now for the consuming part: //Consuming the first interface (this works so i removed it form the question) //Consuming the second interface:</p> <pre><code>var myBinding = new NetTcpBinding(); var myEndpoint = new EndpointAddress("net.tcp://localhost:6543/hello2"); var myChannelFactory = new ChannelFactory&lt;VERAAccessPoint.IVERAAPCS&gt;(myBinding, myEndpoint); VERAAccessPoint.IVERAAPCS client = null; client = myChannelFactory.CreateChannel(); </code></pre> <p>This produces the following error:</p> <blockquote> <p>ChannelFactory does not support the contract IVERAAPCS as it defines a callback contract with one or more operations. Please consider using DuplexChannelFactory instead of ChannelFactory.</p> </blockquote> <p>But I just can't seem to find a way to use the duplexChannelFactory. So my question is basically how do you consume a duplex netTcpBinding service tat is self hosted?</p> <p>Sorry for the long question, but I wanted to provide as much information as I could. Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload