AirWatch SOAP API Guide v9 - 1
AirWatch SOAP API Guide v9 - 1
Have documentation feedback? Submit a Documentation Feedback support ticket using the Support Wizard on
support.air-watch.com.
Copyright © 2017 VMware, Inc. All rights reserved. This product is protected by copyright and intellectual property laws in the United States and other countries as well as by
international treaties. VMware products are covered by one or more patents listed at http://www.vmware.com/go/patents.
VMware is a registered trademark or trademark of VMware, Inc. in the United States and other jurisdictions. All other marks and names mentioned herein may be trademarks of their
respective companies.
1
Revision Table
The following table displays revisions to this guide since the release of AirWatch v8.4 and above.
Date Reason
April 2017 Initial upload. Document posted for AirWatch v9.1 GA.
2
Table of Contents
Chapter 1: Overview 6
Introduction 7
Important API Considerations 7
Creating a Request 8
3
GetDeviceSummaryByOwnership 107
GetDeviceSummaryByPlatform 107
4
LoadLocationStatusList 192
LoadAddressTypeList 194
LoadCountryList 197
LoadDeviceCategoryList 200
LoadOwnershipList 202
5
Chapter 1:
Overview
Introduction 7
Important API Considerations 7
Creating a Request 8
6
Chapter 1: Overview
Introduction
AirWatch Web Services is a collection of interfaces that allow external programs to invoke the core product functionality.
This can be used to integrate with existing IT infrastructure and third party applications.
This guide is targeted at developers who are building applications that uses these services for providing device
management capabilities. It describes the available Application Programming Interfaces (API) and potential integration
challenges.
Use of this guide assumes familiarity with the following:
l A basic understanding of web services.
l A programming language for consuming a web service and any related tools.
Note: The API references in this document align with the AirWatch Services offerings in AirWatch version 6.5.
Data Object
7
Chapter 1: Overview
Creating a Request
Making a request involves creating a request proxy for the correct endpoint and initializing authentication credentials.
AirWatch Web Services use client certificate authentication. Clients must present a valid and recognized certificate as a
part of the SSL handshake.
For a .net client, this information goes into the application configuration file.
8
Chapter 1: Overview
9
Chapter 1: Overview
import javax.net.ssl.SSLContext;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.log4j.BasicConfigurator;
import services.com.air_watch.www.EnrollmentServiceEndpointStub;
import org.apache.commons.httpclient.protocol.Protocol;
import org.jsslutils.sslcontext.X509SSLContextFactory;
// End Point
EndpointReference targetEndPoint = new EndpointReference (endPointURI);
// Key store
KeyStore keyStore = KeyStore.getInstance("JKS");
InputStream keyInput = new FileInputStream(testProps.getProperty
("javax.net.ssl.keyStore"));
keyStore.load(keyInput, "XX-PASSWORD".toCharArray());
keyInput.close();
// Trust Store
KeyStore trustStore = KeyStore.getInstance("JKS");
keyInput = new FileInputStream(testProps.getProperty
("javax.net.ssl.trustStore"));
trustStore.load(keyInput, "XX-PASSWORD".toCharArray());
keyInput.close();
// SSL Context
X509SSLContextFactory sslContextFactory = new X509SSLContextFactory(keyStore,
" XX-PASSWORD", trustStore);
SSLContext sslClientContext = sslContextFactory.buildSSLContext();
Protocol myProtocolHandler = new Protocol("https", new
SslContextedSecureProtocolSocketFactory(sslClientContext, false), 443);
// Request Proxy
PicklistServiceEndpointStub stub = new
PicklistServiceEndpointStub();
stub._getServiceClient().engageModule("addressing");
// Create the request. Disable Chunked Transfer stub._getServiceClient
().getOptions().setProperty(
org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
stub._getServiceClient().getOptions().setProperty(
org.apache.axis2.transport.http.HTTPConstants.CUSTOM_PROTOCOL_HANDLER,
myProtocolHandler);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
PicklistServiceEndpointStub.LoadOwnershipList ownershipList =
new PicklistServiceEndpointStub.LoadOwnershipList();
try
{
PicklistServiceEndpointStub.LoadOwnershipListResponse response
=
stub.loadOwnershipList(ownershipList);
PicklistServiceEndpointStub.ArrayOfOwnershipListItem owners =
response.getLoadOwnershipListResult();
10
Chapter 1: Overview
PicklistServiceEndpointStub.OwnershipListItem[] listItems =
owners.getOwnershipListItem();
// Add Business Logic
}
catch (Exception ex) { Logger.getLogger
TestClient.class.getName()).log(Level.SEVERE, null, ex);
}
11
Chapter 2:
Device Data Service
LoadDeviceGpsDataForDateRange(TimePeriod) 13
LoadDeviceApplicationList 17
LoadProvisioningProfiles 21
LoadConfigurationProfiles 25
LoadDeviceMetricDetails 30
LoadAdaptersByDevice 35
ListCertificates 41
GetSecurityAuditDetails 45
12
Chapter 2: Device Data Service
LoadDeviceGpsDataForDateRange(TimePeriod)
The method signatures are identical for these two methods, both returns a list of GPS coordinates. They differ in the
specification of the search criteria. For LoadDeviceGpsDataForDateRange, specify the StartDate and EndDate. For
LoadDeviceGpsDataForTimePeriod, specify the number of days as the Time Period.
General constraints/validations considered in the above methods:
l Maximum number of days/period considered for getting the GPS data is 180 days. In case of date-range API, if the
difference between the start-date and end-date is more than 180 days then a period of 180 days is considered from
the end date.
l The number of GPS points returned will be MAXPOINTS + 1, if the number of points present exceeds the
MAXPOINTS. This is because the business logic always adds the end point to the list.
Request Parameters:
Response Elements:
13
Chapter 2: Device Data Service
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DeviceData.DeviceDataService;
namespace DeviceData
{
{
class DeviceGpsDataForDate
{
static void Main(string[] args)
{
try
{
// Create an instance of DeviceDataServiceClient
DeviceDataServiceClient client = new DeviceDataServiceClient
();
GPSCoordinateEntity[] deviceResult =
client.LoadDeviceGpsDataForDateRange(deviceId,
deviceGPSSearch, operationContext);
if (deviceResult != null)
{
Console.WriteLine("GPS data is successfully loaded for the
device. Press any key to continue..");
Console.ReadLine();
}
else
{
Console.WriteLine("GPS data load failed. Please try again.
Press any key to continue..");Console.ReadLine();
}
14
Chapter 2: Device Data Service
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DeviceData.DeviceDataService;
namespace DeviceData
{
class LoadGPSDataByTime
{
static void Main(string[] args)
{
try
{
// Create an instance of DeviceDataServiceClient
DeviceDataServiceClient client = new DeviceDataServiceClient
();
15
Chapter 2: Device Data Service
// Operation Context
DeviceDataServiceEndpointStub.ServiceIdentity serviceIdentity
= new DeviceDataServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("[email protected]");
// Device
DeviceDataServiceEndpointStub.EntityKey device
= new DeviceDataServiceEndpointStub.EntityKey();
device.setValue(208);
DeviceDataServiceEndpointStub.DeviceGpsDataSearchCriteria searchCriteria
= new DeviceDataServiceEndpointStub.DeviceGpsDataSearchCriteria();
// Date range
Calendar startDate = Calendar.getInstance();
startDate.add(Calendar.DAY_OF_MONTH, -5);
searchCriteria.setStartDate(startDate);
16
Chapter 2: Device Data Service
searchCriteria.setEndDate(Calendar.getInstance());
request.setDeviceId(device);
request.setDeviceGpsDataSearchTransport(searchCriteria);
DeviceDataServiceEndpointStub.LoadDeviceGpsDataForDateRangeResponse
response = stub.loadDeviceGpsDataForDateRange(request);
DeviceDataServiceEndpointStub.ArrayOfGPSCoordinateEntity gpsList =
response.getLoadDeviceGpsDataForDateRangeResult();
DeviceDataServiceEndpointStub.GPSCoordinateEntity[] coordinateList =
gpsList.getGPSCoordinateEntity();
}
LoadDeviceApplicationList
This API returns the list of applications for a device and takes DeviceEntity as input with the device-ID in it.
Request Parameters:
17
Chapter 2: Device Data Service
Response Parameters:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DeviceData.DeviceDataService;
namespace DeviceData
{
class DeviceApplicationList
{
try
{
//Create an instance of DeviceDataServiceClient
DeviceDataServiceClient client = new DeviceDataServiceClient();
18
Chapter 2: Device Data Service
ApplicationOverviewTransport[] applicationOverviewTransport =
client.LoadDeviceApplicationList(deviceEntity, operationContext);
if (applicationOverviewTransport != null)
{
Console.WriteLine("Application list is successfully loaded for
the device. Press any key to continue..");
Console.ReadLine();
else
{
Console.WriteLine("Application list load failed. Please try
again. Press any key to continue..");
Console.ReadLine();
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}
String keyStoreFile =
D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
InputStream keyInput = new FileInputStream(keyStoreFile);
19
Chapter 2: Device Data Service
20
Chapter 2: Device Data Service
LoadProvisioningProfiles
This API returns the provisioning profiles for a device and takes DeviceEntity as input with the device-ID in it.
Request Parameters:
21
Chapter 2: Device Data Service
Response Parameters:
using System;
using System.Collections.Generic;
using System.Linq; using System.Text;
using DeviceData.DeviceDataService;
namespace DeviceData
{
class ProvisionProfiles { static void Main(string[] args)
{
try
{
//Create an instance of DeviceDataServiceClient
DeviceDataServiceClient client = new DeviceDataServiceClient();
//DeviceEntity containing Device ID
const int deviceId = 2561;
var deviceEntity = new DeviceEntity();
deviceEntity.Id = new EntityKey { Value = deviceId };
22
Chapter 2: Device Data Service
23
Chapter 2: Device Data Service
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try
{
DeviceDataServiceEndpointStub.ServiceIdentity serviceIdentity = new
DeviceDataServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
DeviceDataServiceEndpointStub.AWOperationContext operationContext =
new DeviceDataServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
DeviceDataServiceEndpointStub.EntityKey entityKey=new
DeviceDataServiceEndpointStub.EntityKey();
entityKey.setValue(572);
DeviceDataServiceEndpointStub.DeviceEntity deviceEntity=new
DeviceDataServiceEndpointStub.DeviceEntity();
deviceEntity.setId(entityKey);
DeviceDataServiceEndpointStub.LoadProvisioningProfiles
loadProvisioningProfiles=new
DeviceDataServiceEndpointStub.LoadProvisioningProfiles();
loadProvisioningProfiles.setDeviceEntityTransport(deviceEntity);
loadProvisioningProfiles.setOperationContext(operationContext);
DeviceDataServiceEndpointStub.LoadProvisioningProfilesResponse
loadProvisioningProfilesResponse=stub.loadProvisioningProfiles
(loadProvisioningProfiles);
} catch (Exception ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
24
Chapter 2: Device Data Service
LoadConfigurationProfiles
This API returns the configuration profiles for a device. It also takes deviceEntity as input with the device-ID in it and
returns the Configuration Profile summary for that device.
Request Parameters:
25
Chapter 2: Device Data Service
Response Parameters:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DeviceData.DeviceDataService;
namespace DeviceData
{
class ConfigurationProfiles
{
static void Main(string[] args)
{
try
{
// Create an instance of DeviceDataServiceClient
DeviceDataServiceClient client = new DeviceDataServiceClient
();
26
Chapter 2: Device Data Service
DeviceConfigurationProfileSamples configuratioProfileSamples =
client.LoadConfigurationProfiles(deviceEntity,
operationContext);
if (configuratioProfileSamples != null)
{
Console.WriteLine("Configuration Profile Samples are
successfully loaded for the device. Press any key to
continue..");
Console.ReadLine();
}
else
{
Console.WriteLine("Configuration Profile Samples failed to
load. Please try again. Press any key to continue..");
Console.ReadLine();
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
InputStream keyInput = new FileInputStream(keyStoreFile);
27
Chapter 2: Device Data Service
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
KeyStore trustStore = KeyStore.getInstance("JKS");
trustStore.load(keyInput, trustStorePassword.toCharArray());
keyInput.close();
try
{
DeviceDataServiceEndpointStub.ServiceIdentity serviceIdentity =
new DeviceDataServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
DeviceDataServiceEndpointStub.AWOperationContext operationContext =
new DeviceDataServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
DeviceDataServiceEndpointStub.EntityKey entityKey=new
DeviceDataServiceEndpointStub.EntityKey();
entityKey.setValue(572);
DeviceDataServiceEndpointStub.DeviceEntity deviceEntity=new
DeviceDataServiceEndpointStub.DeviceEntity();
deviceEntity.setId(entityKey);
28
Chapter 2: Device Data Service
DeviceDataServiceEndpointStub.LoadConfigurationProfiles
loadConfigurationProfiles=new
DeviceDataServiceEndpointStub.LoadConfigurationProfiles();
loadConfigurationProfiles.setDeviceEntityTransport(deviceEntity);
loadConfigurationProfiles.setOperationContextTransport
(operationContext);
DeviceDataServiceEndpointStub.LoadConfigurationProfilesResponse
loadConfigurationProfilesResponse=stub.loadConfigurationProfiles
(loadConfigurationProfiles);
29
Chapter 2: Device Data Service
LoadDeviceMetricDetails
This API returns the type DeviceMectricEntity with the information about the device. The input to this is DeviceEntity
with the value of ID.
Request Parameters:
30
Chapter 2: Device Data Service
Response Parameters:
31
Chapter 2: Device Data Service
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DeviceData.DeviceDataService;
namespace DeviceData
{
class DeviceMetric
{
static void Main(string[] args)
{
try
{
32
Chapter 2: Device Data Service
}
}
}
keyStore.load(keyInput, keyStrorePassword.toCharArray());
keyInput.close();
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks"; KeyStore trustStore
= KeyStore.getInstance("JKS");
33
Chapter 2: Device Data Service
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
DeviceDataServiceEndpointStub.ServiceIdentity serviceIdentity = new
DeviceDataServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
operationContext.setIdentity(serviceIdentity);
DeviceDataServiceEndpointStub.EntityKey entityKey=new
DeviceDataServiceEndpointStub.EntityKey();
entityKey.setValue(572);
DeviceDataServiceEndpointStub.DeviceEntity deviceEntity=new
DeviceDataServiceEndpointStub.DeviceEntity();
deviceEntity.setId(entityKey);
DeviceDataServiceEndpointStub.LoadDeviceMetricDetails
loadDeviceMetricDetails=new
DeviceDataServiceEndpointStub.LoadDeviceMetricDetails();
loadDeviceMetricDetails.setDeviceEntity(deviceEntity);
loadDeviceMetricDetails.setOperationContext(operationContext);
DeviceDataServiceEndpointStub.LoadDeviceMetricDetailsResponse
loadDeviceMetricDetailsResponse=stub.loadDeviceMetricDetails
(loadDeviceMetricDetails);
} catch (Exception ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
34
Chapter 2: Device Data Service
LoadAdaptersByDevice
This API is intended to give network status related to the particular device. It returns an array of AdapterEntityTransport[]
which contains all the details of the network status. Depending upon the network status, it will contain the objects of
following type. (These are the derived class of AdapterEntityTransport class):
l WWANAdapterEntityTransport
l WLANAdapterEntityTransport
l BluetoothAdapterEntityTransport
l OtherAdapterEntityTransport
l ActiveSyncAdapterEntityTransport
(Find the Response Elements: diagrams for the class structure)
Request Parameters:
35
Chapter 2: Device Data Service
Response Parameters:
Note:
1. CellularTechnologyTransport is an enum and it indicates whether the device uses GSM, CDMA, and None. If the
information is NULL in database then its value is UnKnown.
2. If particular network is not found for that device, then a corresponding object will not there in the result array.
36
Chapter 2: Device Data Service
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DeviceData.DeviceDataService;
namespace DeviceData
{
class Adapters
{
static void Main(string[] args)
{
try
{
//Create an instance of DeviceDataServiceClient
37
Chapter 2: Device Data Service
catch(Exceptionex)
{
Console.WriteLine(ex);
}
}
}
}
38
Chapter 2: Device Data Service
//
public void loadDeviceApplicationList() throws AxisFault, Exception {
String endPointURI =
"https://qa10ssl.AirWatchportals.com/AWBasicHttpService/DeviceDataServiceEndp
oint.svc";
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks"; KeyStore trustStore
= KeyStore.getInstance("JKS");
39
Chapter 2: Device Data Service
serviceIdentity.setName("Administrator");
DeviceDataServiceEndpointStub.AWOperationContext operationContext = new
DeviceDataServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
DeviceDataServiceEndpointStub.EntityKey entityKey=new
DeviceDataServiceEndpointStub.EntityKey();
entityKey.setValue(2561);
DeviceDataServiceEndpointStub.DeviceEntity deviceEntity=new
DeviceDataServiceEndpointStub.DeviceEntity();
deviceEntity.setId(entityKey);
DeviceDataServiceEndpointStub.LoadDeviceApplicationList
loadDeviceApplicationList=new
DeviceDataServiceEndpointStub.LoadDeviceApplicationList();
loadDeviceApplicationList.setDeviceEntity(deviceEntity);
loadDeviceApplicationList.setOperationContext(operationContext);
DeviceDataServiceEndpointStub.LoadDeviceApplicationListResponse
loadDeviceApplicationListResponse=stub.loadDeviceApplicationList
(loadDeviceApplicationList);
40
Chapter 2: Device Data Service
ListCertificates
This API lists all the certificate details associated with the device. It returns an object of
DeviceCertificateSamplesViewTransport, which contains the list of certificate information.
Request Parameters:
41
Chapter 2: Device Data Service
Response Parameters:
Note: The certificate’s raw data is returned in the form of byte [] Data. Using this Data, certificate can be created.
42
Chapter 2: Device Data Service
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DeviceData.DeviceDataService;
namespace DeviceData
{
class Certificates
{
static void Main(string[] args)
{
try
{
43
Chapter 2: Device Data Service
}
}
}
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
keyStore.load(keyInput, keyStrorePassword.toCharArray());
keyInput.close();
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
KeyStore trustStore = KeyStore.getInstance("JKS");
trustStore.load(keyInput, trustStorePassword.toCharArray());
keyInput.close();
stub._getServiceClient()
44
Chapter 2: Device Data Service
.getOptions()
.setProperty(
org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(
org.apache.axis2.transport.http.HTTPConstants.CUSTOM_PROTOCOL_
HANDLER, myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
DeviceDataServiceEndpointStub.ServiceIdentity serviceIdentity = new
DeviceDataServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
DeviceDataServiceEndpointStub.AWOperationContext operationContext = new
DeviceDataServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
DeviceDataServiceEndpointStub.EntityKey entityKey=new
DeviceDataServiceEndpointStub.EntityKey();
entityKey.setValue(572);
DeviceDataServiceEndpointStub.DeviceEntity deviceEntity=new
DeviceDataServiceEndpointStub.DeviceEntity();
deviceEntity.setId(entityKey);
DeviceDataServiceEndpointStub.ListCertificates listCertificates=new
DeviceDataServiceEndpointStub.ListCertificates();
listCertificates.setDeviceEntity(deviceEntity);
listCertificates.setOperationContext(operationContext);
DeviceDataServiceEndpointStub.ListCertificatesResponse
listCertificatesResponse=stub.listCertificates(listCertificates);
GetSecurityAuditDetails
This API returns the Security Audit information.
45
Chapter 2: Device Data Service
Request Parameters:
46
Chapter 2: Device Data Service
Response Parameters:
Find the response element structure in the below image:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DeviceData.DeviceDataService;
namespace DeviceData
{
class ComplianceSummary
{
static void Main(string[] args)
{
try
{
// Create an instance of DeviceDataServiceClient
DeviceDataServiceClient client = new DeviceDataServiceClient
();
47
Chapter 2: Device Data Service
Note:
l LastSIMCardChange30:
o True indicates - SIM card change detected
48
Chapter 2: Device Data Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
keyStore.load(keyInput, keyStrorePassword.toCharArray());
keyInput.close();
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks"; KeyStore trustStore
= KeyStore.getInstance("JKS");
keyInput = new FileInputStream(trustStoreFile);
String trustStorePassword = "changeit";
trustStore.load(keyInput, trustStorePassword.toCharArray());
keyInput.close();
stub._getServiceClient()
.getOptions()
.setProperty(
org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(
org.apache.axis2.transport.http.HTTPConstants.CUSTOM_PROTOCOL_
HANDLER, myProtocolHandler);
49
Chapter 2: Device Data Service
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
DeviceDataServiceEndpointStub.ServiceIdentity serviceIdentity = new
DeviceDataServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
DeviceDataServiceEndpointStub.AWOperationContext operationContext =
new DeviceDataServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
DeviceDataServiceEndpointStub.EntityKey entityKey=new
DeviceDataServiceEndpointStub.EntityKey();
entityKey.setValue(572);
DeviceDataServiceEndpointStub.DeviceEntity deviceEntity=new
DeviceDataServiceEndpointStub.DeviceEntity();
deviceEntity.setId(entityKey);
DeviceDataServiceEndpointStub.GetSecurityAuditDetails
getSecurityAuditDetails=new
DeviceDataServiceEndpointStub.GetSecurityAuditDetails();
getSecurityAuditDetails.setDeviceEntity(deviceEntity);
getSecurityAuditDetails.setOperationContext(operationContext);
DeviceDataServiceEndpointStub.GetSecurityAuditDetailsResponse
getSecurityAuditDetailsResponse=stub.getSecurityAuditDetails
(getSecurityAuditDetails);
}
catch (Exception ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
50
Chapter 3:
Device Profile Services
InstallDeviceProfile 52
RemoveDeviceProfile 55
CopyProfileToLocationGroup 58
GetDeviceProfileByID 60
51
Chapter 3: Device Profile Services
InstallDeviceProfile
This API Installs the specified profile on the device. It will take deviceprofile ID and deviceID as input.
Request Parameters
Response Elements
Boolean value for installed status.
52
Chapter 3: Device Profile Services
import javax.net.ssl.SSLContext;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.log4j.BasicConfigurator;
import services.com.air_watch.www.EnrollmentServiceEndpointStub;
import org.apache.commons.httpclient.protocol.Protocol;
import org.jsslutils.sslcontext.X509SSLContextFactory;
// End Point
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
// Key store
KeyStore keyStore = KeyStore.getInstance("JKS");
InputStream keyInput = new FileInputStream(testProps.getProperty
("javax.net.ssl.keyStore"));
keyStore.load(keyInput, "XX-PASSWORD".toCharArray());
keyInput.close();
// Trust Store
KeyStore trustStore = KeyStore.getInstance("JKS");
keyInput = new FileInputStream(testProps.getProperty
("javax.net.ssl.trustStore"));
trustStore.load(keyInput, "XX-PASSWORD".toCharArray());
keyInput.close();
// SSL Context
X509SSLContextFactory sslContextFactory = new X509SSLContextFactory(keyStore,
" XX-PASSWORD", trustStore);
SSLContext sslClientContext = sslContextFactory.buildSSLContext();
Protocol myProtocolHandler = new Protocol("https", new
SslContextedSecureProtocolSocketFactory(sslClientContext, false), 443);
// Request Proxy
DeviceProfileServiceEndpointStub stub = new DeviceProfileServiceEndpointStub
();
stub._getServiceClient().engageModule("addressing");
stub._getServiceClient().getOptions().setProperty
(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_PROTOCOL_HANDLER,
myProtocolHandler);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try
{
// Set the identity
53
Chapter 3: Device Profile Services
// Set profile ID
DeviceProfileServiceEndpointStub.EntityKey profileKey = new
DeviceProfileServiceEndpointStub.EntityKey();
profileKey.setValue(1820);
profile.setProfileID(profileKey);
InstallDeviceProfile installDeviceProfile = new InstallDeviceProfile();
installDeviceProfile.setDeviceId(deviceKey);
installDeviceProfile.setDeviceProfile(profile);
installDeviceProfile.setOperationContext(operationContext);
stub.installDeviceProfile(installDeviceProfile);
}
catch (Exception ex) {
Logger.getLogger(TestClient.class.getName()).log(Level.SEVERE, null, ex);
}
54
Chapter 3: Device Profile Services
RemoveDeviceProfile
This API deletes the deviceprofile from the device.
Request Parameters:
Response Elements:
Boolean value for removed status.
//
static void Main(string[] args)
{
try
{
context = new AWOperationContext()
{
Identity = new ServiceIdentity {Name = "Administrator”}
};
var client = new DeviceProfileServiceClient();
client.Open();
var deviceKey = new EntityKey() {Value = 3939};
var profileKey = new DeviceProfileEntity() { ProfileID = new EntityKey
() {Value = 1234}
};
client.RemoveDeviceProfile(deviceKey, profileKey, context);
client.Close();
}
catch (Exception ex)
{
throw ex;
}
55
Chapter 3: Device Profile Services
import javax.net.ssl.SSLContext;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.log4j.BasicConfigurator;
import services.com.air_watch.www.EnrollmentServiceEndpointStub;
import org.apache.commons.httpclient.protocol.Protocol;
import org.jsslutils.sslcontext.X509SSLContextFactory;
// End Point
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
// Key store
KeyStore keyStore = KeyStore.getInstance("JKS");
InputStream keyInput = new FileInputStream(testProps.getProperty
("javax.net.ssl.keyStore"));
keyStore.load(keyInput, "XX-PASSWORD".toCharArray());
keyInput.close();
// Trust Store
KeyStore trustStore = KeyStore.getInstance("JKS");
keyInput = new FileInputStream(testProps.getProperty
("javax.net.ssl.trustStore"));
trustStore.load(keyInput, "XX-PASSWORD".toCharArray());
keyInput.close();
// SSL Context
X509SSLContextFactory sslContextFactory = new X509SSLContextFactory(keyStore,
" XX-PASSWORD", trustStore);
SSLContext sslClientContext = sslContextFactory.buildSSLContext();
Protocol myProtocolHandler = new Protocol("https", new
SslContextedSecureProtocolSocketFactory(sslClientContext, false), 443);
// Request Proxy
DeviceProfileServiceEndpointStub stub = new DeviceProfileServiceEndpointStub
();
stub._getServiceClient().engageModule("addressing");
56
Chapter 3: Device Profile Services
// Set profile ID
DeviceProfileServiceEndpointStub.EntityKey profileKey = new
DeviceProfileServiceEndpointStub.EntityKey(); profileKey.setValue(1820);
profile.setProfileID(profileKey);
RemoveDeviceProfile removeDeviceProfile = new RemoveDeviceProfile();
removeDeviceProfile.setDeviceId(deviceKey );
removeDeviceProfile.setDeviceProfile(profile);
removeDeviceProfile.setOperationContext(operationContext);
stub.removeDeviceProfile(removeDeviceProfile );
}
catch (Exception ex) {
Logger.getLogger(TestClient.class.getName()).log(Level.SEVERE, null, ex);
}
57
Chapter 3: Device Profile Services
CopyProfileToLocationGroup
Copies the device Profile from one location group to another location group.
Request Parameters:
1. EntityKey: LocationGroup.
2. EntityKey : LocationgroupID
3. AWOperationContext
Response Elements:
Boolean to indicate success/failure.
58
Chapter 3: Device Profile Services
59
Chapter 3: Device Profile Services
GetDeviceProfileByID
Returns the DeviceProfile object searched by profile ID.
Request Parameters:
1. EntityKey : LocationGroup.
2. AWOperationContext
Response Elements:
Returns the DeviceProfileEntity Object.
60
Chapter 3: Device Profile Services
61
Chapter 4:
Device Service
Save 63
Load 67
Search 69
UpdateDevice 74
Device Commands 77
QueryDevice 99
RemoveDevice 103
GetDevicesByIsCompromised 106
GetDeviceSummaryByPasscode 106
GetDeviceSummaryByDataEncryption 107
GetDeviceSummaryByOwnership 107
GetDeviceSummaryByPlatform 107
62
Chapter 4: Device Service
Save
This API creates a new device or updates the device information.
l For creating new Device:
o DeviceUId and DeviceType have to be passed along with other information.
Request Parameters:
1. DeviceEntity
2. AWOperationContext
Response Elements:
63
Chapter 4: Device Service
client.Open();
var deviceEntity = new DeviceEntity();
deviceEntity.ActivationCode = "global";
deviceEntity.AssetNumber = "test";
deviceEntity.SerialNumber = "test";
deviceEntity.DeviceUid = "583C3FCC4DE43B41B741BC5CAC82B014";
deviceEntity.DeviceType = new EntityKey(){ Value = 5};
var result = client.Save( deviceEntity, context);
client.Close();
}
catch (Exception ex)
{
throw ex;
}
}
64
Chapter 4: Device Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
InputStream keyInput = new FileInputStream(keyStoreFile);
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
KeyStore trustStore = KeyStore.getInstance("JKS");
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER, myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
DeviceServiceEndpointStub.ServiceIdentity serviceIdentity = new
DeviceServiceEndpointStub.ServiceIdentity();
65
Chapter 4: Device Service
serviceIdentity.setName("Administrator");
operationContext.setIdentity(serviceIdentity);
deviceEntity.setActivationCode("global");
deviceEntity.setAssetNumber("prabhutest");
deviceEntity.setSerialNumber("prabhutest");
deviceEntity.setDeviceUid("583C3FCC4DE43B41B741BC5CAC82B014");
DeviceServiceEndpointStub.EntityKey entityKey = new
DeviceServiceEndpointStub.EntityKey();
entityKey.setValue(5);
deviceEntity.setDeviceType(entityKey);
DeviceServiceEndpointStub.Save save=new DeviceServiceEndpointStub.Save
();
save.setDeviceEntity(deviceEntity);
save.setOperationContext(operationContext);
DeviceServiceEndpointStub.SaveResponse saveResponse=stub.save(save);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
66
Chapter 4: Device Service
Load
Loads the device based on deviceID.
Request Parameters:
1. DeviceID
2. AWOperationContext
Response Elements:
67
Chapter 4: Device Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
InputStream keyInput = new FileInputStream(keyStoreFile);
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
KeyStore trustStore = KeyStore.getInstance("JKS");
68
Chapter 4: Device Service
entityKey.setValue(4694);
DeviceServiceEndpointStub.Load load=new
DeviceServiceEndpointStub.Load();
load.setEntityKey(entityKey); load.setOperationContext
(operationContext); DeviceServiceEndpointStub.LoadResponse
loadResponse=stub.load(load);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null,
ex);
}
}
Search
Searches for the device according to the search criteria.
69
Chapter 4: Device Service
Request Parameters:
1. DeviceSearchCriteria.
Note: If the property Exactmatch is true then it searches for exact string match or else it will use like operator to
match.
2. AWOperationContext
Response Elements:
1. DeviceSearchResult.
using System;
using System.Collections.Generic;
70
Chapter 4: Device Service
using System.Linq;
using System.Text;
using Device.DeviceService;
namespace Device
{
class DeviceSearch
{
static void Main(string[] args)
{
try
{
DeviceServiceClient client = new DeviceServiceClient();
71
Chapter 4: Device Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
InputStream keyInput = new FileInputStream(keyStoreFile);
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
KeyStore trustStore = KeyStore.getInstance("JKS");
72
Chapter 4: Device Service
operationContext.setIdentity(serviceIdentity);
DeviceServiceEndpointStub.DeviceSearchCriteria
deviceSearchCriteria = new
DeviceServiceEndpointStub.DeviceSearchCriteria();
deviceSearchCriteria.setFriendlyName("Brandon’s iPhone");
deviceSearchCriteria.setSerialNumber("320021D13NP");
deviceSearchCriteria.setExactMatch(true);
DeviceServiceEndpointStub.Search search=new
DeviceServiceEndpointStub.Search(); search.setSearchCriteria
(deviceSearchCriteria); search.setOperationContext
(operationContext); DeviceServiceEndpointStub.SearchResponse
queryDeviceResponses=stub.search(search);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null,
ex);
}
}
73
Chapter 4: Device Service
UpdateDevice
This method is added specifically to Pinecone integration. Is used to update the device extended details in the AirWatch
DB. This method is different from the Save method in a way that, it only does the update/insertion specific to
extendedField specified in the deviceEntity input.
Request Parameters:
1. Device Entity:
Response Elements:
1. Device ID
74
Chapter 4: Device Service
deviceEntity.DeviceUid = "583C3FCC4DE43B41B741BC5CAC82B014";
deviceEntity.DeviceType = new EntityKey() { Value = 5 };
deviceEntity.DeviceExtendedField = "L";
// Set 'L'
var result = client.UpdateDevice(deviceEntity);
client.Close();
}
catch (Exception ex)
{
throw ex;
}
}
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
75
Chapter 4: Device Service
keyInput.close();
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
DeviceServiceEndpointStub.ServiceIdentity serviceIdentity = new
DeviceServiceEndpointStub.ServiceIdentity(); serviceIdentity.setName
("Administrator"); DeviceServiceEndpointStub.AWOperationContext
operationContext = new DeviceServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
DeviceServiceEndpointStub.DeviceEntity deviceEntity = new
DeviceServiceEndpointStub.DeviceEntity();
deviceEntity.setDeviceUid("583C3FCC4DE43B41B741BC5CAC82B014");
DeviceServiceEndpointStub.EntityKey entityKey = new
DeviceServiceEndpointStub.EntityKey(); entityKey.setValue(5);
deviceEntity.setDeviceType(entityKey);
deviceEntity.setDeviceExtendedField("L");
DeviceServiceEndpointStub.UpdateDevice updateDevice=new
DeviceServiceEndpointStub.UpdateDevice();
updateDevice.setDeviceEntityTransport(deviceEntity);
DeviceServiceEndpointStub.UpdateDeviceResponse
updateDeviceResponse=stub.updateDevice(updateDevice);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
76
Chapter 4: Device Service
Device Commands
LockDevice
Request Parameters:
1. Device Entity
2. Operation Context
Response Elements:
DeviceLock method returns a Boolean value true/false as output parameter indicating success/failure of the Device
Command operation.
This method is used for remotely locking an enrolled device.
Input Parameters
deviceEntity: This corresponds to the device details. Obligatory fields for deviceEntity are DeviceUid (with data type as
string) or DeviceId (integer), ActivationCode (string) and DeviceType (entity key with value as integer).
operationContext: This describes the user context for the end user performing the device lock operation.
using System;
using System.Collections.Generic;
77
Chapter 4: Device Service
using System.Linq;
using System.Text;
using DeviceCommands.DeviceService;
using System.Runtime.Serialization;
using System.ServiceModel;
namespace DeviceCommands { class LockDevice { static void Main(string[] args)
{
try
{
// An instance of DeviceEntity holds the device details.
78
Chapter 4: Device Service
}
}
}
}
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
Boolean.FALSE);
79
Chapter 4: Device Service
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER,myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
DeviceServiceEndpointStub.ServiceIdentity serviceIdentity = new
DeviceServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
DeviceServiceEndpointStub.AWOperationContext operationContext =
new DeviceServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
DeviceServiceEndpointStub.DeviceEntity deviceEntity=new
DeviceServiceEndpointStub.DeviceEntity();
deviceEntity.setActivationCode("demo");
deviceEntity.setDeviceUid("1AB0485284BG24789G356734FGHJ2345");
DeviceServiceEndpointStub.EntityKey deviceEntityKey=new
DeviceServiceEndpointStub.EntityKey();
deviceEntityKey.setValue(23960);
deviceEntity.setId(deviceEntityKey);
DeviceServiceEndpointStub.EntityKey deviceTypeEntityKey=new
DeviceServiceEndpointStub.EntityKey();
deviceTypeEntityKey.setValue(4);
deviceEntity.setDeviceType(deviceTypeEntityKey);
DeviceServiceEndpointStub.LockDevice lockDevice=new
DeviceServiceEndpointStub.LockDevice();
lockDevice.setDeviceEntity(deviceEntity);
lockDevice.setOperationContext(operationContext);
DeviceServiceEndpointStub.LockDeviceResponse
lockDeviceResponse=stub.lockDevice(lockDevice);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null,
ex);
}
}
80
Chapter 4: Device Service
ClearPasscode
Request Parameters:
Response Elements:
ClearPasscode method returns a Boolean value true/false as output parameter indicating success/failure of the Device
Command operation.
This method is used for clearing the passcode (i.e. password) for an enrolled device.
Input Parameters
deviceEntity: This corresponds to the device details. Mandatory fields for deviceEntity are DeviceUid (with data type as
string) or DeviceId (integer), ActivationCode (string) and DeviceType (entity key with value as integer)
operationContext: This describes the user context for the end user performing the clear passcode operation.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DeviceCommands.DeviceService;
using System.Runtime.Serialization;
using System.ServiceModel;
namespace DeviceCommands
{
class ClearPasscode
{
81
Chapter 4: Device Service
82
Chapter 4: Device Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
InputStream keyInput = new FileInputStream(keyStoreFile);
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
trustStore.load(keyInput, trustStorePassword.toCharArray());
keyInput.close();
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER,myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
83
Chapter 4: Device Service
try {
DeviceServiceEndpointStub.ServiceIdentity serviceIdentity = new
DeviceServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
DeviceServiceEndpointStub.AWOperationContext operationContext = new
DeviceServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
DeviceServiceEndpointStub.DeviceEntity deviceEntity=new
DeviceServiceEndpointStub.DeviceEntity();
deviceEntity.setActivationCode("demo");
deviceEntity.setDeviceUid("1AB0485284BG24789G356734FGHJ2345");
DeviceServiceEndpointStub.EntityKey deviceEntityKey=new
DeviceServiceEndpointStub.EntityKey();
deviceEntityKey.setValue(23960);
deviceEntity.setId(deviceEntityKey);
DeviceServiceEndpointStub.EntityKey deviceTypeEntityKey=new
DeviceServiceEndpointStub.EntityKey();
deviceTypeEntityKey.setValue(4);
deviceEntity.setDeviceType(deviceTypeEntityKey);
DeviceServiceEndpointStub.ClearPasscode clearPasscode=new
DeviceServiceEndpointStub.ClearPasscode();
clearPasscode.setDeviceEntity(deviceEntity);
clearPasscode.setOperationContext(operationContext);
DeviceServiceEndpointStub.ClearPasscodeResponse
clearPasscodeResponse=stub.clearPasscode(clearPasscode);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); }
}
DeviceWipe
Request Parameters:
84
Chapter 4: Device Service
Response Elements:
DeviceWipe method returns a Boolean value true/false as output parameter indicating success/failure of the Device
Command operation.
This method is used to wipe an enrolled device remotely.
Input Parameters
DeviceEntity: This corresponds to the device details. Mandatory fields for deviceEntity are DeviceUid (with data type as
string) or DeviceId (integer), ActivationCode (string) and DeviceType (entity key with value as integer)
OperationContext: This describes the user context for the end user performing the device wipe operation.
85
Chapter 4: Device Service
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DeviceCommands.DeviceService;
using System.Runtime.Serialization;
using System.ServiceModel;
namespace DeviceCommands
{
class DeviceWipe
{
static void Main(string[] args)
{
try
{
// An instance of DeviceEntity holds the device details.
/* Either DeviceUid or DeviceId(denoted as Id) can be
specified for constructing the DeviceEntity*/
if (result)
{
Console.WriteLine("DeviceWipe successful. Press any key to
continue..");
Console.ReadLine();
}
else
{
Console.WriteLine("DeviceWipe unsuccessful. Press any key
86
Chapter 4: Device Service
to continue..");
Console.ReadLine();
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
87
Chapter 4: Device Service
stub._getServiceClient()
.getOptions()
.setProperty
(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
=.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER, myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
DeviceServiceEndpointStub.ServiceIdentity serviceIdentity = new
DeviceServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
deviceEntity.setActivationCode("demo");
deviceEntity.setDeviceUid("1AB0485284BG24789G356734FGHJ2345");
DeviceServiceEndpointStub.EntityKey deviceEntityKey=new
DeviceServiceEndpointStub.EntityKey();
deviceEntityKey.setValue(23960);
deviceEntity.setId(deviceEntityKey);
DeviceServiceEndpointStub.EntityKey deviceTypeEntityKey=new
DeviceServiceEndpointStub.EntityKey();
deviceTypeEntityKey.setValue(4);
deviceEntity.setDeviceType(deviceTypeEntityKey);
DeviceServiceEndpointStub.DeviceWipe deviceWipe=new
DeviceServiceEndpointStub.DeviceWipe();
deviceWipe.setDeviceEntity(deviceEntity);
deviceWipe.setOperationContext(operationContext);
88
Chapter 4: Device Service
DeviceServiceEndpointStub.DeviceWipeResponse
deviceWipeResponse=stub.deviceWipe(deviceWipe);
}
UnenrollDevice
Request Parameters:
Response Elements:
UnenrollDevice method returns a Boolean value true/false as output parameter indicating success/failure of the Device
Command operation.
This method is used for unenrolling an enrolled device.
Input Parameters
DeviceEntity: This corresponds to the device details. Mandatory fields for deviceEntity are DeviceUid (with data type as
string), ActivationCode (string) and DeviceType (entity key with value as integer)
using System;
89
Chapter 4: Device Service
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DeviceCommands.DeviceService;
using System.Runtime.Serialization;
using System.ServiceModel;
namespace DeviceCommands
{
class UnenrollDevice
{
static void Main(string[] args)
{
try
{
// An instance of DeviceEntity holds the device details.
/* Either DeviceUid or DeviceId(denoted as Id) can be specified
for constructing the DeviceEntity*/
if (result)
{
Console.WriteLine("UnenrollDevice successful. Press any key to
continue..");
Console.ReadLine();
}
else
{
Console.WriteLine("UnenrollDevice unsuccessful. Press any key
to continue..");
Console.ReadLine();
}
90
Chapter 4: Device Service
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}
SendMessage
Request Parameters:
Response Elements:
SendMessage method returns a Boolean value true/false as output parameter indicating success/failure of the Device
Command operation.
This method is used for sending a text message to an enrolled device.
Input Parameters
DeviceEntity: This corresponds to the device details. Mandatory fields for deviceEntity are DeviceUid(with data type as
string) or DeviceId (integer), ActivationCode (string), DeviceType (entity key with value as integer), PhoneNumber and
MessageBody (both with data type as string).
OperationContext: This describes the user context for the end user performing the send message operation.
91
Chapter 4: Device Service
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DeviceCommands.DeviceService;
using System.Runtime.Serialization;
using System.ServiceModel;
namespace DeviceCommands
{
class SendMessage
{
static void Main(string[] args)
{
try
{
// An instance of DeviceEntity holds the device details.
/* Either DeviceUid or DeviceId(denoted as Id) can be
specified for constructing the DeviceEntity*/
92
Chapter 4: Device Service
Console.ReadLine();
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
trustStore.load(keyInput, trustStorePassword.toCharArray());
keyInput.close();
X509SSLContextFactory sslContextFactory = new X509SSLContextFactory
(keyStore, keyStrorePassword.toCharArray(), trustStore);
93
Chapter 4: Device Service
stub._getServiceClient()
.getOptions()
.setProperty
(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER,myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
DeviceServiceEndpointStub.ServiceIdentity serviceIdentity = new
DeviceServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
DeviceServiceEndpointStub.AWOperationContext operationContext = new
DeviceServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
DeviceServiceEndpointStub.DeviceEntity deviceEntity=new
DeviceServiceEndpointStub.DeviceEntity();
deviceEntity.setActivationCode("demo");
deviceEntity.setDeviceUid("1AB0485284BG24789G356734FGHJ2345");
DeviceServiceEndpointStub.EntityKey deviceEntityKey=new
DeviceServiceEndpointStub.EntityKey();
deviceEntityKey.setValue(23960);
deviceEntity.setId(deviceEntityKey);
DeviceServiceEndpointStub.EntityKey deviceTypeEntityKey=new
DeviceServiceEndpointStub.EntityKey();
deviceTypeEntityKey.setValue(4);
deviceEntity.setDeviceType(deviceTypeEntityKey);
sendMessage.setDeviceEntity(deviceEntity);
sendMessage.setOperationContext(operationContext);
DeviceServiceEndpointStub.SendMessageResponse
deviceWipeResponse=stub.sendMessage(sendMessage);
}
94
Chapter 4: Device Service
95
Chapter 4: Device Service
GetDevicesByLocationGroup
This API returns the array of devices present in the specified locationGroup. It returns in the array of
DeviceDashboardSummary objects.
Request Parameters:
Response Elements:
Note:
l OwnershipAbbr: This attribute informs about the ownership of the Device. Possible values are:
o C - Corporate dedicated
o S - Corparate shared
o E - Employee owned
96
Chapter 4: Device Service
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Device.DeviceService;
namespace Device
{
class DevicesByLG
{
static void Main(string[] args)
{
try
{
// Create an instance of DeviceServiceClient
DeviceServiceClient client = new DeviceServiceClient();
97
Chapter 4: Device Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
KeyStore trustStore = KeyStore.getInstance("JKS");
keyInput = new FileInputStream(trustStoreFile);
String trustStorePassword = "changeit";
trustStore.load(keyInput, trustStorePassword.toCharArray());
keyInput.close();
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER, myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
98
Chapter 4: Device Service
serviceIdentity.setName("Administrator");
operationContext.setIdentity(serviceIdentity);
DeviceServiceEndpointStub.EntityKey locationEntityKey=new
DeviceServiceEndpointStub.EntityKey();
locationEntityKey.setValue(631);
DeviceServiceEndpointStub.GetDevicesByLocationGroup
getDevicesByLocationGroup=new
DeviceServiceEndpointStub.GetDevicesByLocationGroup();
getDevicesByLocationGroup.setLocationGroupId(locationEntityKey);
getDevicesByLocationGroup.setOperationContext(operationContext);
DeviceServiceEndpointStub.GetDevicesByLocationGroupResponse
getDevicesByLocationGroupResponse=stub.getDevicesByLocationGroup
(getDevicesByLocationGroup);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
QueryDevice
Queries the device and returns a Boolean success/failure.
Request Parameters:
1. DeviceEntity: Qeury device is based on DeviceID. If DeviceID is null then based on DeviceType and deviceUID it
performs deviceQuery. ActivationCode is required.
99
Chapter 4: Device Service
2. AWOperationContext
Response Elements:
Boolean value.
100
Chapter 4: Device Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
keyStore.load(keyInput, keyStrorePassword.toCharArray());
keyInput.close();
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
101
Chapter 4: Device Service
stub._getServiceClient()
.getOptions()
.setProperty
(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER,myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
serviceIdentity.setName("Administrator");
operationContext.setIdentity(serviceIdentity);
idEntityKey.setValue(4589);
deviceEntity.setActivationCode("global");
102
Chapter 4: Device Service
DeviceServiceEndpointStub.QueryDevice queryDevice=new
DeviceServiceEndpointStub.QueryDevice();
queryDevice.setDeviceEntity(deviceEntity);
queryDevice.setOperationContext(operationContext);
DeviceServiceEndpointStub.QueryDeviceResponse
queryDeviceResponses=stub.queryDevice(queryDevice);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
RemoveDevice
Removes the device from AirWatch DB.
Request Parameters:
1. EntityKey : DeviceID
2. AWOperationContext
Response Elements:
Returns true/false depending on deletion success.
103
Chapter 4: Device Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
104
Chapter 4: Device Service
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER,myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
DeviceServiceEndpointStub.ServiceIdentity serviceIdentity = new
DeviceServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
DeviceServiceEndpointStub.AWOperationContext operationContext = new
DeviceServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
entityKey.setValue(4694);
DeviceServiceEndpointStub.RemoveDevice removeDevice=new
DeviceServiceEndpointStub.RemoveDevice();
removeDevice.setDeviceId(entityKey);
removeDevice.setOperationContext(operationContext);
DeviceServiceEndpointStub.RemoveDeviceResponse
loadResponse=stub.removeDevice(removeDevice);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
105
Chapter 4: Device Service
GetDevicesByIsCompromised
Returns a device count for a location group for various compromised statuses. Location group will be derived from the
client certificate used to make the API call.
Request Parameters:
No Input
Response Elements:
Dictionary<string, int>
GetDeviceSummaryByPasscode
Returns a device count for a location group for various passcode statuses. Location group will be derived from the client
certificate used to make the API call.
Request Parameters:
No Input
Response Elements:
Dictionary<string, int>
106
Chapter 4: Device Service
GetDeviceSummaryByDataEncryption
Returns a device count for a location group for various data encryption statuses.Location group will be derived from the
client certificate used to make the API call.
Request Parameters:
No Input.
Response Elements:
Dictionary<string, int>
GetDeviceSummaryByOwnership
Returns a device count for a location group for various data encryption statuses.Location group will be derived from the
client certificate used to make the API call.
Request Parameters:
Response Elements:
Dictionary<string, int>
GetDeviceSummaryByPlatform
Returns a device count for a location group for various platforms.Location group will be derived from the client certificate
used to make the API call.
Request Parameters:
No Input.
Response Elements:
Dictionary<string, int>
107
Chapter 5:
Enrollment Service
Overview 109
RegisterEnrollmentUser 109
RegisterDeviceForUser 111
RemoveEnrollmentUser 116
PublishUserProfiles 121
LoadEnrolledDeviceUser 125
108
Chapter 5: Enrollment Service
Overview
This service provides access to business functionality related to Enrollment management. It provides methods to create a
new enrollment user and associate a device with a particular user.
RegisterEnrollmentUser
Request Parameters:
Response Elements:
None
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Enrollment.EnrollmentService;
namespace Enrollment
{
class EnrollUser
{
static void Main(string[] args)
{
try
{
// Create an instance of EnrollmentServiceClient
EnrollmentServiceClient client = new EnrollmentServiceClient
();
109
Chapter 5: Enrollment Service
operationContext.setIdentity(serviceIdentity);
EnrollmentServiceEndpointStub.EnrollmentUserEntity userEntity = new
EnrollmentServiceEndpointStub.EnrollmentUserEntity();
110
Chapter 5: Enrollment Service
userEntity.setActivationCode("demo");
userEntity.setAuthentication
(EnrollmentServiceEndpointStub.EnrollmentUserAuthenticationType.Basic);
guid.setGuid(UUID.randomUUID().toString());
EnrollmentServiceEndpointStub.ConcurrencyIdentifier concurrencyIdentifier
= new EnrollmentServiceEndpointStub.ConcurrencyIdentifier();
concurrencyIdentifier.setValue(guid);
userEntity.setConcurrencyId(concurrencyIdentifier);
userEntity.setEmailAddress("[email protected]"); userEntity.setFirstName
("John"); userEntity.setLastName("Doe"); userEntity.setPhoneNumber
("123456789"); userEntity.setUsername("user");
userEntity.setUserPassword("password");
EnrollmentServiceEndpointStub.ConcurrentEntityReference entityReference =
new EnrollmentServiceEndpointStub.ConcurrentEntityReference();
entityKey1.setValue(1);
userEntity.setId(entityKey1);
request.setOperationContext(operationContext);
request.setUserEntityTransport(userEntity);
RegisterDeviceForUser
Associates a device to an enrollment user. If the user does not exist, it creates a new enrollment user.
111
Chapter 5: Enrollment Service
Request Parameters:
1. EnrollmentUserEntity
2. EnrollmentDeviceEntity
3. AWOperationContext
Response Elements:
No response.
112
Chapter 5: Enrollment Service
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Enrollment.EnrollmentService;
namespace Enrollment
{
class RegisterDevice
{
static void Main(string[] args)
{
try
{
// Create an instance of EnrollmentServiceClient
EnrollmentServiceClient client = new EnrollmentServiceClient
();
user.Authentication = EnrollmentUserAuthenticationType.Basic;
user.MessageType = MessageType.Email;
device.DeviceOperatingSystem = "iOS4.3";
113
Chapter 5: Enrollment Service
Console.WriteLine(ex);
}
}
}
}
114
Chapter 5: Enrollment Service
serviceIdentity.setName("Administrator");
EnrollmentServiceEndpointStub.AWOperationContext operationContext = new
EnrollmentServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
request.setOperationContext(operationContext);
/*------*/
/*Setting Enrollment User */
userEntity.setActivationCode("Apple");
userEntity.setAuthentication
(EnrollmentServiceEndpointStub.EnrollmentUserAuthenticationType.Basic);
guid.setGuid(UUID.randomUUID().toString());
EnrollmentServiceEndpointStub.ConcurrencyIdentifier concurrencyIdentifier =
new EnrollmentServiceEndpointStub.ConcurrencyIdentifier();
concurrencyIdentifier.setValue(guid);
userEntity.setConcurrencyId(concurrencyIdentifier);
userEntity.setAuthentication
(EnrollmentServiceEndpointStub.EnrollmentUserAuthenticationType.TokenOnly);
userEntity.setEmailAddress("[email protected]");
userEntity.setFirstName("First");
userEntity.setLastName("Last");
userEntity.setPhoneNumber("");
userEntity.setUsername("TestEU");
userEntity.setUserPassword("");
request.setUserEntityTransport(userEntity);
/*------*/
/*Setting Enrollment Device*/
115
Chapter 5: Enrollment Service
deviceEntity.setAssetNumber("AN001"); deviceEntity.setDeviceModel("iPhone");
deviceEntity.setDeviceOperatingSystem("iOS 4.0");
deviceEntity.setDevicePlatform("Apple");
deviceEntity.setInternationMobileEquipmentIdentity("IMEI001122");
deviceEntity.setSerialNumber("SN00998877");
deviceEntity.setSubscriberIdentityModule("ATT");
deviceEntity.setUdid("TGJHGFJGSD8345634RGRE5654");
EnrollmentServiceEndpointStub.OwnershipListItem ownership = new
EnrollmentServiceEndpointStub.OwnershipListItem();
/*loop through the listItems and find the ownership by Text - "C", "E" or "S"
*/
/* sample code uses listItems[0] */
ownership.setDescription(listItems[0].getDescription());
ownership.setSortOrder(listItems[0].getSortOrder());
ownership.setValue(listItems[0].getValue());
deviceEntity.setOwnership(ownership);
request.setDeviceEntityTransport(deviceEntity);
RemoveEnrollmentUser
Using this API below actions can be performed.
116
Chapter 5: Enrollment Service
User Actions:
1. Deactivate User
2. Delete User
Device Actions:
1. Wipe all the devices associated to the User
Request Parameters:
1. RemoveEnrollmentUserRequest
2. AWOperationContext
117
Chapter 5: Enrollment Service
// user action.
userRemove.RemoveUserAction = RemoveUserActions.DeleteUser;
client.RemoveEnrollmentUser(userRemove, context);
client.Close();
}
catch (Exception ex)
{
throw ex;
}
}
118
Chapter 5: Enrollment Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
InputStream keyInput = new FileInputStream(keyStoreFile);
String keyStrorePassword = "wif1Admin";
keyStore.load(keyInput, keyStrorePassword.toCharArray());
keyInput.close();
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
KeyStore trustStore = KeyStore.getInstance("JKS");
keyInput = new FileInputStream(trustStoreFile);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
serviceIdentity.setName("Administrator");
119
Chapter 5: Enrollment Service
EnrollmentServiceEndpointStub.AWOperationContext operationContext =
new EnrollmentServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
EnrollmentServiceEndpointStub.RemoveEnrollmentUserRequest
removeEnrollmentUserRequest = new
EnrollmentServiceEndpointStub.RemoveEnrollmentUserRequest();
removeEnrollmentUserRequest.setUsername("prabhu");
removeEnrollmentUserRequest.setActivationCode("global");
removeEnrollmentUserRequest
.setRemoveUserDeviceAction
(EnrollmentServiceEndpointStub.RemoveUserDeviceActions.None);
removeEnrollmentUserRequest
.setRemoveUserAction
(EnrollmentServiceEndpointStub.RemoveUserActions.DeleteUser);
EnrollmentServiceEndpointStub.RemoveEnrollmentUser
removeEnrollmentUser = new
EnrollmentServiceEndpointStub.RemoveEnrollmentUser();
removeEnrollmentUser .setUserRequestTransport
(removeEnrollmentUserRequest);
removeEnrollmentUser.setOperationContext(operationContext);
stub.removeEnrollmentUser(removeEnrollmentUser);
}
catch (Exception ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
120
Chapter 5: Enrollment Service
PublishUserProfiles
This API publishes the profile for all the Devices enrolled for the specified user.
Request Parameters:
1. PublishProfileRequest
2. AWOperationContext
121
Chapter 5: Enrollment Service
Response Elements:
ProfileType = ProfileTypes.LDAP
};
client.PublishUserProfiles(profileRequest, context);
client.Close();
}
catch (Exception ex)
{
throw ex;
}
}
122
Chapter 5: Enrollment Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
// End Point
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER, myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
123
Chapter 5: Enrollment Service
try {
EnrollmentServiceEndpointStub.ServiceIdentity serviceIdentity = new
EnrollmentServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
operationContext.setIdentity(serviceIdentity);
EnrollmentServiceEndpointStub.PublishProfileRequest publishProfileRequest
= new EnrollmentServiceEndpointStub.PublishProfileRequest();
publishProfileRequest.setActivationCode("adam");
publishProfileRequest.setUserName("demo");
publishProfileRequest
.setProfileType(EnrollmentServiceEndpointStub.ProfileTypes.LDAP);
EnrollmentServiceEndpointStub.PublishUserProfiles publishUserProfiles =
new EnrollmentServiceEndpointStub.PublishUserProfiles();
publishUserProfiles.setOperationContext(operationContext);
publishUserProfiles
.setProfileRequestTransport(publishProfileRequest);
stub.publishUserProfiles(publishUserProfiles);
}
catch (Exception ex) { Logger.getLogger(Main.class.getName()).log
(Level.SEVERE, null, ex);
}
}
124
Chapter 5: Enrollment Service
LoadEnrolledDeviceUser
Loads the enrollment User for the specified device. If DeviceID is known then send only DeviceID. If device ID is unknown
then device type and DeviceUid should be sent.
Request Parameters:
1. DeviceEntity
2. AWOperationContext
125
Chapter 5: Enrollment Service
Response Elements:
EnrollmentUserEntity
client.Close();
}
catch (Exception ex)
{
throw ex;
}
}
126
Chapter 5: Enrollment Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
// End Point
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
InputStream keyInput = new FileInputStream(keyStoreFile);
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
trustStore.load(keyInput, trustStorePassword.toCharArray());
keyInput.close();
X509SSLContextFactory sslContextFactory = new X509SSLContextFactory
(keyStore, keyStrorePassword.toCharArray(), trustStore); SSLContext
sslClientContext = sslContextFactory.buildSSLContext();
stub._getServiceClient().getOptions().setProperty(
org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient().getOptions().setProperty
(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_PROTOCOL_HANDLER,
myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
EnrollmentServiceEndpointStub.ServiceIdentity serviceIdentity = new
EnrollmentServiceEndpointStub.ServiceIdentity();
127
Chapter 5: Enrollment Service
serviceIdentity.setName("Administrator");
EnrollmentServiceEndpointStub.AWOperationContext operationContext =
new EnrollmentServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
EnrollmentServiceEndpointStub.DeviceEntity deviceEntity=new
EnrollmentServiceEndpointStub.DeviceEntity();
EnrollmentServiceEndpointStub.EntityKey entityKey=new
EnrollmentServiceEndpointStub.EntityKey();
entityKey.setValue(4242);
deviceEntity.setId(entityKey);
EnrollmentServiceEndpointStub.LoadEnrolledDeviceUser
loadEnrolledDeviceUser=new
EnrollmentServiceEndpointStub.LoadEnrolledDeviceUser();
loadEnrolledDeviceUser.setOperationContextTransport(operationContext);
loadEnrolledDeviceUser.setDeviceEntityTransport(deviceEntity);
stub.loadEnrolledDeviceUser(loadEnrolledDeviceUser);
}
catch (Exception ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
128
Chapter 6:
Location Group Service
Load 130
Save 134
139
Search 140
DeleteLocationGroup 144
DeleteUserInGroup 148
ProvisionLocationGroup 151
LoadGroupAuthenticationTypes 155
GetEnrollmentStatusForLg 158
161
LoadHierarchy 162
129
Chapter 6: Location Group Service
Load
This API loads the locationGroup based on the locationGroup ID.
Request Parameters:
Response Elements:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LocationGroup.LocationGroupService;
namespace LocationGroup
{
class Program
{
static void Main(string[] args)
{
try
{
// Create an instance of LocationGroupServiceClient
LocationGroupServiceClient client = new LocationGroupServiceClient
();
130
Chapter 6: Location Group Service
// Location Group ID
const int locationGroup = 7;
131
Chapter 6: Location Group Service
C# Sample Code
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks"; InputStream
keyInput = new FileInputStream(keyStoreFile);
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
trustStore.load(keyInput, trustStorePassword.toCharArray());
keyInput.close();
stub._getServiceClient().getOptions().setProperty
(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient().getOptions().setProperty
(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_PROTOCOL_HANDLER,
myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
132
Chapter 6: Location Group Service
serviceIdentity.setName("Administrator");
LocationGroupServiceEndpointStub.AWOperationContext operationContext =
new LocationGroupServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
LocationGroupServiceEndpointStub.EntityKey entityKey=new
LocationGroupServiceEndpointStub.EntityKey();
entityKey.setValue(7);
LocationGroupServiceEndpointStub.Load load=new
LocationGroupServiceEndpointStub.Load();
load.setOperationContext(operationContext);
load.setLocationGroupEntity(entityKey);
stub.load(load);
}
catch (Exception ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
133
Chapter 6: Location Group Service
Save
Creates the location group in the DB.
Request Parameters:
1. LocationGroupEntity
2. AWOperationContext
134
Chapter 6: Location Group Service
Response Elements:
// Set LocationGroupType
//This value should be present in 'LocationGroupType' table in DB
Id = new EntityKey {Value = (int) 1},
Text = "Test",
Value = "Test"
};
locationGroupEntity.ParentLocationGroupReference = new
ConcurrentEntityReference
{
// Assign parent LG ID Id = new EntityKey
{
135
Chapter 6: Location Group Service
Value = 7
},
ReferenceConcurrencyId = new ConcurrencyIdentifier(),ReferenceType =
"Test"
};
Guid();
locationGroupEntity.ParentLocationGroupReference.ReferenceConcurrency
Id.Value = new locationGroupEntity.ChildLocationGroupReferences = new
ConcurrentEntityReference[0];
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
136
Chapter 6: Location Group Service
keyStore.load(keyInput, keyStrorePassword.toCharArray());
keyInput.close();
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
KeyStore trustStore = KeyStore.getInstance("JKS");
trustStore.load(keyInput, trustStorePassword.toCharArray());
keyInput.close();
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient().getOptions().setProperty
(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_PROTOCOL_HANDLER,
myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
LocationGroupServiceEndpointStub.ServiceIdentity serviceIdentity = new
LocationGroupServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
LocationGroupServiceEndpointStub.AWOperationContext operationContext =
new LocationGroupServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
LocationGroupServiceEndpointStub.LocationGroupEntity
locationGroupEntity =new
LocationGroupServiceEndpointStub.LocationGroupEntity();
locationGroupEntity.setName("unique");
137
Chapter 6: Location Group Service
LocationGroupServiceEndpointStub.LocationGroupTypeListItem
locationGroupTypeListItem=new
LocationGroupServiceEndpointStub.LocationGroupTypeListItem();
locationGroupTypeListItem.setText("test");
locationGroupTypeListItem.setValue("test");
entityKey.setValue(1);
locationGroupTypeListItem.setId(entityKey);
locationGroupEntity.setLocationGroupType(locationGroupTypeListItem);
LocationGroupServiceEndpointStub.ConcurrentEntityReference
concurrentEntityReference=new
LocationGroupServiceEndpointStub.ConcurrentEntityReference();
parentEntityKey.setValue(7);
concurrentEntityReference.setId(parentEntityKey);
LocationGroupServiceEndpointStub.ConcurrencyIdentifier
concurrencyIdentifier=new
LocationGroupServiceEndpointStub.ConcurrencyIdentifier();
guid.setGuid(UUID.randomUUID().toString());
concurrencyIdentifier.setValue(guid);
concurrentEntityReference.setReferenceConcurrencyId
(concurrencyIdentifier); concurrentEntityReference.setReferenceType
("Test");
locationGroupEntity.setParentLocationGroupReference
(concurrentEntityReference);
LocationGroupServiceEndpointStub.ArrayOfConcurrentEntityReference
arrayOfConcurrentEntityReference=new
LocationGroupServiceEndpointStub.ArrayOfConcurrentEntityReference();
138
Chapter 6: Location Group Service
locationGroupEntity.setChildLocationGroupReferences
(arrayOfConcurrentEntityReference);
LocationGroupServiceEndpointStub.CountryListItem countryListItem=new
LocationGroupServiceEndpointStub.CountryListItem();
countryEntityKey.setValue(1);
countryListItem.setId(countryEntityKey);
countryListItem.setText("");
countryListItem.setValue("");
locationGroupEntity.setCountry(countryListItem);
locationGroupEntity.setCustomerCode("newcust2");
LocationGroupServiceEndpointStub.Save save=new
LocationGroupServiceEndpointStub.Save();
save.setLocationGroupEntity(locationGroupEntity);
save.setOperationContext(operationContext);
stub.save(save);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
139
Chapter 6: Location Group Service
Search
Search the Location Group based on the search criteria
Request Parameters:
1. LocationGroupSearchCriteria
2. AWOperationContext
Response Elements:
Array of LocationGroupSearchResult object.
140
Chapter 6: Location Group Service
groupSearchCriteria.IncludeSubTree = true;
var result = client.Search(groupSearchCriteria, context);
client.Close();
}
catch (Exception ex)
{
throw ex;
}
}
141
Chapter 6: Location Group Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks"; KeyStore trustStore
= KeyStore.getInstance("JKS");
keyInput.close();
X509SSLContextFactory sslContextFactory = new X509SSLContextFactory
(keyStore, keyStrorePassword.toCharArray(), trustStore);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
142
Chapter 6: Location Group Service
try {
LocationGroupServiceEndpointStub.ServiceIdentity serviceIdentity = new
LocationGroupServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
LocationGroupServiceEndpointStub.AWOperationContext operationContext =
new LocationGroupServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
LocationGroupServiceEndpointStub.LocationGroupSearchCriteria
locationGroupSearchCriteria = new
LocationGroupServiceEndpointStub.LocationGroupSearchCriteria();
entityKey.setValue(7);
locationGroupSearchCriteria.setRootLocationGroupKey(entityKey);
locationGroupSearchCriteria.setCustomerCode("newcust11");
locationGroupSearchCriteria.setIncludeSubTree(true);
search.setSearchCriteria(locationGroupSearchCriteria);
search.setOperationContext(operationContext); stub.search(search);
}
143
Chapter 6: Location Group Service
DeleteLocationGroup
API to delete the LocationGroup from the DB.
Request Parameters:
1. EntityKey
2. AWOperationContext
Response Elements:
Boolean value to indicate success/failure.
144
Chapter 6: Location Group Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
145
Chapter 6: Location Group Service
trustStore.load(keyInput, trustStorePassword.toCharArray());
keyInput.close();
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER, myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
LocationGroupServiceEndpointStub.ServiceIdentity serviceIdentity = new
LocationGroupServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
LocationGroupServiceEndpointStub.AWOperationContext operationContext =
new LocationGroupServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
entityKey.setValue(3867);
LocationGroupServiceEndpointStub.DeleteLocationGroup
deleteLocationGroup = new
LocationGroupServiceEndpointStub.DeleteLocationGroup();
deleteLocationGroup.setLocationGroupEntity(entityKey);
146
Chapter 6: Location Group Service
deleteLocationGroup.setOperationContext(operationContext);
stub.deleteLocationGroup(deleteLocationGroup);
}
147
Chapter 6: Location Group Service
DeleteUserInGroup
API to delete the Admin Users in the LocationGroup.
Request Parameters:
1. EntityKey
2. AWOperationContext
Response Elements:
Boolean value to indicate success/failure.
148
Chapter 6: Location Group Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
// End Point
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
InputStream keyInput = new FileInputStream(keyStoreFile);
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
149
Chapter 6: Location Group Service
stub._getServiceClient().getOptions().setProperty(
org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient().getOptions().setProperty(
org.apache.axis2.transport.http.HTTPConstants.CUSTOM_PROTOCOL_HANDLER,
myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
LocationGroupServiceEndpointStub.ServiceIdentity serviceIdentity = new
LocationGroupServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
LocationGroupServiceEndpointStub.AWOperationContext operationContext =
new LocationGroupServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
entityKey.setValue(3867);
LocationGroupServiceEndpointStub.DeleteUserInGroup
deleteUserInGroup=new
LocationGroupServiceEndpointStub.DeleteUserInGroup();
deleteUserInGroup.setLocationGroup(entityKey);
deleteUserInGroup.setOperationContext(operationContext);
150
Chapter 6: Location Group Service
stub.deleteUserInGroup(deleteUserInGroup);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
ProvisionLocationGroup
Does the provisioning related actions for LG like suspend/allow enrollment, lock/unlock users.
Request Parameters:
1. ProvisionGroupRequest
Response Elements:
No response
151
Chapter 6: Location Group Service
client.ProvisionLocationGroup(provisionRequest, context);
client.Close();
}
catch (Exception ex)
{
throw ex;
}
}
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
// End Point
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
152
Chapter 6: Location Group Service
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
trustStore.load(keyInput, trustStorePassword.toCharArray());
keyInput.close();
stub._getServiceClient().getOptions().setProperty
(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient().getOptions().setProperty
(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_PROTOCOL_HANDLER,
myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
serviceIdentity.setName("Administrator");
LocationGroupServiceEndpointStub.AWOperationContext operationContext =
new LocationGroupServiceEndpointStub.AWOperationContext();
153
Chapter 6: Location Group Service
operationContext.setIdentity(serviceIdentity);
LocationGroupServiceEndpointStub.ProvisionGroupRequest
provisionGroupRequest=new
LocationGroupServiceEndpointStub.ProvisionGroupRequest();
provisionGroupRequest.setActivationCode("newcust11");
LocationGroupServiceEndpointStub.ProvisionGroupDeviceAction
provisionGroupDeviceAction=ProvisionGroupDeviceAction.None;
provisionGroupRequest.setDeviceAction(provisionGroupDeviceAction);
LocationGroupServiceEndpointStub.ProvisionGroupUserAction
provisionGroupUserAction=ProvisionGroupUserAction.LockUsers;
provisionGroupRequest.setUserAction(provisionGroupUserAction);
LocationGroupServiceEndpointStub.ProvisionLocationGroup
provisionLocationGroup=new
LocationGroupServiceEndpointStub.ProvisionLocationGroup();
provisionLocationGroup.setOperationContext(operationContext);
provisionLocationGroup.setLocationGroupProvision
(provisionGroupRequest);
stub.provisionLocationGroup(provisionLocationGroup);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
154
Chapter 6: Location Group Service
LoadGroupAuthenticationTypes
This is an API to get the enrollment authentication type list configured for a location group. Location Group is based on
customer code.
Request Parameters:
1. LocationgroupEntity with customer code.
2. AWOperationContext
Response Elements:
Returns an array of EnrollmentUserAuthenticationType
155
Chapter 6: Location Group Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
156
Chapter 6: Location Group Service
trustStore.load(keyInput, trustStorePassword.toCharArray());
keyInput.close();
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty( org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER, myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
LocationGroupServiceEndpointStub.ServiceIdentity serviceIdentity = new
LocationGroupServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
LocationGroupServiceEndpointStub.AWOperationContext operationContext =
new LocationGroupServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
LocationGroupServiceEndpointStub.LocationGroupEntity
locationGroupEntity = new
LocationGroupServiceEndpointStub.LocationGroupEntity();
locationGroupEntity.setCustomerCode("newcust11");
LocationGroupServiceEndpointStub.LoadGroupAuthenticationTypes
loadGroupAuthenticationTypes = new
LocationGroupServiceEndpointStub.LoadGroupAuthenticationTypes();
157
Chapter 6: Location Group Service
loadGroupAuthenticationTypes.setOperationContext(operationContext);
loadGroupAuthenticationTypes
.setLocationGroupEntity(locationGroupEntity);
}
GetEnrollmentStatusForLg
Gets the enrollment suspended status for the list of Location Groups.
Request Parameters:
1. Array of integer of locationGroup IDs for which enrollmentStatus is required. Int[]
2. AWOperationContext
Response Elements:
Array of Locationgroup Entity for all the LG IDs sent in input.
158
Chapter 6: Location Group Service
// Assign LG IDs
var locationGroupIds = new int[3];
locationGroupIds[0] = 7;
locationGroupIds[1] = 630;
locationGroupIds[2] = 631;
159
Chapter 6: Location Group Service
String endPointURI =
"https://qa10ssl.AirWatchportals.com/AWBasicHttpService/LocationGroupServiceE
ndpoint.svc";
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
// End Point
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
InputStream keyInput = new FileInputStream(keyStoreFile);
String keyStrorePassword = "wif1Admin";
keyStore.load(keyInput, keyStrorePassword.toCharArray());
keyInput.close();
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
KeyStore trustStore = KeyStore.getInstance("JKS");
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
160
Chapter 6: Location Group Service
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER, myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
LocationGroupServiceEndpointStub.ServiceIdentity serviceIdentity = new
LocationGroupServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
LocationGroupServiceEndpointStub.AWOperationContext operationContext =
new LocationGroupServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
LocationGroupServiceEndpointStub.GetEnrollmentStatusForLg
getEnrollmentStatusForLg = new
LocationGroupServiceEndpointStub.GetEnrollmentStatusForLg();
getEnrollmentStatusForLg.setLocationGroupIDs(arrayOfint);
getEnrollmentStatusForLg.setOperationContext(operationContext);
LocationGroupServiceEndpointStub.GetEnrollmentStatusForLgResponse
getEnrollmentStatusForLgResponse = stub.getEnrollmentStatusForLg
(getEnrollmentStatusForLg);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
161
Chapter 6: Location Group Service
LoadHierarchy
Loads a hierarchical listing of all instances defined for an AirWatch user. The name specified in the operation context is
considered as AirWatch user and it loads the LG hierarchy based on user’s LG.
Request Parameters:
1. AWOperationContext
Response Elements:
162
Chapter 6: Location Group Service
163
Chapter 6: Location Group Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
KeyStore trustStore = KeyStore.getInstance("JKS");
trustStore.load(keyInput, trustStorePassword.toCharArray());
keyInput.close();
stub._getServiceClient().getOptions().setProperty
(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient().getOptions().setProperty
(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_PROTOCOL_
HANDLER,myProtocolHandler);
164
Chapter 6: Location Group Service
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
serviceIdentity.setName("Administrator");
LocationGroupServiceEndpointStub.AWOperationContext operationContext =
new LocationGroupServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
LocationGroupServiceEndpointStub.LoadHierarchy loadHierarchy=new
LocationGroupServiceEndpointStub.LoadHierarchy();
loadHierarchy.setOperationContext(operationContext);
stub.loadHierarchy(loadHierarchy);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
165
Chapter 7:
Location Services
Load 167
Save 170
Search 176
List 180
166
Chapter 7: Location Services
Load
Loads the entire location Entity based on the LocationID.
Request Parameters:
1. LocationID
2. AWOperationContext
Response Elements:
LocationEntity
167
Chapter 7: Location Services
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile="D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
InputStream keyInput = new FileInputStream(keyStoreFile);
String keyStrorePassword="wif1Admin";
keyStore.load(keyInput, keyStrorePassword.toCharArray());
keyInput.close();
String
trustStoreFile="D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
168
Chapter 7: Location Services
String trustStorePassword="changeit";
trustStore.load(keyInput, trustStorePassword.toCharArray());
keyInput.close();
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER, myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
serviceIdentity.setName("Administrator");
operationContext.setIdentity(serviceIdentity);
entityKey.setValue(4586);
load.setEntityKey(entityKey); load.setOperationContext
(operationContext);
stub.load(load);
}
169
Chapter 7: Location Services
Save
Creates a location in the database with the specified values.
Request Parameters:
1. LocationEntity
2. AWOperationContext
170
Chapter 7: Location Services
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Location.LocationService;
namespace Location
{
class Program
{
static void Main(string[] args)
{
try
{
// Create an instance of LocationGroupServiceClient.
// Location Group ID
const int locationGroup = 7;
if (!string.IsNullOrEmpty(savedLocationEntity.InternalName))
171
Chapter 7: Location Services
{
Console.WriteLine("Location is successfully saved. Press any
key to continue..");
Console.ReadLine();
}
else
{
Console.WriteLine("Location save failed. Please try again.
Press any key to continue..");
Console.ReadLine();
}
}
catch (Exception)
{
}
}
}
}
172
Chapter 7: Location Services
// End Point
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
keyStore.load(keyInput, keyStrorePassword.toCharArray());
keyInput.close();
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
trustStore.load(keyInput, trustStorePassword.toCharArray());
keyInput.close();
X509SSLContextFactory sslContextFactory = new X509SSLContextFactory
(keyStore, keyStrorePassword.toCharArray(), trustStore);
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER,myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
173
Chapter 7: Location Services
try {
LocationServiceEndpointStub.ServiceIdentity serviceIdentity = new
LocationServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
operationContext.setIdentity(serviceIdentity);
LocationServiceEndpointStub.LocationEntity locationEntity=new
LocationServiceEndpointStub.LocationEntity();
LocationServiceEndpointStub.ConcurrentEntityReference
concurrentEntityReference=new
LocationServiceEndpointStub.ConcurrentEntityReference();
LocationServiceEndpointStub.EntityKey locationEntityKey=new
LocationServiceEndpointStub.EntityKey();
locationEntityKey.setValue(7);
concurrentEntityReference.setId(locationEntityKey);
LocationServiceEndpointStub.ConcurrencyIdentifier
concurrencyIdentifier=new
LocationServiceEndpointStub.ConcurrencyIdentifier();
guid.setGuid(UUID.randomUUID().toString());
concurrencyIdentifier.setValue(guid);
concurrentEntityReference.setReferenceConcurrencyId
(concurrencyIdentifier);
locationEntity.setParentLocationGroupReference
(concurrentEntityReference);
LocationServiceEndpointStub.LocationTypeListItem
locationTypeListItem=new
LocationServiceEndpointStub.LocationTypeListItem();
LocationServiceEndpointStub.EntityKey locationTypeEntityKey=new
LocationServiceEndpointStub.EntityKey();
locationTypeEntityKey.setValue(3);
locationTypeListItem.setId(locationTypeEntityKey);
174
Chapter 7: Location Services
locationEntity.setLocationType(locationTypeListItem);
LocationServiceEndpointStub.LocationStatusListItem
locationStatusListItem=new
LocationServiceEndpointStub.LocationStatusListItem();
LocationServiceEndpointStub.EntityKey locationStatusEntityKey=new
LocationServiceEndpointStub.EntityKey();
locationStatusEntityKey.setValue(10);
locationStatusListItem.setId(locationStatusEntityKey);
locationEntity.setStatus(locationStatusListItem);
locationEntity.setLocationCode("6666");
locationEntity.setInternalName("Location Service");
LocationServiceEndpointStub.Save save=new
LocationServiceEndpointStub.Save();
save.setLocationEntity(locationEntity);
save.setOperationContext(operationContext);
LocationServiceEndpointStub.SaveResponse saveResponse=stub.save(save);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
175
Chapter 7: Location Services
Search
Searches the location based on the search criteria.
Request Parameters:
1. LocationSearchCriteria
2. AWOperationContext
Response Elements:
Array of LocationSearchResult:
176
Chapter 7: Location Services
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile="D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
String keyStrorePassword="wif1Admin";
keyStore.load(keyInput, keyStrorePassword.toCharArray());
keyInput.close();
String
trustStoreFile="D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
177
Chapter 7: Location Services
String trustStorePassword="changeit";
trustStore.load(keyInput, trustStorePassword.toCharArray());
keyInput.close();
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
LocationServiceEndpointStub.ServiceIdentity serviceIdentity = new
LocationServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
operationContext.setIdentity(serviceIdentity);
LocationServiceEndpointStub.LocationSearchCriteria
locationSearchCriteria = new
LocationServiceEndpointStub.LocationSearchCriteria();
locationSearchCriteria.setInternalName("Location #1000");
locationSearchCriteria.setStoreNumber("1000");
178
Chapter 7: Location Services
search.setOperationContext(operationContext)
search.setSearchCriteria(locationSearchCriteria);
stub.search(search);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
179
Chapter 7: Location Services
List
Returns the list of Location Entities under the location Group for which the admin User belongs to. The admin user name
is picked from the name of the call context.
Request Parameters:
1. AWOperationContext
Response Elements:
Array of LocationSearchResult:
180
Chapter 7: Location Services
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
// End Point
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
InputStream keyInput = new FileInputStream(keyStoreFile);
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
181
Chapter 7: Location Services
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER, myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
LocationServiceEndpointStub.ServiceIdentity serviceIdentity = new
LocationServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
LocationServiceEndpointStub.AWOperationContext operationContext = new
LocationServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
entityKey.setValue(4586);
list.setOperationContext(operationContext);
stub.list(list);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
182
Chapter 7: Location Services
}
}
183
Chapter 8:
Pick List Service
Overview 185
LoadLocationGroupTypeList 185
LoadLocationTypeList 189
LoadLocationStatusList 192
LoadAddressTypeList 194
LoadCountryList 197
LoadDeviceCategoryList 200
LoadOwnershipList 202
184
Chapter 8: Pick List Service
Overview
This service provides methods to load lists of elements like ownership types, device types, and country codes from the
application configuration. These are typically used as parameters to other service requests. UI based applications may
use these methods to populate drop-down menus.
LoadLocationGroupTypeList
Loads the locationgroup Types from DB
Request Parameters:
None
Response Elements:
185
Chapter 8: Pick List Service
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Picklist.PicklistService;
namespace Picklist
{
class LoadPickLists
{
static void Main(string[] args)
{
try
{
// Create an instance of PicklistServiceClient
PicklistServiceClient client = new PicklistServiceClient();
186
Chapter 8: Pick List Service
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
trustStore.load(keyInput, trustStorePassword.toCharArray());
keyInput.close();
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER, myProtocolHandler);
187
Chapter 8: Pick List Service
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
PicklistServiceEndpointStub.LoadLocationGroupTypeList
loadLocationGroupTypeList = new
PicklistServiceEndpointStub.LoadLocationGroupTypeList();
PicklistServiceEndpointStub.LoadLocationGroupTypeListResponse
loadLocationGroupTypeListResponse = stub.loadLocationGroupTypeList
(loadLocationGroupTypeList);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null,
ex);
}
}
188
Chapter 8: Pick List Service
LoadLocationTypeList
Loads the location Types from DB
Request Parameters:
None
Response Elements:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Picklist.PicklistService;
namespace Picklist
{
class LoadPickLists
{
static void Main(string[] args)
{
try
{
// Create an instance of PicklistServiceClient
PicklistServiceClient client = new PicklistServiceClient();
189
Chapter 8: Pick List Service
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
KeyStore trustStore = KeyStore.getInstance("JKS");
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER, myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
PicklistServiceEndpointStub.LoadLocationTypeList
190
Chapter 8: Pick List Service
loadLocationTypeList = new
PicklistServiceEndpointStub.LoadLocationTypeList();
PicklistServiceEndpointStub.LoadLocationTypeListResponse
loadLocationTypeListResponse = stub.loadLocationTypeList
(loadLocationTypeList);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null,
ex);
}
}
191
Chapter 8: Pick List Service
LoadLocationStatusList
Loads the location status from DB
Request Parameters:
None
Response Elements:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Picklist.PicklistService;
namespace Picklist
{
class LoadPickLists
{
static void Main(string[] args)
{
try
{
// Create an instance of PicklistServiceClient
PicklistServiceClient client = new PicklistServiceClient();
var locationStatusList = client.LoadLocationStatusList();
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}
192
Chapter 8: Pick List Service
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
InputStream keyInput = new FileInputStream(keyStoreFile);
keyStore.load(keyInput, keyStrorePassword.toCharArray());
keyInput.close();
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER, myProtocolHandler);
193
Chapter 8: Pick List Service
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
PicklistServiceEndpointStub.LoadLocationStatusList
loadLocationStatusList = new
PicklistServiceEndpointStub.LoadLocationStatusList();
PicklistServiceEndpointStub.LoadLocationStatusListResponse
loadLocationGroupTypeListResponse = stub.loadLocationStatusList
(loadLocationStatusList);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null,
ex);
}
}
LoadAddressTypeList
Loads the AddressTypes from DB
Request Parameters:
None
Response Elements:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Picklist.PicklistService;
194
Chapter 8: Pick List Service
namespace Picklist
{
class LoadPickLists
{
static void Main(string[] args)
{
try
{
// Create an instance of PicklistServiceClient
PicklistServiceClient client = new PicklistServiceClient();
195
Chapter 8: Pick List Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
KeyStore trustStore = KeyStore.getInstance("JKS");
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER, myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
196
Chapter 8: Pick List Service
PicklistServiceEndpointStub.LoadAddressTypeList loadAddressTypeList =
new PicklistServiceEndpointStub.LoadAddressTypeList();
PicklistServiceEndpointStub.LoadAddressTypeListResponse
loadAddressTypeListResponse = stub.loadAddressTypeList
(loadAddressTypeList);
}
LoadCountryList
Loads all country details from DB
Request Parameters:
None
Response Elements:
197
Chapter 8: Pick List Service
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Picklist.PicklistService;
namespace Picklist
{
class LoadPickLists
{
static void Main(string[] args)
{
try
{
// Create an instance of PicklistServiceClient
PicklistServiceClient client = new PicklistServiceClient();
var countryList = client.LoadCountryList();
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
InputStream keyInput = new FileInputStream(keyStoreFile);
198
Chapter 8: Pick List Service
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
KeyStore trustStore = KeyStore.getInstance("JKS");
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER, myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
PicklistServiceEndpointStub.LoadCountryList loadCountryList = new
PicklistServiceEndpointStub.LoadCountryList();
PicklistServiceEndpointStub.LoadCountryListResponse
loadCountryListResponse = stub.loadCountryList(loadCountryList);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
199
Chapter 8: Pick List Service
LoadDeviceCategoryList
Loads the device category from DB
Request Parameters:
None
Response Elements:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Picklist.PicklistService;
namespace Picklist
{
class LoadPickLists
{
static void Main(string[] args)
{
try
{
// Create an instance of PicklistServiceClient
PicklistServiceClient client = new PicklistServiceClient();
var deviceCategoryList = client.LoadDeviceCategoryList();
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}
200
Chapter 8: Pick List Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
InputStream keyInput = new FileInputStream(keyStoreFile);
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
KeyStore trustStore = KeyStore.getInstance("JKS");
201
Chapter 8: Pick List Service
PicklistServiceEndpointStub.LoadDeviceCategoryListResponse
loadDeviceCategoryListResponse = stub.loadDeviceCategoryList
(loadDeviceCategoryList);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
LoadOwnershipList
Loads all the ownerships available in DB
Request Parameters:
None
Response Elements:
202
Chapter 8: Pick List Service
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Picklist.PicklistService;
namespace Picklist
{
class LoadPickLists
{
static void Main(string[] args)
{
try
{
}
// Create an instance of PicklistServiceClient
PicklistServiceClient client = new PicklistServiceClient();
var ownershipList = client.LoadOwnershipList();
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
InputStream keyInput = new FileInputStream(keyStoreFile);
203
Chapter 8: Pick List Service
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
trustStore.load(keyInput, trustStorePassword.toCharArray());
keyInput.close();
X509SSLContextFactory sslContextFactory = new X509SSLContextFactory
(keyStore, keyStrorePassword.toCharArray(), trustStore);
SSLContext sslClientContext = sslContextFactory.buildSSLContext();
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER, myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
PicklistServiceEndpointStub.LoadOwnershipList loadOwnershipList = new
PicklistServiceEndpointStub.LoadOwnershipList();
PicklistServiceEndpointStub.LoadOwnershipListResponse
loadCountryListResponse = stub.loadOwnershipList(loadOwnershipList);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
204
Chapter 9:
User Service
Load 206
Save 210
Search 212
List 216
AddUserToRole 218
CreateAdminUser 223
DeleteAdminUser 226
GetUsersInGroup 229
ResetAdminUser 234
205
Chapter 9: User Service
Load
This API loads the user Entity based on the User ID.
Request Parameters:
1. UserID
2. AWOperationContext
Response Elements:
1. UserEntity
206
Chapter 9: User Service
try
{
var context = new AWOperationContext()
{
Identity = new ServiceIdentity() { Name = "Administrator" }
};
UserService.UserServiceClient serviceClient = new UserServiceClient();
serviceClient.Open();
var userID = new EntityKey();
userID.Value = 4;
var userResult = serviceClient.Load(userID, context);
serviceClient.Close();
}
catch (Exception ex)
{
throw ex;
}
}
207
Chapter 9: User Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
KeyStore trustStore = KeyStore.getInstance("JKS");
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER, myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
208
Chapter 9: User Service
serviceIdentity.setName("Administrator");
operationContext.setIdentity(serviceIdentity);
entityKey.setValue(639);
UserServiceEndpointStub.Load load = new UserServiceEndpointStub.Load
();
load.setOperationContext(operationContext);
load.setEntityKey(entityKey);
209
Chapter 9: User Service
Save
This API is used to update the information of any Core User. New users cannot be created using this API. For creating new
admin-user use CreateAdminUser API explained later.
Request Parameters:
1. UserEntity
2. AWOperationContext
210
Chapter 9: User Service
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Users.UserService;
namespace Users
{
class UserService
{
static void Main(string[] args)
{
try
{
// Create an instance of UserServiceClient
UserServiceClient client = new UserServiceClient();
userEntity.MobileTelephone = "9343434343";
userEntity.Fax = "9676767676";
userEntity.EmailAddress = "[email protected]";
211
Chapter 9: User Service
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}
Search
Searches for the Core User based on the search criteria.
Request Parameters:
1. UserSearchCriteria
2. AWOperationContext
Response Elements:
212
Chapter 9: User Service
213
Chapter 9: User Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
InputStream keyInput = new FileInputStream(keyStoreFile);
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
Boolean.FALSE);
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER, myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
UserServiceEndpointStub.ServiceIdentity serviceIdentity = new
UserServiceEndpointStub.ServiceIdentity();
214
Chapter 9: User Service
serviceIdentity.setName("Administrator");
UserServiceEndpointStub.AWOperationContext operationContext = new
UserServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
userSearchCriteria.setUserName("Administrator");
215
Chapter 9: User Service
List
Lists all AirWatch user search results accessible to an AirWatch User in the API call context.
Request Parameters:
1. AWOperationContext
Response Elements:
Array of UserEntity objects.
216
Chapter 9: User Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
keyStore.load(keyInput, keyStrorePassword.toCharArray());
keyInput.close();
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
217
Chapter 9: User Service
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
UserServiceEndpointStub.ServiceIdentity serviceIdentity = new
UserServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
UserServiceEndpointStub.AWOperationContext operationContext = new
UserServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
UserServiceEndpointStub.List list = new UserServiceEndpointStub.List
();
list.setOperationContext(operationContext);
AddUserToRole
Associates a user with a location group and role.
If IsPrimaryRole is set to true, it updates the coreUser’s locationgroup to the specified locationGroup.
218
Chapter 9: User Service
Request Parameters:
1. LocationGroupID
2. Role ID
3. User ID
4. IsPrimaryRole
5. AWOperationContext
Response Elements:
No response
219
Chapter 9: User Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
220
Chapter 9: User Service
trustStore.load(keyInput, trustStorePassword.toCharArray());
keyInput.close();
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
UserServiceEndpointStub.ServiceIdentity serviceIdentity = new
UserServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
UserServiceEndpointStub.AWOperationContext operationContext = new
UserServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
roleEntityKey.setValue(92);
userEntityKey.setValue(3966); UserServiceEndpointStub.AddUserToRole
addUserToRole = new UserServiceEndpointStub.AddUserToRole();
221
Chapter 9: User Service
addUserToRole.setOperationContext(operationContext);
addUserToRole.setLocationGroupKey(locationEntityKey);
addUserToRole.setRoleKey(roleEntityKey); addUserToRole.setUserKey
(userEntityKey);
stub.addUserToRole(addUserToRole);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
222
Chapter 9: User Service
CreateAdminUser
This method creates an admin user in the specified Location group. The User name should be unique and creating
duplicate user names are not allowed.
Request Parameters:
Response Elements:
After successful creation of admin user, CoreUserID is updated to the object and returned.
223
Chapter 9: User Service
//
private void CreateAdminUser(AWTrialRequest awTrialRequest, int
locationGroupId)
{
var userEntity = new UserEntity
{
UserName = “Examplename”,
Company = “CompanyXYZ”,
EmailAddress = “[email protected]”,
FirstName = “John”,
LocationGroupReference = new ConcurrentEntityReference
{
Id = locationGroupId }
EntityKey { Value = locationGroupId
},
Password = CryptUtil.CreateRandomToken(6),
MobileTelephone = “8095504334”,
TimeZoneId = 1, CultureId = 1,
ContactType = 1,
};
var operationContext = new AWOperationContext
{
Identity = new ServiceIdentity { Name = "Administrator" }
};
var userServiceClient = new UserServiceClient();
userServiceClient.CreateAdminUser(userEntity, operationContext);
}
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
224
Chapter 9: User Service
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
KeyStore trustStore = KeyStore.getInstance("JKS");
stub._getServiceClient()
.getOptions()
.setProperty(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER, myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
UserServiceEndpointStub.ServiceIdentity serviceIdentity = new
UserServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
UserServiceEndpointStub.AWOperationContext operationContext = new
UserServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
userEntity.setUserName("testexample"); userEntity.setCompany
("CompanyXYZ"); userEntity.setEmailAddress("[email protected]");
userEntity.setFirstName("Jhon"); userEntity.setPassword
("password"); userEntity.setMobileTelephone("8095504334");
userEntity.setTimeZoneId(1); userEntity.setContactType(1);
userEntity.setCultureId(1);
UserServiceEndpointStub.ConcurrentEntityReference
concurrentEntityReference = new
UserServiceEndpointStub.ConcurrentEntityReference();
225
Chapter 9: User Service
Note:
l ConsoleMenuLayoutIsOverLay : False: Classic , True: Overlay
l DefaultLandingPage, ContactType, and UserRoleID: Default value will be used if not data is set.
DeleteAdminUser
Deletes the Admin User from the database. Admin User can be deleted using username.
Request Parameters:
1. UserEntity
226
Chapter 9: User Service
2. AWOperationContext
227
Chapter 9: User Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks"; KeyStore trustStore
= KeyStore.getInstance("JKS");
228
Chapter 9: User Service
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
UserServiceEndpointStub.ServiceIdentity serviceIdentity = new
UserServiceEndpointStub.ServiceIdentity();
serviceIdentity.setName("Administrator");
UserServiceEndpointStub.AWOperationContext operationContext = new
UserServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
UserServiceEndpointStub.UserEntity userEntity = new
UserServiceEndpointStub.UserEntity();
userEntity.setUserName("testexample");
UserServiceEndpointStub.DeleteAdminUser deleteAdminUser = new
UserServiceEndpointStub.DeleteAdminUser();
deleteAdminUser.setOperationContext(operationContext);
deleteAdminUser.setUserEntity(userEntity); stub.deleteAdminUser
(deleteAdminUser);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null,
ex);
}
}
GetUsersInGroup
Gets all the admin users in the specified LocationGroup ID.
229
Chapter 9: User Service
Request Parameters:
1. LocationgroupID
2. AWOperationContext
Response Elements:
Array of User-Entity object.
230
Chapter 9: User Service
{
var context = new AWOperationContext()
{
Identity = new ServiceIdentity() { Name = "Administrator" }
};
UserService.UserServiceClient serviceClient = new UserServiceClient();
serviceClient.Open();
var locationGroupKey = new EntityKey();
locationGroupKey.Value = 659;
var userResult = serviceClient.GetUsersInGroup(locationGroupKey,
context);
serviceClient.Close();
}
catch (Exception ex)
{
throw ex;
}
}
231
Chapter 9: User Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
KeyStore trustStore = KeyStore.getInstance("JKS");
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
UserServiceEndpointStub.ServiceIdentity serviceIdentity = new
UserServiceEndpointStub.ServiceIdentity();
232
Chapter 9: User Service
serviceIdentity.setName("Administrator");
UserServiceEndpointStub.AWOperationContext operationContext = new
UserServiceEndpointStub.AWOperationContext();
operationContext.setIdentity(serviceIdentity);
UserServiceEndpointStub.EntityKey entityKey = new
UserServiceEndpointStub.EntityKey();
entityKey.setValue(639);
UserServiceEndpointStub.GetUsersInGroup getUsersInGroup = new
UserServiceEndpointStub.GetUsersInGroup();
getUsersInGroup.setOperationContext(operationContext);
getUsersInGroup.setUserEntity(entityKey);
UserServiceEndpointStub.GetUsersInGroupResponse
getUsersInGroupResponse = stub
.getUsersInGroup(getUsersInGroup);
}
catch (Exception ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null,
ex);
}
}
233
Chapter 9: User Service
ResetAdminUser
This API resets password and unlock the Admin user.
Request Parameters:
1. User Entity
2. AWOperationContext
Response Elements:
No response.
234
Chapter 9: User Service
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
EndpointReference targetEndPoint = new EndpointReference(endPointURI);
KeyStore keyStore = KeyStore.getInstance("JKS");
String keyStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\client.jks";
InputStream keyInput = new FileInputStream(keyStoreFile);
keyStore.load(keyInput, keyStrorePassword.toCharArray());
keyInput.close();
String trustStoreFile =
"D:\\AirWatch\\project\\ClientTest\\ssl\\server.jks";
KeyStore trustStore = KeyStore.getInstance("JKS");
235
Chapter 9: User Service
stub._getServiceClient().getOptions().setTo(targetEndPoint);
stub._getServiceClient()
.getOptions()
.setPropert(org.apache.axis2.transport.http.HTTPConstants.CUSTOM_
PROTOCOL_HANDLER, myProtocolHandler);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(120000);
try {
UserServiceEndpointStub.ServiceIdentity serviceIdentity = new
UserServiceEndpointStub.ServiceIdentity(); serviceIdentity.setName
("Administrator"); UserServiceEndpointStub.AWOperationContext
operationContext = new UserServiceEndpointStub.AWOperationContext
();
operationContext.setIdentity(serviceIdentity);
UserServiceEndpointStub.EntityKey entityKey = new
UserServiceEndpointStub.EntityKey();
entityKey.setValue(3988);
UserServiceEndpointStub.UserEntity userEntity = new
UserServiceEndpointStub.UserEntity();
userEntity.setId(entityKey);
UserServiceEndpointStub.ResetAdminUser resetAdminUser = new
UserServiceEndpointStub.ResetAdminUser();
resetAdminUser.setOperationContext(operationContext);
resetAdminUser.setUserEntity(userEntity); stub.resetAdminUser
(resetAdminUser);
}
catch (Exception ex)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null,
ex);
}
}
236
Chapter 10: Tables A: Catalog of Services
Chapter 10:
Tables A: Catalog of Services
Device Data Service
Service Method Type Description
Device Data Service LoadDeviceGpsDataForDateRange Query Loads recent GPS coordinates within the
given date range
LoadDeviceGpsDataForTimePeriod Query Loads recent GPS coordinates for the last
n days
LoadDeviceApplicationList Query Loads the applications for the device
LoadProvisioningProfiles Query Loads the provisioning profiles for a
device
LoadConfigurationProfiles Query Loads the configuration profiles for a
device
LoadDeviceMetricDetails Query Returns the Device and Device-Network
status details
LoadAdaptersByDevice Query Returns the network status details of the
device
ListCertificates Query Returns the certificates for a device
GetSecurityAuditDetails Query Returns the Security Audit information
for a device
237
Chapter 10: Tables A: Catalog of Services
Device Service
Service Method Type Description
Device Service Save Update Persists a Device
Load Query Loads a Device Record
Search Query Returns a Device matching a search
criteria
UpdateDevice Update Updates Device Information for a given
device
List Query Returns a list of all devices accessible to a
User
LockDevice Device Locks an enrolled Device remotely
Command
ClearPasscode Device Clears the passcode for an enrolled
Command Device
DeviceWipe Device Wipes an enrolled Device
Command
UnenrollDevice Device Unenrolls an enrolled Device
Command
SendMessage Device Sends text message to an enrolled
Command Device
GetDevicesByLocationGroup Query Gets all the devices in the specified
LocationGroupID
QueryDevice Query Queries the device
RemoveDevice Query Removes the specified device from DB
GetDevicesByIsCompromised Query Returns a device count for a location
group for various compromised status
GetDeviceSummaryByPasscode Query Returns a device count for a location
group for various passcode
GetDeviceSummaryByDataEncryption Query Returns a device count for a location
group for various data encryption
GetDeviceSummaryByOwnership Query Returns a device count for a location
group for various ownerships
GetDeviceSummaryByPlatform Query Returns a device count for a location
group for various platforms
238
Chapter 10: Tables A: Catalog of Services
Enrollment Service
Service Method Type Description
Enrollment Service RegisterEnrollmentUser Create Creates a new enrollment user
RegisterDeviceForUser Update Associates a device with an enrollment
user
RemoveEnrollmentUser Update Deletes the enrollment User
PublishUserProfiles Update Publishes profile for devices enrolled for
the user
LoadEnrolledDeviceUser Query Loads the user for device
239
Chapter 10: Tables A: Catalog of Services
Location Service
Service Method Type Description
Location Service Load Query Loads a location entity for the specified
identifier
Save Update Saves the specified Location entity.
Returns the updated entity
Search Query Gets a list of location search results based
on the specified location search criteria
List Query Return a list of all Location Entities
240
Chapter 10: Tables A: Catalog of Services
User Service
Service Method Type Description
User Service Load Query Loads a User from the Database
Save Update Persists a User
Search Query Finds one or more users matching a
search criteria
List Query Loads all Users list
ListRoles Query Lists all Security Roles for a given user
AddUserToRole Update Associates a user with a location group
and role
RemoveUserFromRole Update Removes a User's association to a Role at
a Location Group
CreateAdminUser Update Creates an Admin user in the specified
Location group
DeleteAdminUser Delete Deletes the admin user form DB
GetUsersInGroup Query Gets all the admin user in specified
location group
ResetAdminUser Update Resets the password and unlock the
useradmin
241