Maintaining session state in WF calls to WCF service

Locked Maintaining session state in WF calls to WCF service

  • Montag, 9. Juli 2012 10:12
     
     

    I have a set of WCF services generated by third party application which allow me to communicate witha mainframe application.  Using this I can write code of the form:

    Client = new MainframeService.Client;

    Client.Connect;

    Client.GetAccountDetails(1)

    Client. Close;

    This will connect to a terminal emulator based session with the mainframe, get some account details and then disconnect. because I am using the same same instance of MainframeService.Client, the mainframe thinks all requests are comming from the same terminal emulator session.

    What I want to do is the same thing but via a WF sequence. I added a reference to the Mainframe WCF service to my workflow project and this automatically created a set of WCF send/receive activities. However, If I simply create a new sequence and then drag the Connect, GetAccountDetails and Close activities onto the designer and then run my test application, the connect works fine but the GetAccountDetails fails. The actual error says that there is a contract mismatch, but I suspect that behind the scenes, WF is usinga  different instance of the WCF service for the GetAccountDetails call, so the mainframe is regecting the call as I have not logged on.

    Is there any way to force WF to use the same instnace of a WCF client for all calls in a particular sequence? I cannot change the WCF service code (other than the config file), so any chnages wuld have to be at the WF level.

    Thanks

    Nigel


    Nigel T

Alle Antworten

  • Dienstag, 10. Juli 2012 02:03
    Moderator
     
     Beantwortet

    Hi,

    Could you please share the code of your WCF services with us? It will be convenient for us to know how the generated activities work and reproduce this issue.

    The Connect, GetAccountDetails and Close activities themself are WCF clients, you can check the implementation of these service operations to see if it is necessary that using one instance for all calls.

    if you want to use the same instance of a WCF client for all calls, you can create a custom code activity for all calls or create multiple activities with in/out argument of MainframeService.Client. Thanks.


    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Montag, 16. Juli 2012 08:58
     
     Beantwortet

    Hi

    I found an option in the utility which generates the WCF service with the mainframe which sets the option Session requried to false and also does not add any IsInitiating or IsTerminating attributes to the method. Using this I can sucessfully call the mainframe by simply calling the 'GetAccounts' method.

    Many thanks for your help


    Nigel T

    • Als Antwort markiert NigelT99 Montag, 16. Juli 2012 08:58
    •