Table of Contents [Hide/Show]
Web Service Reference Custom settingsSample codeReferences
int PageSize = 100; String username = "testuser"; String password = "0123456789"; cwcmanagementsvc.ManagementService_Service service = new ManagementService_Service(); int currentPage = 0; ManagementService port = service.getBasicHttpBindingManagementService(); // All methods return with a result code. Zero means succes, negative // means server error and positive is a client error. Holder result = new Holder(); // First retrieve the available customers for this user account and // lets just use the first for all following methods. Holder customers = new Holder(); port.customerList( username, password, currentPage, PageSize, result, customers); if(result.value!=0) throw new Exception("Could not retrieve customer list. Reason: " + result.value); if(customers.value.getCustomerSummary().isEmpty()) throw new Exception("No customers."); System.out.println("Available customers:"); for(int i=0;i String customerId = customers.value.getCustomerSummary().get(0).getId(); // Now lets retrieve the available webcast profiles for this customers // and select the first profile. Holder profiles = new Holder(); port.profileList( username, password, customerId, result, profiles); if(result.value!=0) throw new Exception("Could not retrieve profile list. Reason: " + result.value); if(profiles.value.getProfile().isEmpty()) throw new Exception("No profiles."); System.out.println("Available profiles:"); for(int i=0;i String profileId = profiles.value.getProfile().get(1).getId(); // Here we are going to create a webcast for a specific customer with // a specific profile. This will create a webcast that we can later // retrieve to extend with additional data. Holder webcastCode = new Holder(); GregorianCalendar plannedStartUtc; plannedStartUtc = new GregorianCalendar(2011, 1, 1, 13, 5 ); // javax.xml.datatype XMLGregorianCalendar xmlPlannedStartUtc = DatatypeFactory.newInstance().newXMLGregorianCalendar( plannedStartUtc ); port.webcastCreate( username, password, customerId, profileId, xmlPlannedStartUtc, result, webcastCode); if(result.value!=0) throw new Exception("Could not create webcast. Reason: " + result.value ); System.out.format("Webcast created succesfully (code: %s)\r\n", webcastCode.value); // We are going to just retrieve the webcast with the key that we got on // the create method. Holder webcast = new Holder(); port.webcastGet( username, password, webcastCode.value, result, webcast); if(result.value!=0) throw new Exception("Could not retrieve webcast data. Reason: " + result.value); System.out.format("Webcast %s retrieved succesfully.\r\n", webcastCode.value); // A webcast can have localized literals. For example if a webcast is // in Dutch and English the topics need to be specified in two languages. // The available languages can be determined via the LanguageCodes property. java.util.List codes = webcast.value.getLanguageCodes().getString(); if(codes.size()!=1) throw new Exception("Only one language is supported in this sample."); if(!codes.get(0).equalsIgnoreCase("nl")) throw new Exception("Only Dutch is supported in this sample."); int dutchIndex = 0; // The system works with optimistic concurrency control. We use this so // that modifications done by another user or process or the system // itself will not result in data loss. The value that is used to compare // versions is held in the webcastRevision argument. // // Here we are just going to save the webcast data that we previously // retrieved from the system. We just change the webcast title and the // reference. String webcastTitle = "Ramon " + webcast.value.getCode(); webcast.value.getLocalization().getWebcastData().get(dutchIndex).setTitle(webcastTitle); webcast.value.setReference(webcastTitle); Holder webcastRevision = new Holder(); port.webcastSave( username, password, webcast.value, result, webcastRevision); if(result.value!=0) throw new Exception("Could not save webcast after creation. Reason: " + result.value); System.out.println("Webcast with changed title saved succesfully."); webcast.value.setRevision(webcastRevision.value); // Now we are going to change the webcast data. Here we are going to // add an additional topic. TopicsModule tm = webcast.value.getTopicsModule(); Topic topic = new Topic(); topic.setTitle("A nice topic"); topic.setDescription("This topic is as nice as it can possibly be."); tm.getTopics().getTopics().get(dutchIndex).getTopic().add(topic); // Now save the modified webcast data. port.webcastSave( username, password, webcast.value, result, webcastRevision); if(result.value!=0) throw new Exception("Could not save webcast after previous save. Reason: " + result.value); System.out.println("Webcast with added topic saved succesfully."); // When we want to delete a webcast we also need the revision code as // this is also a modification. It could be that something or someone // else has modified the data so that would first require an update of // the data and check if a delete would still be appropriate. result.value = port.webcastDelete( username, password, webcastCode.value, webcastRevision.value); if(result.value!=0) throw new Exception("Could not delete webcast. Reason: " + result.value); System.out.println("Webcast deleted succesfully.");