Hello,
I have the following web service
----------
Imports System.Web.Services
Imports System
Imports System.IO
Imports System.Runtime.Serialization.Formatters
Imports System.Runtime.Serialization.Formatters.Binary
Imports System.Runtime.Serialization.Formatters.Soap
<System.Web.Services.WebService
(Namespace := "http://tempuri.org/serv_serial/Service1")> _
Public Class Service1
Inherits System.Web.Services.WebService
<Serializable()> Class Employee
Public Name As String
Public Address As String
Public Salary As Double
End Class
<WebMethod()> _
Public Function Serialize(ByVal obj As Object) As Stream
Dim fs As FileStream = New _
FileStream("c:\\vbdata.xml", FileMode.OpenOrCreate,
FileAccess.ReadWrite, FileShare.ReadWrite)
Dim sFmt As SoapFormatter = New SoapFormatter
sFmt.Serialize(fs, obj)
Return fs
End Function
<WebMethod()> _
Public Function Deserialize(ByVal s As Stream) As Object
Dim fs As SoapFormatter = New SoapFormatter
s.Position = 0
Return fs.Deserialize(s)
End Function
<WebMethod()> _
Public Function GetEmployeeInfo() As Stream
Dim emp As Employee = New Employee
emp.Name = "Tim"
emp.Address = " First Street, Country "
emp.Salary = 10000.0
Dim s As FileStream = Serialize(emp)
Return s
End Function
End Class
-----------
I call this web service in the following manner
Imports System
Imports System.IO
Imports System.Runtime.Serialization.Formatters
Imports System.Runtime.Serialization.Formatters.Binary
Imports System.Runtime.Serialization.Formatters.Soap
Public Class WebForm1
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Put user code to initialize the page here
Dim x As New service_employee.Service1
Dim s As service_employee.Stream = x.GetEmployeeInfo()
Dim y As Object = x.Deserialize(s)
Response.Write(y.Name & "<BR>")
Response.Write(y.Address & "<BR>")
Response.Write(y.Salary & "<BR>")
End Sub
End Class
------
but for some reason, it is blowing up after GetEmployeeInfo is done.
Do you know why this is happening?
Thank you,
Burak
I have the following web service
----------
Imports System.Web.Services
Imports System
Imports System.IO
Imports System.Runtime.Serialization.Formatters
Imports System.Runtime.Serialization.Formatters.Binary
Imports System.Runtime.Serialization.Formatters.Soap
<System.Web.Services.WebService
(Namespace := "http://tempuri.org/serv_serial/Service1")> _
Public Class Service1
Inherits System.Web.Services.WebService
<Serializable()> Class Employee
Public Name As String
Public Address As String
Public Salary As Double
End Class
<WebMethod()> _
Public Function Serialize(ByVal obj As Object) As Stream
Dim fs As FileStream = New _
FileStream("c:\\vbdata.xml", FileMode.OpenOrCreate,
FileAccess.ReadWrite, FileShare.ReadWrite)
Dim sFmt As SoapFormatter = New SoapFormatter
sFmt.Serialize(fs, obj)
Return fs
End Function
<WebMethod()> _
Public Function Deserialize(ByVal s As Stream) As Object
Dim fs As SoapFormatter = New SoapFormatter
s.Position = 0
Return fs.Deserialize(s)
End Function
<WebMethod()> _
Public Function GetEmployeeInfo() As Stream
Dim emp As Employee = New Employee
emp.Name = "Tim"
emp.Address = " First Street, Country "
emp.Salary = 10000.0
Dim s As FileStream = Serialize(emp)
Return s
End Function
End Class
-----------
I call this web service in the following manner
Imports System
Imports System.IO
Imports System.Runtime.Serialization.Formatters
Imports System.Runtime.Serialization.Formatters.Binary
Imports System.Runtime.Serialization.Formatters.Soap
Public Class WebForm1
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Put user code to initialize the page here
Dim x As New service_employee.Service1
Dim s As service_employee.Stream = x.GetEmployeeInfo()
Dim y As Object = x.Deserialize(s)
Response.Write(y.Name & "<BR>")
Response.Write(y.Address & "<BR>")
Response.Write(y.Salary & "<BR>")
End Sub
End Class
------
but for some reason, it is blowing up after GetEmployeeInfo is done.
Do you know why this is happening?
Thank you,
Burak