C
Chris Dunaway
How can a class be shared between a web service and a client that consumes
the web service?
Suppose I have a Class Libraray with the following simple class:
Public Class SimpleClass
Private _AnInteger As Integer
Public Property AnInteger As Integer
Get
Return _AnInteger
End Get
Set(ByVal Value As Integer)
_AnInteger = Value
End Set
End Property
End Class
This is compiled to a .DLL.
Now, I create a Web Service project and Reference the ClassLibrary and then
add a Web Method as follows:
<WebMethod()> _
Public Sub DoSomething(ByVal sc As SimpleClass)
'Do Something with sc here
End Sub
Finally, I create a Windows Forms Application to consume the web service.
I add the Web Reference to the web service and also Reference the
SimpleClass library and everything looks OK so far, until I try to use
them. Here is an example
Private Sub Button1_Click(...) Handles Button1.Click
'Declare an instance of the web service
Dim ws As New localhost.Service1
'Create an instance of the simple class
Dim sc As New SimpleClass
'Now call the web service method:
ws.DoSomething(sc) '<------- Error here
End Sub
When I try this, it tells me that it cant convert an instance of
SimpleClass to localhost.SimpleClass.
If I change the instantiation of the simple class as follows:
Dim sc As New localhost.SimpleClass
Then it seems to work OK. But my problem is that if SimpleClass in the
ClassLibrary has methods and not just properties, those methods are not
available in the localhost.SimpleClass version, just the properties.
Is it possible to share a ClassLibrary in this manner?
Any assistance would be appreciated.
Chris
the web service?
Suppose I have a Class Libraray with the following simple class:
Public Class SimpleClass
Private _AnInteger As Integer
Public Property AnInteger As Integer
Get
Return _AnInteger
End Get
Set(ByVal Value As Integer)
_AnInteger = Value
End Set
End Property
End Class
This is compiled to a .DLL.
Now, I create a Web Service project and Reference the ClassLibrary and then
add a Web Method as follows:
<WebMethod()> _
Public Sub DoSomething(ByVal sc As SimpleClass)
'Do Something with sc here
End Sub
Finally, I create a Windows Forms Application to consume the web service.
I add the Web Reference to the web service and also Reference the
SimpleClass library and everything looks OK so far, until I try to use
them. Here is an example
Private Sub Button1_Click(...) Handles Button1.Click
'Declare an instance of the web service
Dim ws As New localhost.Service1
'Create an instance of the simple class
Dim sc As New SimpleClass
'Now call the web service method:
ws.DoSomething(sc) '<------- Error here
End Sub
When I try this, it tells me that it cant convert an instance of
SimpleClass to localhost.SimpleClass.
If I change the instantiation of the simple class as follows:
Dim sc As New localhost.SimpleClass
Then it seems to work OK. But my problem is that if SimpleClass in the
ClassLibrary has methods and not just properties, those methods are not
available in the localhost.SimpleClass version, just the properties.
Is it possible to share a ClassLibrary in this manner?
Any assistance would be appreciated.
Chris