C
Chris Dunaway
Fairly new to web services so bear with me.
I have a simple class library with the following class:
Public Class SimpleClass
Private _AnInteger As Integer
Private _AString As String
Public Property AnInteger() As Integer
Get
Return _AnInteger
End Get
Set(ByVal Value As Integer)
_AnInteger = Value
End Set
End Property
Public Property AString() As String
Get
Return _AString
End Get
Set(ByVal Value As String)
_AString = Value
End Set
End Property
End Class
This is compiled into a .dll
I have a web service that references the .dll with web methods declared
thusly:
<WebMethod()> _
Public Function SomeMethod() As SimpleClass
Dim sc as new SimpleClass
sc.AnInteger = 1
sc.AString = "One"
End Function
<WebMethod()> _
Public Sub AnotherMethod(ByVal sc As SimpleClass)
Dim sc2 as SimpleClass = sc
sc2.AnInteger = 2
sc2.AString = "Two"
End Sub
Nothing too complex about this so far.
Finally I have a Windows Forms Application that consumes the web service.
Dim ws as New localhost.WebService
this windows app also references the SimpleClass class library .dll
What I want to be able to do is something like this:
Dim oMySimpleClassInstance As SimpleClass = ws.SomeMethod()
ws.AnotherMethod(oMySimpleClassInstance)
But I can't do this. I have to declare the object as
localhost.SimpleClass. So if I want to work with a SimpleClass instance
from the class library, I have to use code like this:
Dim oMySimpleClassInstance As New SimpleClass
Dim oWebServiceSimpleClass As localhost.SimpleClass = ws.SomeMethod()
oMySimpleClassInstance.AnInteger = oWebServiceSimpleClass.AnInteger
oMySimpleClassInstance.AString = oWebServiceSimpleClass.AString
And I have to do the opposite when calling the ws.AnotherMethod.
Bottom line, All I want to do is create an object on the client side and
pass that object to the web service without having to manually convert it
back and forth to the proxy class! The classes I intend to use will only
have basic data types (strings, integers, etc). They might have an array
variable, but the array will only hold basic datatypes.
I'm sure there must be something I'm not getting. Do I need to serialize
the object and just pass a byte array to the web service?
Any help is appreciated.
Chris
P.S. Sorry for the long post
I have a simple class library with the following class:
Public Class SimpleClass
Private _AnInteger As Integer
Private _AString As String
Public Property AnInteger() As Integer
Get
Return _AnInteger
End Get
Set(ByVal Value As Integer)
_AnInteger = Value
End Set
End Property
Public Property AString() As String
Get
Return _AString
End Get
Set(ByVal Value As String)
_AString = Value
End Set
End Property
End Class
This is compiled into a .dll
I have a web service that references the .dll with web methods declared
thusly:
<WebMethod()> _
Public Function SomeMethod() As SimpleClass
Dim sc as new SimpleClass
sc.AnInteger = 1
sc.AString = "One"
End Function
<WebMethod()> _
Public Sub AnotherMethod(ByVal sc As SimpleClass)
Dim sc2 as SimpleClass = sc
sc2.AnInteger = 2
sc2.AString = "Two"
End Sub
Nothing too complex about this so far.
Finally I have a Windows Forms Application that consumes the web service.
Dim ws as New localhost.WebService
this windows app also references the SimpleClass class library .dll
What I want to be able to do is something like this:
Dim oMySimpleClassInstance As SimpleClass = ws.SomeMethod()
ws.AnotherMethod(oMySimpleClassInstance)
But I can't do this. I have to declare the object as
localhost.SimpleClass. So if I want to work with a SimpleClass instance
from the class library, I have to use code like this:
Dim oMySimpleClassInstance As New SimpleClass
Dim oWebServiceSimpleClass As localhost.SimpleClass = ws.SomeMethod()
oMySimpleClassInstance.AnInteger = oWebServiceSimpleClass.AnInteger
oMySimpleClassInstance.AString = oWebServiceSimpleClass.AString
And I have to do the opposite when calling the ws.AnotherMethod.
Bottom line, All I want to do is create an object on the client side and
pass that object to the web service without having to manually convert it
back and forth to the proxy class! The classes I intend to use will only
have basic data types (strings, integers, etc). They might have an array
variable, but the array will only hold basic datatypes.
I'm sure there must be something I'm not getting. Do I need to serialize
the object and just pass a byte array to the web service?
Any help is appreciated.
Chris
P.S. Sorry for the long post