By default, WCF will create a new instance of your service to serve each call ( PerCall instancing ), so your property sets will not be remembered.
You need to transfer your security data using a service call StockQuery.
[OperationContract]
bool StockQuery(string partNo,String userName,String password);
public bool StockQuery(string partNo,String userName,String password)
{
this.CheckSecurity(userName,password);
if(partNo == "123456")
{
return true;
}
return false;
}
You can get away from this approach using PerSession instancing , where the same instance will be used to serve each client.
[ServiceContract(SessionMode = SessionMode.Required)]
public interface IMyAPI
{
...
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
public class MyAPI : IMyAPI
{
...
}
, , WCF.