Reputation: 10329
Objects of the following class need to be passed as arguments to a WCF web service:
public class Context
{
public static readonly string AUTH_CODE = "AUTH_CODE";
public static readonly string REQUEST_TAG = "REQUEST_TAG";
private readonly IDictionary<string, string> _context = new Dictionary<string, string>();
public void AddProperty(string key, string value)
{
_context.Add(key, value);
}
public string GetProperty(string name)
{
return _context[name];
}
}
I tagged the class with [DataContract] and AUTH_CODE, REQUEST_TAG and _context fields with [DataMember]. The class itself is defined along with the web service on the server side.
When I try to instantiate an object of this class so that I can pass it as parameter while calling the web service from the client, I observe the following:
Can you please explain the above behavior?
Also, I would need access to AddProperty method to populate the object before calling the web service. How do I achieve this?
Note : This is my first experience with WCF. If I am straying off from any standard practices towards achieving such behavior, please advise.
Upvotes: 1
Views: 1116
Reputation: 8937
The behaviour of data contacts is described in the following MSDN link: http://msdn.microsoft.com/en-us/library/ms733127.aspx
Upvotes: 2