How do I integrate with the XML webservice?2013 WORKetc Pty Ltdhttp://admin.worketc.com/Community/Forums?Topic=136Mon, 03 Aug 2009 05:44:45WORKetc forums feedworketc.comHi, A little bit more on web http://admin.worketc.com/Community/Forums?Message=2236Hi, A little bit more on web service permissions. The web service will will take your browser cookie that you used to log in originally. The functions are all locked down in exactly the same method as seen from within the main website application itself. This means if you don't have, for example, the Sales or Finance credential.. GetInvoice() and SetInvoice etc will fail if you attempt to run them. Similarly if you're logged in with a low-privilege CUSTOMER account, probably 95% of the web service methods will reject your attempt to use them, or will error you out if the data does not explicitly relate to your profile in some way. (A customer can't view details of a different customer's support ticket or project, for example... the web service will throw a security exception.) If you have any other questions, let us know! Kind Regards, Geoff Customer Support Tue, 25 Jan 2011 02:59:222236GeoffEvery WORKetc account has it'shttp://admin.worketc.com/Community/Forums?Message=313Every WORKetc account has it's own private SOAP/XML web service. Your webservice end-point is located at [b]https://[i]yourdomain[/i].worketc.com/Xml[/b]. This page lists all web methods available -- basically *everything* that WORKetc is capable of. Most methods are locked-down for obvious security reasons, so you need to authenticate and provide the session ticket during operations. Here is a quick run-down on how you can easily leverage Veetro in your .NET Winforms/Web applications. [b]1) Enable remote webservice access in WORKetc[/b] WORKetc’s web service comes locked down by default. Simply navigate to Settings -> Security, and enter an IP address/range for which you wish to enable access. [b]2) Create a new Visual Studio project[/b] Open up Visual Studio 2003 or later and create a new Project. For the sake of this tutorial I am just going to create a basic Windows Form. [b]3) Add your web reference[/b] In your solution explorer, right-click your Project and select "add web reference … " In the Add Web Reference dialog, simply enter youraccount.worketc.com/Xml. If desired you can enter a more friendly web reference name such as “WORKetc”. Press Add Reference. [b]4) Write some code...[/b] [i][b]About Permissions[/b][/i] 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. [code]WORKetc.VeetroWebServiceMethods service = new WORKetc.VeetroWebServiceMethods(); // Ensure the service URL is correct, use your account! service.Url = "http://youraccountdomain/Xml"; 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); }[/code] [i][b]Basic Example[/b][/i] Now that you have the entire platform at your command, let’s create a new person in our Address Book. Here is some simple code to create a new contact: [code]void AddPerson() { // Instantiate the webservice WORKetc.VeetroWebServiceMethods service = new WORKetc.VeetroWebServiceMethods(); // Ensure the service URL is correct, use your account! service.Url = "http://youraccountdomain/Xml"; WORKetc.AuthenticateResult res = service.AuthenticateWebSafe("user@domain.com", "password"); if (res.Code != WORKetc.AuthenticateCode.Success) { // Login has failed here.. MessageBox.Show("Login failed with " + res.Message); return; } // 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)); /// // Create a new person object // Person p = new Person(); p.EntityID = 0; // EntityID zero will tell the service, this is a new contact. p.FirstName = "John"; p.Surname = "Doe"; p.Email = "john@doe.com"; // Create an address Veetro.Address a = new Veetro.Address(); a.Country = "Canada"; a.Phone = "902 555 0000"; a.PostalCode = "B0J 3C0"; a.StateOrProv = "NS"; a.Street = "Some Street"; a.Suburb = "Sherbrooke"; p.Addresses = new Veetro.Address[] { a }; // Save the person. SetPerson will return the object again // except it will be populated with it's new unique EntityID. try { p = service.SetPerson(p); MessageBox.Show("New Person created with ID " + p.EntityID + "."); } catch (Exception x) { MessageBox.Show("Create person failed with " + x.Message); } }[/code] If we invoke our AddPerson() method above, we should get a the full Person object returned from the web service, complete with our unique "EntityID". [b]Hint:[/b] All web service methods in WORKetc allow you to create a new object by supplying zero (0) as the Unique Identifier. This instructs WORKetc to make a fresh record, and since all SetXXXXX() web methods return the saved object, you immediately gain a reference to the object's Unique Identifier(s). Mon, 03 Aug 2009 05:44:45313Simon