Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF service callback not called
    text
    copied!<p>I am using tcp binding in WCF service and my callback at client side in not getting called.This is my code</p> <p>Service </p> <pre><code> public interface IMyContractCallback { [OperationContract(IsOneWay = true)] void OnCallback(); } [ServiceContract(CallbackContract = typeof (IMyContractCallback),SessionMode = SessionMode.Required)] public interface IService1 { [OperationContract(IsOneWay = true)] void DoSomething(); [OperationContract] int GetCount(); } public class Service1 : IService1 { private int count=0; public int GetCount() { return count; } public void DoSomething() { count++; Console.WriteLine("increased count"); IMyContractCallback callback = OperationContext.Current.GetCallbackChannel&lt;IMyContractCallback&gt;(); if ((callback as IChannel).State == CommunicationState.Opened) { callback.OnCallback(); } } } </code></pre> <p>and my client is </p> <pre><code>public class App1 { private MyServiceCallback callback; private InstanceContext context; private Service1Client proxy; public App1() { callback=new MyServiceCallback(); context = new InstanceContext(callback); var factory = new DuplexChannelFactory&lt;IService1&gt;(callback, "EndPointTCP"); IService1 proxy = factory.CreateChannel(); callback.proxy = proxy; proxy.DoSomething(); } } public class MyServiceCallback : IService1Callback { public IService1 proxy { get; set; } public void OnCallback() { Console.WriteLine("Callback thread = " + Thread.CurrentThread.ManagedThreadId); Console.WriteLine(proxy.GetCount()); } } </code></pre> <p>I face two issues:</p> <p>1.I dont receive callback from DoSomething with above mentioned code. 2.If I declare DoSomething as Twoway ,I do receive callback but it throws exception "Server did not provide a meaningful reply"</p> <p>My client config</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;configuration&gt; &lt;system.serviceModel&gt; &lt;bindings&gt; &lt;netTcpBinding&gt; &lt;binding name="EndPointTCP" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536"&gt; &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt; &lt;reliableSession ordered="true" inactivityTimeout="00:20:00" enabled="true" /&gt; &lt;security mode="Transport"&gt; &lt;transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /&gt; &lt;message clientCredentialType="Windows" /&gt; &lt;/security&gt; &lt;/binding&gt; &lt;/netTcpBinding&gt; &lt;wsDualHttpBinding&gt; &lt;binding name="EndPointHTTP" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"&gt; &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt; &lt;reliableSession ordered="true" inactivityTimeout="00:10:00" /&gt; &lt;security mode="Message"&gt; &lt;message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" /&gt; &lt;/security&gt; &lt;/binding&gt; &lt;/wsDualHttpBinding&gt; &lt;/bindings&gt; &lt;client&gt; &lt;endpoint address="masked" binding="wsDualHttpBinding" bindingConfiguration="EndPointHTTP" contract="ServiceReference1.IService1" name="EndPointHTTP"&gt; &lt;identity&gt; &lt;servicePrincipalName value="masked" /&gt; &lt;/identity&gt; &lt;/endpoint&gt; &lt;endpoint address="masked" binding="netTcpBinding" bindingConfiguration="EndPointTCP" contract="ServiceReference1.IService1" name="EndPointTCP"&gt; &lt;identity&gt; &lt;servicePrincipalName value="masked" /&gt; &lt;/identity&gt; &lt;/endpoint&gt; &lt;/client&gt; &lt;/system.serviceModel&gt; &lt;/configuration&gt; </code></pre> <p>my Service config</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;configuration&gt; &lt;system.web&gt; &lt;compilation debug="true" targetFramework="4.0"/&gt; &lt;httpRuntime maxRequestLength="102400" /&gt; &lt;/system.web&gt; &lt;system.diagnostics&gt; &lt;sources&gt; &lt;source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true"&gt; &lt;listeners&gt; &lt;add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData= "d:\log\Traces.svclog" /&gt; &lt;/listeners&gt; &lt;/source&gt; &lt;/sources&gt; &lt;/system.diagnostics&gt; &lt;system.serviceModel&gt; &lt;bindings&gt; &lt;netTcpBinding&gt; &lt;binding name="TcpBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" portSharingEnabled="true" &gt; &lt;readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /&gt; &lt;security mode="Transport"/&gt; &lt;reliableSession enabled="true" /&gt; &lt;/binding&gt; &lt;/netTcpBinding&gt; &lt;/bindings&gt; &lt;services&gt; &lt;service behaviorConfiguration="WcfService2.MyServiceBehaviour" name="WcfService2.Service1"&gt; &lt;endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="" name="EndPointHTTP" contract="WcfService2.IService1" /&gt; &lt;endpoint address="" binding="netTcpBinding" bindingConfiguration="TcpBinding" name="EndPointTCP" contract="WcfService2.IService1" isSystemEndpoint="false" /&gt; &lt;endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" name="mexpoint" contract="IMetadataExchange" /&gt; &lt;/service&gt; &lt;/services&gt; &lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="WcfService2.MyServiceBehaviour"&gt; &lt;serviceMetadata httpGetEnabled="false" /&gt; &lt;serviceThrottling maxConcurrentSessions="10000"/&gt; &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt; &lt;dataContractSerializer maxItemsInObjectGraph="2147483647" /&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;/system.serviceModel&gt; &lt;system.webServer&gt; &lt;modules runAllManagedModulesForAllRequests="true" /&gt; &lt;directoryBrowse enabled="true" showFlags="Date, Time, Size, Extension, LongDate" /&gt; &lt;/system.webServer&gt; &lt;/configuration&gt; </code></pre>
 

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