So, I created Client / Server WCF. I want when I send a message to the server from this client and for some reason the connection is disconnected, the client is turned off, for example, how can this client get a response when it will be available again?
Is it possible to establish a session or something like this between a client and a server?
My client code:
private static void Main(string[] args) { var client = new FlipCaseServiceClient("ReliableMessageService"); var sd = new StringData { FirstName = "Turgut", LastName = "Kançeltik" }; var fullName = client.GetFullName(ref sd); Console.WriteLine(fullName); }
My server code:
[DeliveryRequirements(RequireOrderedDelivery = true)] [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Single)] public class FlipCaseService : IFlipCaseService { public string GetFullName(ref StringData stringData) { var fullName = $"{stringData.FirstName} {stringData.LastName}"; stringData.FullName = fullName; return fullName; } }
And the server configuration as a whole:
<service behaviorConfiguration="ServiceBehaviorMetaData" name="FlipCaseService.FlipCaseService" > <endpoint name="ReliableMessageService" address="flipcase/wsAddress" binding="wsHttpBinding" bindingConfiguration="BindingReliableMessaging" contract="FlipCaseService.IFlipCaseService" > <identity> <dns value="localhost" /> </identity> </endpoint> </service> <bindings> <wsHttpBinding> <binding name="BindingReliableMessaging"> <reliableSession enabled="true" inactivityTimeout="00:10:00"/> </binding> </wsHttpBinding> </bindings> <behavior name="ServiceBehaviorMetaData"> <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8080/flipcase/metadata" /> <serviceDebug includeExceptionDetailInFaults="true" /> </behavior>
source share