Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Null just means null. There's no inherent security issue there.</p> <p>As a web service is a public API, you should be rigorously checking all input data and expect badly-formed input to occur. You can never assume that the client code does the right thing and doesn't send you null either (maliciously or otherwise). </p> <p>So Empty strings or other sentinel values don't save you from checking input, and they don't necessarily make life easier either. Semantically empty strings aren't null either, they're empty.</p> <p>For what it's worth, the xml generated by the .net SoapFormatter for a null is plain old nothing, and that's not the same as an empty string. It's a trivial example, but informative. If you send null you're also sending less data, which may be something to consider.</p> <pre><code>{ [WebMethod] public MyClass HelloWorld() { MyClass val = new MyClass() { IsValid = false, HelloString = "Hello World", BlankString = "", Nested = new NestedClass { Name = "Bob" } }; return val; } } public class MyClass { public bool IsValid { get; set; } public string HelloString { get; set; } public string BlankString { get; set; } public string OtherString { get; set; } public NestedClass Nested { get; set; } public NestedClass NullNested { get; set; } } public class NestedClass { public string Name { get; set; } } </code></pre> <p>yields the following xml response. Note how <code>OtherString</code> and <code>NullNested</code> are missing entirely from the response, which is different to <code>BlankString</code>.</p> <pre><code>&lt;MyClass&gt; &lt;IsValid&gt;false&lt;/IsValid&gt; &lt;HelloString&gt;Hello World&lt;/HelloString&gt; &lt;BlankString /&gt; &lt;Nested&gt; &lt;Name&gt;Bob&lt;/Name&gt; &lt;/Nested&gt; &lt;/MyClass&gt; </code></pre>
 

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