AndyTheAce
October 11th, 2006, 03:40 AM
Hi Folks -
I'm trying to use a Webservice as "interface" for a an oracle database.
So my goal is, that all users on my website share the database connection
and are always up to date by receiving data from this webservice.
But this doesn't work at all, I'm not able to setup the proxy instances
correctly it seems.. every visitor of my page receives its own instance of my webservice.. thatfor I created a little example webservice & application with just a button and a counter.
My goal is, that the counter in my Webservice has the same value for each client!
If for example client a increases the counter by clicking a button, client b should start with that increased value on visiting the asp application site.
---------------Code from the calling application----------------
Protected Sub Increase_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ret As Integer
If Session("myCookie") Is Nothing Then
Dim Cookies As New System.Net.CookieContainer
Session("myCookie") = Cookies
End If
If Session("wsTest") Is Nothing Then
Dim proxy As New wsTestPage.wsTestPage
proxy.CookieContainer = Session("myCookie")
Session("wsTest") = proxy
End If
' Cookiecontainer für Proxy festlegen
ret = Session("wsTest").TestWebService()
Label1.Text = "Result: " & CStr(ret)
End Sub
---------------Code from the WebService----------------
<WebMethod(EnableSession:=True)> _
Public Function TestWebService() As Integer
If Context.Session("Counter") Is Nothing Then
Context.Session("Counter") = 1
Return (Context.Session("Counter"))
Else
Context.Session("Counter") += 1
Return (Context.Session("Counter"))
End If
End Function
Is it actually possible to do what I want with a WebService?
If so, what am I doing wrong here?
Thanks in Advance,
Regards,
Andy
I'm trying to use a Webservice as "interface" for a an oracle database.
So my goal is, that all users on my website share the database connection
and are always up to date by receiving data from this webservice.
But this doesn't work at all, I'm not able to setup the proxy instances
correctly it seems.. every visitor of my page receives its own instance of my webservice.. thatfor I created a little example webservice & application with just a button and a counter.
My goal is, that the counter in my Webservice has the same value for each client!
If for example client a increases the counter by clicking a button, client b should start with that increased value on visiting the asp application site.
---------------Code from the calling application----------------
Protected Sub Increase_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ret As Integer
If Session("myCookie") Is Nothing Then
Dim Cookies As New System.Net.CookieContainer
Session("myCookie") = Cookies
End If
If Session("wsTest") Is Nothing Then
Dim proxy As New wsTestPage.wsTestPage
proxy.CookieContainer = Session("myCookie")
Session("wsTest") = proxy
End If
' Cookiecontainer für Proxy festlegen
ret = Session("wsTest").TestWebService()
Label1.Text = "Result: " & CStr(ret)
End Sub
---------------Code from the WebService----------------
<WebMethod(EnableSession:=True)> _
Public Function TestWebService() As Integer
If Context.Session("Counter") Is Nothing Then
Context.Session("Counter") = 1
Return (Context.Session("Counter"))
Else
Context.Session("Counter") += 1
Return (Context.Session("Counter"))
End If
End Function
Is it actually possible to do what I want with a WebService?
If so, what am I doing wrong here?
Thanks in Advance,
Regards,
Andy