Note that there are some explanatory texts on larger screens.

plurals
  1. POASMX webservice doesn't return any result
    text
    copied!<p>I'm trying to send an object of a custom class through my asmx webservice running on .net 4.0, but all i get is an empty response. See below:</p> <pre><code>&lt;soap:Body&gt; &lt;ActivateResponse xmlns="http://tempuri.org/"&gt; &lt;ActivateResult /&gt; &lt;!-- why is this empty --&gt; &lt;/ActivateResponse&gt; &lt;/soap:Body&gt; </code></pre> <p>However, if i modify my method and change the return type for example from class <em>A</em> to <em>B</em>, then it returns all the properties of object <em>B</em> correctly. See below:</p> <pre><code>&lt;ActivateResponse xmlns="http://tempuri.org/"&gt; &lt;ActivateResult&gt; &lt;BtAddress&gt;string&lt;/BtAddress&gt; &lt;Name&gt;string&lt;/Name&gt; &lt;Number&gt;string&lt;/Number&gt; &lt;/ActivateResult&gt; &lt;/ActivateResponse&gt; </code></pre> <p>I'm wondering why its happening? I could blame to improper <strong>Serialization</strong> of class <em>A</em> but there's nothing fancy I'm involving in my class files. Both class files are almost similar in terms of contents and does not contain any Serialize attribute.</p> <p>So, why does the webservice return one type, but not the other?</p> <hr> <p><strong>Class A</strong>:</p> <pre><code>public class A { private string code; private bool isValid; private int maxUniqueActivations; private DateTime dateAdded; private Customer customer = null; private bool _initAsEmpty = false; public License() { _initAsEmpty = true; } public string LicenseCode { get { return code; } //set { code = String.IsNullOrWhiteSpace(value)? null : value.Trim(); } } //If i change return type to Customer, it works too //so i dont think it should be blamed public Customer Customer { get { return customer; } } public bool IsValid { get { return isValid; } } public int MaxUniqueActivations { get { return maxUniqueActivations; } } public DateTime DateAdded { get { return dateAdded; } } } </code></pre> <p><strong>Class B</strong>:</p> <pre><code>public class Phone { private string btAddress, name, number; private bool isValid; private DateTime dateAdded; private bool _initAsEmtpy = false; public Phone() { _initAsEmtpy = true; } public string BtAddress { get { return btAddress; } set { btAddress = string.IsNullOrWhiteSpace(value) ? null : value.Replace(":", "").Trim(); } } public string Name { get { return name; } set { name = string.IsNullOrWhiteSpace(value) ? null : value.Trim(); } } public string Number { get { return number; } set { number = string.IsNullOrWhiteSpace(value) ? null : value.Trim(); } } public bool IsValid { get { return isValid; } } public DateTime DateAdded { get { return dateAdded; } } } </code></pre> <p><em>some methods are suppressed</em></p>
 

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