I’m not sure WCF being involved is significant or not.
I have a class and method exposed to a client asp.net app. The class looks like
<DataContract()> _
Public Class Class1
Private v_string As String
Private v_integer As Integer
Public Sub New()
v_string = ""
v_integer = -1
End Sub
<DataMember()> _
Public Property P_String() As String
Get
Return v_string
End Get
Set(ByVal value As String)
v_string = value
End Set
End Property
<DataMember()> _
Public Property P_Integer() As Integer
Get
Return v_integer
End Get
Set(ByVal value As Integer)
v_integer = value
End Set
End Property
End Class
The method is declared as
<OperationContract()> _
Function GetStuff(ByVal bar As Class1) As String
In the client code I create an instance of Class1 and set the values for v_string and v_integer, but using Wireshark to look at the xml being sent to the server only a value for v_string is being sent as part of Class1. I’m guessing this is because it considers the value of v_integer to be null/not set. Here is an example of the client code.
Dim MyService as New Service1.ServiceClient
Dim test as New Service1.Class1
test.P_integer = 1
test.P_string = "hello"
Dim result as String = MyService.GetStuff(test)
I’m guessing this is a problem with how different types are passed/used since Integer is a intergral type and String is a class, but can’t seem to work out what to do to fix the problem.
A colleague of mine found that everthing works properly we change the decorations for the data members from:
To:
for all value types. Class types such as string work fine without this.