Note that there are some explanatory texts on larger screens.

plurals
  1. POWhen passing an object as an argument to a method, string properties are populated, but integers are null
    primarykey
    data
    text
    <p>I'm not sure WCF being involved is significant or not.</p> <p>I have a class and method exposed to a client asp.net app. The class looks like</p> <pre><code>&lt;DataContract()&gt; _ Public Class Class1 Private v_string As String Private v_integer As Integer Public Sub New() v_string = "" v_integer = -1 End Sub &lt;DataMember()&gt; _ Public Property P_String() As String Get Return v_string End Get Set(ByVal value As String) v_string = value End Set End Property &lt;DataMember()&gt; _ 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 </code></pre> <p>The method is declared as</p> <pre><code>&lt;OperationContract()&gt; _ Function GetStuff(ByVal bar As Class1) As String </code></pre> <p>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.</p> <pre><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) </code></pre> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload