I have a client wherein I pass in the username, password through network credentials. What I want to do is to pass these two parameters to the service itself for authentication purposes: Example shown below:
Client:
HttpClient client = new HttpClient("http://localhost:8080/ProductService/");
client.TransportSettings.Credentials =
new System.Net.NetworkCredential("admin", "admin");
using (HttpResponseMessage response = client.Get("getproducts"))
{
DataSet dst = new DataSet();
dst.ReadXml(response.Content.ReadAsStream(), XmlReadMode.ReadSchema);
return;
}
Service/Server Side:
[OperationContract]
[WebGet(UriTemplate = "getproducts", ResponseFormat = WebMessageFormat.Xml,
RequestFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped)]
public DataSet GetProducts()
{
//how can I extract the credentials i passed in the client side?
}
This explains what I want to get done. Hope you all understand what I mean to say.