Add a Player to a Display Unit (SOAP)
This use case illustrates how to add a player to a display unit.
SOAP API Method Reference
To add a player to a display unit, use the following method: host_mgr_update.
PHP Code Sample
Note: The ID#s we use in these samples are for illustration purposes. They are invalid. Be sure to use your own ID#s for your integrations.
Copy
#!/usr/bin/php
<?php
## Add a player to a display unit
## Modify a host 69262182
##
## Usage: php host_mgr_update_v12 --id=playerId --domain=domainId --display_unit_id=diplayunitId
## Usage example : php host_mgr_update_v12 --id=123456789 --domain=987654321 --display_unit_id=123456789
include "soaplib.php";
include "cmdutil.php";
$options = get_arguments("id!","domain!","display_unit_id!");
$body = new stdClass();
$body -> id = $options["id"] ; # ID of your player
$body -> domain_id = $options["domain"] ; #ID of your domain
$body -> display_unit_id = $options["display_unit_id"] ; #ID of your display unit
$body -> discovery_status = 0 ;
$body -> name = "Host_attached_to_a_du_via_sdk" ;
$body -> volume = 75 ;
$response = performSimpleOperation("host", "update", 12, $body);
#echo json_encode($response);
?
Java Code Samples
Note: The ID#s we use in these samples are for illustration purposes. They are invalid. Be sure to use your own ID#s for your integrations.
Main.java
Copy
/*
* (c) 2002 - 2015 Broadsign International, LLC
*/
import java.util.List;
import org.apache.axis2.Constants.Configuration;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.description.TransportOutDescription;
import org.apache.axis2.transport.http.CommonsHTTPTransportSender;
import org.apache.axis2.transport.http.HTTPConstants;
import com.broadsign.www.wsdl_ops.BsapiStub;
import com.broadsign.www.wsdl_ops.IncidentMgrListResponseBody;
class Main {
public static void main(String[] args) throws Exception
{
setupKeystore();
BsapiStub javaStub = createStub();
String basicPlayerId = "12345678";
IncidentFactory incidentFactory = new IncidentFactory(javaStub);
List<IncidentMgrListResponseBody> rBodies = incidentFactory.list(basicPlayerId, "");
for(IncidentMgrListResponseBody rBody : rBodies) {
System.out.println(rBody.getId() + " : " + rBody.getResourceId() + " : " + rBody.getProblemDescription());
}
}
private static BsapiStub createStub()
{
try {
ConfigurationContext config = ConfigurationContextFactory.createDefaultConfigurationContext();
TransportOutDescription transport = new TransportOutDescription("https_mutual_auth");
CommonsHTTPTransportSender sender = new CommonsHTTPTransportSender();
sender.init(config, transport);
BsapiStub javaStub = new BsapiStub();
transport.setSender(sender);
javaStub._getServiceClient().getOptions().setProperty(Configuration.CHARACTER_SET_ENCODING, "utf-16");
javaStub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, "false");
javaStub._getServiceClient().getOptions().setTransportOut(transport);
return javaStub;
} catch (java.lang.Exception e) {
System.out.println("Error:" + e.toString());
}
return null;
}
private static void setupKeystore()
{
// NOTE: Make sure to update the folders where your keystore files are located
// as well as the actual passwords for your keystores
System.setProperty("javax.net.ssl.keyStoreType", "jks");
System.setProperty("javax.net.ssl.keyStore", "YOUR_SOAP_KEYSTORE_HERE.keystore");
System.setProperty("javax.net.ssl.keyStorePassword", "YOUR_SOAP_KEYSTORE_PASSWORD_HERE");
System.setProperty("javax.net.ssl.trustStoreType", "jks");
System.setProperty("javax.net.ssl.trustStore", "YOUR_TRUSTED_KEYSTORE_HERE.keystore");
System.setProperty("javax.net.ssl.trustStorePassword", "YOUR_TRUSTED_KEYSTORE_PASSWORD_HERE");
}
}
HostFactory.java
Copy
/*
* (c) 2002 - 2015 BroadSign International, LLC
*/
import java.util.ArrayList;
import java.util.List;
import org.apache.xmlbeans.XmlObject;
import com.broadsign.www.wsdl_ops.BsapiStub;
import com.broadsign.www.wsdl_ops.HostMgrListRequestBody;
import com.broadsign.www.wsdl_ops.HostMgrListResponseBody;
import com.broadsign.www.wsdl_ops.HostMgrUpdateRequestBody;
import com.broadsign.www.wsdl_ops.HostMgrUpdateResponseBody;
import com.broadsign.www.wsdl_ops.RequestDocument;
import com.broadsign.www.wsdl_ops.ResponseDocument;
import com.broadsign.www.wsdl_ops.WsdlRequest;
import com.broadsign.www.wsdl_ops.WsdlResponse;
import com.broadsign.www.wsdl_types.ResourceDiscoveryStatus;
public class HostFactory {
public HostFactory(BsapiStub stub)
{
assert(stub != null);
m_stub = stub;
}
public List<String> list(String domainId) throws Exception
{
List<String> hosts = new ArrayList<String>();
HostMgrListRequestBody hostMgrListRequestBody = HostMgrListRequestBody.Factory.newInstance();
WsdlRequest hostWsdlRequest = WsdlRequest.Factory.newInstance();
XmlObject hostBodies[];
RequestDocument hostRequestDocument = RequestDocument.Factory.newInstance();
ResponseDocument hostResponseDocument;
hostMgrListRequestBody.setDomainId(domainId);
hostWsdlRequest.setName("host_mgr_list");
hostWsdlRequest.setVersion(12);
hostWsdlRequest.setHost(hostMgrListRequestBody);
hostRequestDocument.setRequest(hostWsdlRequest);
hostRequestDocument.documentProperties().setEncoding("utf-16");
System.out.println(hostRequestDocument.xmlText());
hostResponseDocument = m_stub.host_mgr_list_v12(hostRequestDocument);
System.out.println(hostResponseDocument.xmlText());
WsdlResponse response = hostResponseDocument.getResponse();
hostBodies = response.getHostArray();
if (hostBodies.length > 0) {
for (XmlObject hostBody : hostBodies) {
HostMgrListResponseBody host = HostMgrListResponseBody.Factory.parse(hostBody.xmlText());
hosts.add(host.getName());
}
}
return hosts;
}
public boolean update(
ResourceDiscoveryStatus.Enum discovery_status,
String id,
String name,
int volume,
// optional parameters start below
String config_profile_bag_id,
String container_id,
String domain_id,
String display_unit_id,
int nscreens,
String geolocation) throws Exception
{
HostMgrUpdateRequestBody hostMgrUpdateRequestBody = HostMgrUpdateRequestBody.Factory.newInstance();
WsdlRequest hostWsdlRequest = WsdlRequest.Factory.newInstance();
XmlObject hostBodies[];
RequestDocument hostRequestDocument = RequestDocument.Factory.newInstance();
ResponseDocument hostResponseDocument;
hostMgrUpdateRequestBody.setDiscoveryStatus(discovery_status);
hostMgrUpdateRequestBody.setId(id);
hostMgrUpdateRequestBody.setName(name);
hostMgrUpdateRequestBody.setVolume(volume);
hostMgrUpdateRequestBody.setConfigProfileBagId(config_profile_bag_id);
hostMgrUpdateRequestBody.setContainerId(container_id);
hostMgrUpdateRequestBody.setDomainId(domain_id);
hostMgrUpdateRequestBody.setDisplayUnitId(display_unit_id);
hostMgrUpdateRequestBody.setNscreens(nscreens);
hostMgrUpdateRequestBody.setGeolocation(geolocation);
hostWsdlRequest.setName("host_mgr_update");
hostWsdlRequest.setVersion(12);
hostWsdlRequest.setHost(hostMgrUpdateRequestBody);
hostRequestDocument.setRequest(hostWsdlRequest);
hostRequestDocument.documentProperties().setEncoding("utf-16");
System.out.println(hostRequestDocument.xmlText());
hostResponseDocument = m_stub.host_mgr_update_v12(hostRequestDocument);
System.out.println(hostResponseDocument.xmlText());
WsdlResponse response = hostResponseDocument.getResponse();
hostBodies = response.getHostArray();
if (hostBodies.length > 0) {
for (XmlObject hostBody : hostBodies) {
HostMgrUpdateResponseBody host = HostMgrUpdateResponseBody.Factory.parse(hostBody.xmlText());
if(host.getId() != null) {
return true;
}
}
}
return false;
}
private BsapiStub m_stub;
}