Single instance???

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sniper

    Single instance???

    Hi guys

    I have facing a small problem, it's like this.

    There is a web service which has a web method call OpenPublicConne ction
    which will open a connection to the SQL Server, and there is a web method
    call StartTransactio n to start a tranaction for the class level connection
    which is opened by the OpenPublicConec tion Method. But when I call
    StartTransactio n it's retruing an error saing the connection is closed... ?
    Is there anyway to fix this?? is there anyway to keep the conneciton object
    alive in the server side till client call the StartTransactio n Method after
    calling the OpenPublicConne ction method...?

    Thanks for your help
    -Aruna
  • erymuzuan

    #2
    Re: Single instance???

    One way is you can utilise ASP.Net Session state framework to achieve
    this. or you can create a singleton remoting object on the server.

    regards
    erymuzuan mustapa

    Sniper wrote:[color=blue]
    > Hi guys
    >
    > I have facing a small problem, it's like this.
    >
    > There is a web service which has a web method call OpenPublicConne ction
    > which will open a connection to the SQL Server, and there is a web method
    > call StartTransactio n to start a tranaction for the class level connection
    > which is opened by the OpenPublicConec tion Method. But when I call
    > StartTransactio n it's retruing an error saing the connection is closed... ?
    > Is there anyway to fix this?? is there anyway to keep the conneciton object
    > alive in the server side till client call the StartTransactio n Method after
    > calling the OpenPublicConne ction method...?
    >
    > Thanks for your help
    > -Aruna[/color]

    Comment

    • Rafal Gwizdala

      #3
      Re: Single instance???

      erymuzuan wrote:[color=blue]
      > One way is you can utilise ASP.Net Session state framework to achieve
      > this. or you can create a singleton remoting object on the server.
      >
      > regards
      > erymuzuan mustapa
      >
      > Sniper wrote:
      >[color=green]
      >> Hi guys
      >>
      >> I have facing a small problem, it's like this.
      >> There is a web service which has a web method call
      >> OpenPublicConne ction which will open a connection to the SQL Server,
      >> and there is a web method call StartTransactio n to start a tranaction
      >> for the class level connection which is opened by the
      >> OpenPublicConec tion Method. But when I call StartTransactio n it's
      >> retruing an error saing the connection is closed... ? Is there anyway
      >> to fix this?? is there anyway to keep the conneciton object alive in
      >> the server side till client call the StartTransactio n Method after
      >> calling the OpenPublicConne ction method...?
      >>
      >> Thanks for your help
      >> -Aruna[/color][/color]

      You could try to solve this problem, but I think the problem is in your
      web service design. You should not leave open database
      connections/transactions between web service calls - this is very
      inefficient and can cause many problems when clients will be making
      concurrent calls to your web service.
      Better think how to make your web service stateless.

      Best regards
      Rafal Gwizdala

      Comment

      • Gilberto

        #4
        Re: Single instance???

        Aruna,
        There is a way to use transactions in a web service. Since it is stateless,
        you must keep track of the user who made the request. You may want to have a
        collection of "ActiveUser s" which is going to have as part of its fields
        userId and connection. Whenever you start a transaction you can return a
        unique Id. You must provide that Id whenever you make another request to the
        web service (Update, Insert, Delete). The web service is going to loop throw
        the collection and find the user with the specified Id. Once the user is
        found, you can grab the connection and pass it to the Update, Insert or
        Delete methods so that the connection doesnt get closed.
        Then you can call the Comit or Rollback.

        Gilberto

        connections/transactions between web service calls - this is very[color=blue]
        > inefficient and can cause many problems when clients will be making
        > concurrent calls to your web service.
        > Better think how to make your web service stateless.[/color]

        "Rafal Gwizdala" wrote:
        [color=blue]
        > erymuzuan wrote:[color=green]
        > > One way is you can utilise ASP.Net Session state framework to achieve
        > > this. or you can create a singleton remoting object on the server.
        > >
        > > regards
        > > erymuzuan mustapa
        > >
        > > Sniper wrote:
        > >[color=darkred]
        > >> Hi guys
        > >>
        > >> I have facing a small problem, it's like this.
        > >> There is a web service which has a web method call
        > >> OpenPublicConne ction which will open a connection to the SQL Server,
        > >> and there is a web method call StartTransactio n to start a tranaction
        > >> for the class level connection which is opened by the
        > >> OpenPublicConec tion Method. But when I call StartTransactio n it's
        > >> retruing an error saing the connection is closed... ? Is there anyway
        > >> to fix this?? is there anyway to keep the conneciton object alive in
        > >> the server side till client call the StartTransactio n Method after
        > >> calling the OpenPublicConne ction method...?
        > >>
        > >> Thanks for your help
        > >> -Aruna[/color][/color]
        >
        > You could try to solve this problem, but I think the problem is in your
        > web service design. You should not leave open database
        > connections/transactions between web service calls - this is very
        > inefficient and can cause many problems when clients will be making
        > concurrent calls to your web service.
        > Better think how to make your web service stateless.
        >
        > Best regards
        > Rafal Gwizdala
        >[/color]

        Comment

        • Gilberto

          #5
          Re: Single instance???

          Aruna,
          There is a way to use transactions in a web service. Since it is stateless,
          you must keep track of the user who made the request. You may want to have a
          collection of "ActiveUser s" which is going to have as part of its fields
          userId and connection. Whenever you start a transaction you can return a
          unique Id. You must provide that Id whenever you make another request to the
          web service (Update, Insert, Delete). The web service is going to loop throw
          the collection and find the user with the specified Id. Once the user is
          found, you can grab the connection and pass it to the Update, Insert or
          Delete methods so that the connection doesnt get closed.
          Then you can call the Comit or Rollback.

          Gilberto

          connections/transactions between web service calls - this is very[color=blue]
          > inefficient and can cause many problems when clients will be making
          > concurrent calls to your web service.
          > Better think how to make your web service stateless.[/color]

          "Rafal Gwizdala" wrote:
          [color=blue]
          > erymuzuan wrote:[color=green]
          > > One way is you can utilise ASP.Net Session state framework to achieve
          > > this. or you can create a singleton remoting object on the server.
          > >
          > > regards
          > > erymuzuan mustapa
          > >
          > > Sniper wrote:
          > >[color=darkred]
          > >> Hi guys
          > >>
          > >> I have facing a small problem, it's like this.
          > >> There is a web service which has a web method call
          > >> OpenPublicConne ction which will open a connection to the SQL Server,
          > >> and there is a web method call StartTransactio n to start a tranaction
          > >> for the class level connection which is opened by the
          > >> OpenPublicConec tion Method. But when I call StartTransactio n it's
          > >> retruing an error saing the connection is closed... ? Is there anyway
          > >> to fix this?? is there anyway to keep the conneciton object alive in
          > >> the server side till client call the StartTransactio n Method after
          > >> calling the OpenPublicConne ction method...?
          > >>
          > >> Thanks for your help
          > >> -Aruna[/color][/color]
          >
          > You could try to solve this problem, but I think the problem is in your
          > web service design. You should not leave open database
          > connections/transactions between web service calls - this is very
          > inefficient and can cause many problems when clients will be making
          > concurrent calls to your web service.
          > Better think how to make your web service stateless.
          >
          > Best regards
          > Rafal Gwizdala
          >[/color]

          Comment

          Working...