none
WCF PerCall Session RRS feed

  • Question

  • Hi !

    I am using

    • Visual Studio 2017
    • XamarinForms ( For Simple Android Application )
    • WCF
    • PCL (Portable Class Library)

    Application purpose is Database Routines, Get Data, Update Data (user can select from a login screen which database wants to use) e.g DB1,DB2,DB3, etc... (they are all same schema on the same server)

    Problem:

    Due to the bad luck of compatibility the PCL dose not support / allow me to use WCF PerSession with WsHttpBinding (i was needed that to store some variable like connectionString  or CurrentUser Information on which database the user was about to login and when requests arrived served for that ConnectionString)

    if i am wrong about the above statement please let me know.

    Now i have 2 options Single Session & PerCall Session i believe the most suitable for me now is the PerCall  Session

    BUT

    i realized PerCall And Single Sessions dose not allow me to implement this architecture that initially thought. (storing session variables like connectionString, CurrentUserLoggedIn  )

    So by accepting the option PerCall Session i need to send on every call some extra parameters to the method ( The DatabaseConnectionString and CurrentUserLogin) so when updating data or getting data to know which database the service will find.

    i want to ask before proceeding to any changes to my WCF Service 

    1. Is there any other way to NOT passing the parameters to every call ? remember am using PerCall session..
    2. if i still go with option PerCall do i have to think any concurrency issues? if 100 clients request a method normally this is not an issue since every call will create a new instance (just to clear my thoughts)
    3. I guess Single Service is not an option in my case( am i correct )?or you believe is better going with single service?

    Please suggest me ( i have 5 days now searching / testing just to realized that WCF PerSession is not compatible with PCL ) 

    Thanks 


    stelios ----------











    • Edited by stelios84 Friday, January 26, 2018 11:03 AM
    Thursday, January 25, 2018 12:59 PM

Answers

  • Hi Stelios,

    >> ow Since  wsHttpBinding is not supported in PCL How can i use a session variables if my only option is to use PerCall or Single Session ?

    I am afraid your requirement is impossible, and this is limited by combining WCF and PCL.

    As you have known, wsHttpBinding is not supported in PCL, and the current supported binding is basicHttpBinding.

    But as this System-Provided Bindings indicates, BasicHttpBinding does not support Session.

    In a consolation, you could not achieve session in WCF under PCL.

    Best Regards,

     Tao Zhou


    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.

    • Marked as answer by stelios84 Tuesday, January 30, 2018 9:35 AM
    Monday, January 29, 2018 3:05 AM

All replies

  • Hi Stelios,

    >> Due to the bad luck of compatibility the PCL dose not support / allow me to use WCF PerSession

    How did you use PCL with WCF? WCF PerSession is configured at service side, I am not sure what you mean by it is not support.

    >> i was needed that to store some variable like connectionString  or CurrentUser Information on which database the user was about to login and when requests arrived served for that ConnectionString

    How did you store them? Did you store them in session? Do you need to access the variable in next requests?

    >> Is there any other way to NOT passing the parameters to every call ?

    What do you mean by passing parameters? Whether passing parameter depends on whether the method in service require parameters.

    Best Regards,

    Tao Zhou


    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.

    Friday, January 26, 2018 6:20 AM
  • Hi Tao

    How did you use PCL with WCF? WCF PerSession is configured at service side, I am not sure what you mean by it is not support

    WCF By default is using  PerSession as i also read it somewhere but this will be skipped (as it seems) if not configure correctly like i did. For example my EndPoint in WCF App.Config was point to a basicHttpBinding

    I read that basicHttpBinding dose not support PerSessions  so i create a wsHttpBinding which support PerSession and point my binding then to wsHttpBinding.

    an example of image how wsHttpBinding is this

    My Next steps was

    1. Test the WCF service independently  if is working the PerSession with wsHttpBinding  as expected before referencing to my PCL and was work as expected 
    2. Now i right click on a PCL as i did previously when it was basicHttpBinding but now with wsHttpBinding  but this time the Visual Studio giving me a warning that wsHttpBinding is not supported in Portable Class Library as also i read this officially 

    see the warnings in this image

    The 3rd warning seems that After referencing the service to the pcl  expecting to configure an enum of 

    EndPointConfugration like this image ( that did not asked when it was basicHttpBinding)


    As for question 3 what i mean by passing parameters

    I mean that i didn't want to send a ConnectionString Parameter to every method i call. I wanted to store the connectionString of the selected database to a session variable for that client.

    At the same time when another Client login and select a different Database then a new session along with  connectionString parameter will be stored to his session and use that for requests 


    So in other words : the wsHttpBinding is not supported in Portable Class Libray.

    Question

    Now Since  wsHttpBinding is not supported in PCL How can i use a session variables if my only option is to use PerCall or Single Session ?

    Sorry for any bad explanation i am very new to WCF and services so please show mercy :)

    stelios ----------









    • Edited by stelios84 Friday, January 26, 2018 12:30 PM
    Friday, January 26, 2018 8:11 AM
  • Hi Stelios,

    >> ow Since  wsHttpBinding is not supported in PCL How can i use a session variables if my only option is to use PerCall or Single Session ?

    I am afraid your requirement is impossible, and this is limited by combining WCF and PCL.

    As you have known, wsHttpBinding is not supported in PCL, and the current supported binding is basicHttpBinding.

    But as this System-Provided Bindings indicates, BasicHttpBinding does not support Session.

    In a consolation, you could not achieve session in WCF under PCL.

    Best Regards,

     Tao Zhou


    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.

    • Marked as answer by stelios84 Tuesday, January 30, 2018 9:35 AM
    Monday, January 29, 2018 3:05 AM
  • Tao, 

    Is there any way to know for each call arrive on the server which client is calling it?

    For example

    On the Server

    Function GetCustomerList
    
    // is there any way here to know which client is calling this function?
    
    End Function



    stelios ----------



    • Edited by stelios84 Monday, January 29, 2018 1:13 PM
    Monday, January 29, 2018 1:11 PM
  • Hi Stelios,

    >> Is there any way to know for each call arrive on the server which client is calling it?

    For this requirement, I think you could try to add SOAP Header which could indicate the client at client side, and then check the SOAP Header at Service side.

    Since this issue is different from original issue, if you have any issue to achieve this, I would suggest you post a new thread. And for this issue, I would suggest you mark the helpful reply as answer to close current thread since it is impossible to use Session with basicBinding under PC.

    Best Regards,

    Tao Zhou


    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.

    Tuesday, January 30, 2018 2:30 AM