none
WCF Service connection RRS feed

  • Question

  • Hello all

    I have created a WCF service and consumed it with a UWP app. I have an issue where at times the clients connection drops just before the server completes its return causing the data to get out of sync. I need to server to roll back if the client does not fully receive the return object.

    I have just discovered that UWP does now support System.Transaction so I cannot wrap my service in transaction scope

    I am working on a work around but have be hindered and progress has stalled.

    my questions are:

    1. is there a way for the Client to use the same WCF server side object for every call (same session)? I have noticed that every call to the service fires the WCF constructor.

    and

    2. when the client sends data to the service and is waiting for a response, is there a way to test on the server side that the client received the response successfully.

    example

    public string getname(){

    return "Melinda"; <---is there a success event or such when the client receives this, or a failure

    }

    Thank You

    Tuesday, April 18, 2017 2:31 PM

All replies

  • >>is there a way for the Client to use the same WCF server side object for every call (same session)?

    You could try InstanceContextMode =InstanceContextMode.PerSession. But the WCF constructor will be called by every called.

    You could refer below link for more information about InstanceContextMode =InstanceContextMode.PerSession.

    #Sessions, Instancing, and Concurrency

    https://msdn.microsoft.com/en-us/library/ms731193(v=vs.110).aspx

    >>when the client sends data to the service and is waiting for a response, is there a way to test on the server side that the client received the response successfully

    For this issue, I think you could try duplex, and you could try below link.

    #How to use duplex and TCP binding in WCF in UWP app

    https://code.msdn.microsoft.com/windowsapps/How-to-use-duplex-and-TCP-9b14b1bd

    In addition, if you have any issue for the second question, I would suggest you post a new thread, and then we could focus on the specific issue in one thread.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 19, 2017 4:45 AM
  • Question 1)

    You want to implement a Singleton service.

    Specifically, your InstanceContextMode should be:

    [ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
    Single: A single InstanceContext (and therefore service object) handles all client requests for the lifetime of the application.

    Question 2)

    You can implement a duplex service 

    "A duplex service contract is a message exchange pattern in which both endpoints can send messages to the other independently. A duplex service, therefore, can send messages back to the client endpoint, providing event-like behavior"




    william xifaras


    Thursday, April 20, 2017 7:42 PM