<p>I'm hosting my first WCF service in IIS. I have two methods, 1 to set a string variable on the WCF Service, and the other to retrieve it. The interface used is:</p>

<pre><code>[OperationContract]
string ReturnText();

[OperationContract]
void SetText(string s);
</code></pre>

<p>BasicHttpBinding is used. Stepping through the service with the debugger from the client reveals that the value of the string is set correctly using SetText, but when I immediately do a return text, the string is back to null.</p>

<p>Probably a simple one I know, but I thought that all values on the WCF service were retained between opening the service connection and closing it.</p>

<p>Why is the value lost between the Set and Gets?</p>

By default things are session-less and instances are per-call.  See
http://msdn.microsoft.com/en-us/library/ms731193.aspx
for some starter information, but in order to have state across the calls, you'll either need a PerSession or Single instancing mode on the server, and in the former case, configure the binding to support sessions (so that the two calls can be correlated as a result of being a part of the same session connection).