/** * Reserve a number Item and Revision Ids * * @param numberOfIds Number of IDs to generate * @param type Type of IDs to generate * * @return An array of Item and Revision IDs. The size of the array is equal * to the input numberOfIds * * @throws ServiceException If any partial errors are returned */ public ItemIdsAndInitialRevisionIds[] generateItemIds(int numberOfIds, String type) // throws ServiceException { // Get the service stub DataManagementService dmService = DataManagementService.getService(MyFormAppSession.getConnection()); GenerateItemIdsAndInitialRevisionIdsProperties[] properties = new GenerateItemIdsAndInitialRevisionIdsProperties[1]; GenerateItemIdsAndInitialRevisionIdsProperties property = new GenerateItemIdsAndInitialRevisionIdsProperties(); property.Count = numberOfIds; property.ItemType = type; property.Item = null; // Not used properties[0] = property; // ***************************** // Execute the service operation // ***************************** GenerateItemIdsAndInitialRevisionIdsResponse response = dmService.GenerateItemIdsAndInitialRevisionIds(properties); // The AppXPartialErrorListener is logging the partial errors returned // In this simple example if any partial errors occur we will throw a // ServiceException if (response.ServiceData.sizeOfPartialErrors() > 0) { throw new ServiceException("DataManagementService.generateItemIdsAndInitialRevisionIds returned a partial error."); } // The return is a map of ItemIdsAndInitialRevisionIds keyed on the // 0-based index of requested IDs. Since we only asked for IDs for one // data type, the map key is '0' Int32 bIkey = 0; Hashtable allNewIds = response.OutputItemIdsAndInitialRevisionIds; ItemIdsAndInitialRevisionIds[] myNewIds = (ItemIdsAndInitialRevisionIds[])allNewIds[bIkey]; return(myNewIds); }