Reputation: 5419
Test
public string username { get; set; }
public void Test(string test)
{
this.username = test;
}
public string Get()
{
return this.username
}
ITest
[OperationContract]
public string Get();
[OperationContract]
public void Test(string test);
TestProject
var webapi3 = new v3.TestClient("BasicHttpBinding_IProductData1");
webapi3.Test("TestString");
var u = webapi3.Get();
Problem
Why does u
remain empty, no mather what I try?
Upvotes: 0
Views: 127
Reputation: 1657
I assume
public void Test(string test)
{
this.username = username;
}
Should be:
public void Test(string test)
{
this.username = test;
}
Upvotes: 0
Reputation: 2919
public void Test(string test)
{
this.username = test; // test not username?
}
Upvotes: 4
Reputation: 67326
The second call Get()
will be potentially picked up on another thread. You would need to make username
static if you want state on the server.
You are communicating over HTTP, a stateless protocol.
There are other options than to make the field static, but this would at least get the test passing.
Upvotes: 0