Welcome Guest ( Login | Register )Home   Search   Today's Posts   Mark All Threads Read

HOWTO: WebService Employee Authentication

Jul 6 2008 11:56pm#1 (permalink)

Simon - Lead Developer

Administrator
Avatar for Simon - Lead Developer
The WORKetc SOAP web service requires you to authenticate before calling any non *WebSafe method. Employees are allowed to call web methods based on their assigned security credentials. For instance, you will invoke a permission error if you try call a finance method from an account which does not have permission to the Finances feature in the application.

To create a session key, you should call AuthenticateWebSafe( .. ). You may then include "VeetroSession: {your key}" as a HTTP cookie or HTTP request header.

If you're using .NET to interop with WORKetc, here's some sample code which demonstrates how to create a session key and use it for subsequent calls.


WORKetc.VeetroWebServiceMethods service = new WORKetc.VeetroWebServiceMethods();
WORKetc.AuthenticateResult res = service.AuthenticateWebSafe("user@domain.com", "password");
if (res.Code == WORKetc.AuthenticateCode.Success)
{
// We have a valid session, add to cookies or http header
service.CookieContainer = new System.Net.CookieContainer();
service.CookieContainer.Add(new System.Net.Cookie("VeetroSession", res.SessionKey, "/", new Uri(service.Url).Host));

// Call some Employee-only method
WORKetc.Entity[] ar = service.GetAllEntities();
System.Diagnostics.Debug.WriteLine(ar.Length);

}
else
{
// login failed
System.Diagnostics.Debug.WriteLine("Login failed with " + res.Message);
}



All times are in GMT-12:00