VS2008 SOAP Client - losing Session problem [modified]
-
hy, i made a Web Service project in visual studio 2008. then added 2 "Web Service" files to the project. Service1.asmx
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <system.web.script.services.scriptservice()> _
<system.web.services.webservice(namespace:="http://tempuri.org/")> _
<system.web.services.webservicebinding(conformsto:=WsiProfiles.BasicProfile1_1)> _
<toolboxitem(false)> _
Public Class Service1
Inherits System.Web.Services.WebService<webmethod(true)> \_ Public Function HelloWorld() As String Session("foo") = "bar" Return "Hello World" End Function
End Class
Service2.asmx
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <system.web.script.services.scriptservice()> _
<system.web.services.webservice(namespace:="http://tempuri.org/")> _
<system.web.services.webservicebinding(conformsto:=WsiProfiles.BasicProfile1_1)> _
<toolboxitem(false)> _
Public Class Service2
Inherits System.Web.Services.WebService<webmethod(true)> \_ Public Function HelloWorld() As String If Session("foo") <> "bar" Then Throw New UnauthorizedAccessException End If Return "Hello World" End Function
End Class
After i made a windows application, where i made a "Service Reference" to both web service classes/files. The problem is that Service1.asmx doesn't share it's session with Service2.asmx,... I get the thrown "UnauthorizedAccessException" on calling "Service2.HelloWorld()" because the session is not created in Service2.asmx after calling Service2...
Public Class Form1
Private Sub Form1\_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim bhp As New System.ServiceModel.BasicHttpBinding
bhp.AllowCookies = TrueDim x As New ServiceReference1.Service1SoapClient(bhp, New ServiceModel.EndpointAddress("http://localhost/ImsBrowserWebService/Service1.asmx")) Dim y As New ServiceReference2.Service2SoapClient(bhp, New ServiceModel.EndpointAddress("http://localhost/ImsBrowserWebService/Service2.asmx")) MsgBox(x
-
hy, i made a Web Service project in visual studio 2008. then added 2 "Web Service" files to the project. Service1.asmx
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <system.web.script.services.scriptservice()> _
<system.web.services.webservice(namespace:="http://tempuri.org/")> _
<system.web.services.webservicebinding(conformsto:=WsiProfiles.BasicProfile1_1)> _
<toolboxitem(false)> _
Public Class Service1
Inherits System.Web.Services.WebService<webmethod(true)> \_ Public Function HelloWorld() As String Session("foo") = "bar" Return "Hello World" End Function
End Class
Service2.asmx
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <system.web.script.services.scriptservice()> _
<system.web.services.webservice(namespace:="http://tempuri.org/")> _
<system.web.services.webservicebinding(conformsto:=WsiProfiles.BasicProfile1_1)> _
<toolboxitem(false)> _
Public Class Service2
Inherits System.Web.Services.WebService<webmethod(true)> \_ Public Function HelloWorld() As String If Session("foo") <> "bar" Then Throw New UnauthorizedAccessException End If Return "Hello World" End Function
End Class
After i made a windows application, where i made a "Service Reference" to both web service classes/files. The problem is that Service1.asmx doesn't share it's session with Service2.asmx,... I get the thrown "UnauthorizedAccessException" on calling "Service2.HelloWorld()" because the session is not created in Service2.asmx after calling Service2...
Public Class Form1
Private Sub Form1\_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim bhp As New System.ServiceModel.BasicHttpBinding
bhp.AllowCookies = TrueDim x As New ServiceReference1.Service1SoapClient(bhp, New ServiceModel.EndpointAddress("http://localhost/ImsBrowserWebService/Service1.asmx")) Dim y As New ServiceReference2.Service2SoapClient(bhp, New ServiceModel.EndpointAddress("http://localhost/ImsBrowserWebService/Service2.asmx")) MsgBox(x