Integration Web Services

In addition to the Data Integration module and the Integration framework, which allow you to move data around in bulk, we also provide you with a webservice which allows you to add and update products and users indiviually.

The productSync webservice is available at the url:

http://your.website/Admin/public/webservices/productManagement/ProductSync.asmx

In Visual Studio add a new Service reference pointing to the addresse above. Make sure to use Service reference rather than Webservice reference. Below a service reference with name DwSync has been added, and a product is updated with the following code:

string url = "http://mysite.dk/Admin/public/webservices/productManagement/ProductSync.asmx"; string token = "c06abdf84deefdaddfe4a4dd580b82f2"; DwSync.ProductInfo info = new DwSync.ProductInfo { Id = "PROD10", LanguageId = "LANG1", VariantId = "", ShortDescription = "This is an awesome ShortDescription!" }; var webservice = new DwSync.ProductSyncSoapClient("ProductSyncSoap", url); try { webservice.SynchronizeProduct(info, token); Console.WriteLine("Update succeeded"); } catch (Exception ex) { Console.WriteLine("Update failed: " + ex.Message); }

The token is found in the administration under Settings > System > System Information as the Installation checksum.

If the info.ID is not set, a new product will be added to the database, with an auto-generated ID. If the ID, VariantID and LanguageID already exist in the Dynamicweb solution, it will be updated. If the VariantID or LangaugeID are left out, the default product/main product will be updated.

After the product is added/updated, the index is updated.

The UserSync webservice is available at:

http://your.website/Admin/public/webservices/userManagement/UserSync.asmx

The implementation is similar to the one described above for Products, with some small differences:

  • The user must have an ExternalID – this is used when retrieving the user from the Dynamicweb database.
  • By setting the SyncAction on the userInfo object to Delete, it is possible to remove a user from dynamicweb using the service.

Example:

namespace DWUserSync { class Program { private static string token = "b0c4b3d42b57f347069fb6c755e5e6b5"; // Installation checksum private static string address = "http://mysite.dk/Admin/public/webservices/usermanagement/usersync.asmx"; static void Main(string[] args) { UserReference.UserInfo user = new UserReference.UserInfo(); UserReference.ArrayOfString groups = new UserReference.ArrayOfString(); groups.Add("/DK"); // Placed in root groups.Add("/DK/East"); // East being a subgroup to group DK groups.Add("/NO"); //user.Action = UserReference.SyncAction.DELETE; user.Action = UserReference.SyncAction.UPDATE; user.ExternalId = "007"; user.UserName = "James"; user.Password = "Bond"; user.Name = "James Bond"; user.Groups = groups; var webservice = new UserReference.UserSyncSoapClient("UserSyncSoap", address); webservice.SynchronizeUser(user, token); } } }