Add Display Units

This use case describes the requirements for adding display units to your domain using BroadSign Open.

SOAP API Method Reference

To add display units, use the following methods:

Code Samples
#!/usr/bin/php
<?php
	## Create a new display unit and associate a criterion to it
	##
	## Usage: php display_unit_mgr_add_v10 --domain=domainId --name="Display unit name" --type="Display type ID" \
	## --loopPolicy="Loop policy ID" [--containerId=folderId] [--enforceDayParts] [--criteria=criteriaId]
	## Usage example : php display_unit_mgr_add_v10 --domain=123456789 --name="Display_Unit_for_11_1_docs" --type=987654321 --loopPolicy=123456789

	include "soaplib.php";
	include "cmdutil.php";

	$options = get_arguments("domain!", "name!", "type!", "loopPolicy!", "containerId", "enforceDayParts?", "criteria");

	# Add display unit
	$body = new stdClass();
	$body -> display_unit_type_id = $options["type"]; # ID of the display type
	$body -> enforce_day_parts = $options["enforceDayParts"]; # Boolean: reports offline incidents
	$body -> name = $options["name"]; # Name of the new display unit
	$body -> container_id = @$options["containerId"]; # ID of the display unit folder, leave NULL for root
	$body -> domain_id = $options["domain"]; # ID of your domain
	$du_response = performSimpleOperation("display_unit", "add", 10, $body, false);

	if (!$du_response || !isset($du_response -> display_unit[0] -> id)) {
		echo "\nCould not create display unit.\n";
		return;
	}
	else 
		echo ("\nCreated display unit : {$du_response -> display_unit[0] -> id}")

	$du_id = $du_response -> display_unit[0] -> id;

	# Add default day part
	$body = new stdClass();
	$body -> name = "24/7";
	$body -> day_mask = 127;
	$body -> parent_id = $du_id;
	$body -> start_date = "";
	$body -> end_date = "";
	$body -> start_time = "00:00:00";
	$body -> end_time = "00:00:00";
	$body -> virtual_start_date = "1756-01-01";
	$body -> virtual_end_date = "8000-12-31";
	$body -> impressions_per_hour = -1;
	$body -> weight = 0;
	$body -> domain_id = $options["domain"];
	$dp_response = performSimpleOperation("day_part", "add", 5, $body, false);


	if (!$dp_response || !isset($dp_response -> day_part[0] -> id)) {
		echo "Could not create day part.\n";
		return;
	}
	else
		echo ("\nCreated day part {$dp_response -> day_part[0] -> id} into display unit : {$du_response -> display_unit[0] -> id}")

	$dp_id = $dp_response -> day_part[0] -> id;

	# Add default frame
	$body = new stdClass();
	$body -> parent_id = $dp_id;
	$body -> geometry_type = 1; # 1 => Percent geometry, 2 => Pixel geometry
	$body -> height = 100;
	$body -> width = 100;
	$body -> x = 0;
	$body -> y = 0;
	$body -> name = "Fullscreen";
	$body -> loop_policy_id = $options["loopPolicy"]; # ID of the associated loop policy
	$body -> screen_no = 1;
	$body -> domain_id = $options["domain"];
	$frame_response = performSimpleOperation("skin", "add", 7, $body, false);
	
	if (!$frame_response || !isset($frame_response -> skin[0] -> id)) {
		echo "Could not create frame.\n";
		return;
	}
	else
		echo ("\nCreated frame {$frame_response -> skin[0] -> id} into day part : {$dp_response -> day_part[0] -> id}")
	

	# Add targeting criterion
	if (isset($options["criteria"])) {
		$body = new stdClass();
		$body -> parent_id = $du_id;
		$body -> criteria_id = $options["criteria"];
		$body -> domain_id = $options["domain"];
		$criteria_response = performSimpleOperation("resource_criteria", "add", 7, $body, false);
	}
?>

/*
 * (c) 2002 - 2015 BroadSign International, LLC
 */

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;

class Main {

	public static void main(String[] args)
	{
		setupKeystore();
		BsapiStub javaStub = createStub();
		
		String basicDomain = "68110168";
		String basicDisplayUnitContainer = "125613640";
		String basicLoopPolicy = "68125057";
		String basicDisplayUnitType = "68124121";
		String basicCampaignTargetingCriteria = "68270896";
		
		DisplayUnitFactory duFactory = new DisplayUnitFactory(javaStub);
		String duId = duFactory.createDefaultDisplayUnitTree("BroadSign SDK Display Unit Test",
				basicDisplayUnitType,
				basicLoopPolicy,
				basicDisplayUnitContainer,
				basicDomain);

		if (!duId.isEmpty()) {
			CriteriaFactory criteriaFactory = new CriteriaFactory(javaStub);
			criteriaFactory.assignCriteriaToResource(duId, basicCampaignTargetingCriteria, basicDomain);
			System.out.println("Created display unit: " + duId);
		}
	}


	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
		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");
	}
}

/*
 * (c) 2002 - 2015 BroadSign International, LLC
 */

/*
 * CampaignFactory Class
 *
 * This class allows the creation of display units
 */

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.DisplayUnitMgrAddRequestBody;
import com.broadsign.www.wsdl_ops.DisplayUnitMgrAddResponseBody;
import com.broadsign.www.wsdl_ops.DisplayUnitMgrListManyRequestBody;
import com.broadsign.www.wsdl_ops.DisplayUnitMgrListManyResponseBody;
import com.broadsign.www.wsdl_ops.DisplayUnitMgrListRequestBody;
import com.broadsign.www.wsdl_ops.DisplayUnitMgrListResponseBody;
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;

class DisplayUnitFactory {
	public DisplayUnitFactory(BsapiStub stub)
	{
		assert(stub != null);
		m_stub = stub;
	}

	public String createDisplayUnit(String name,
		String displayUnitTypeId,
		String containerId,
		Boolean enforceDayParts,
		String domainId)
	{
		String displayUnitId = null;

		try {
			DisplayUnitMgrAddRequestBody duMgrAddRequestBody = DisplayUnitMgrAddRequestBody.Factory.newInstance();
			WsdlRequest duWsdlRequest = WsdlRequest.Factory.newInstance();
			RequestDocument duRequestDocument = RequestDocument.Factory.newInstance();
			XmlObject duBodies[];
			ResponseDocument duResponseDocument;

			duMgrAddRequestBody.setContainerId(containerId);
			duMgrAddRequestBody.setDisplayUnitTypeId(displayUnitTypeId);
			duMgrAddRequestBody.setEnforceDayParts(enforceDayParts);
			duMgrAddRequestBody.setDomainId(domainId);
			duMgrAddRequestBody.setName(name);
			duWsdlRequest.setName("display_unit_mgr_add");
			duWsdlRequest.setVersion(10);
			duWsdlRequest.setDisplayUnit(duMgrAddRequestBody);
			duRequestDocument.setRequest(duWsdlRequest);
			duRequestDocument.documentProperties().setEncoding("utf-16");
			System.out.println(duRequestDocument.xmlText());
			duResponseDocument = m_stub.display_unit_mgr_add_v10(duRequestDocument);
			System.out.println(duResponseDocument.xmlText());
			duBodies = duResponseDocument.getResponse().getDisplayUnitArray();

			if (duBodies.length == 1) {
				DisplayUnitMgrAddResponseBody du = DisplayUnitMgrAddResponseBody.Factory.parse(duBodies[0].xmlText());

				displayUnitId = du.getId().toString();
			} else {
				System.out.println("Error: Failed to create display unit.");
			}
		} catch (java.lang.Exception e) {
			System.out.println("Error:" + e.toString());
		}

		return displayUnitId;
	}

	public String createDefaultDisplayUnitTree(String name,
		String displayUnitTypeId,
		String loopPolicyId,
		String containerId,
		String domainId)
	{
		String duId = createDisplayUnit(name, displayUnitTypeId, containerId, false, domainId);

		if (duId.isEmpty()) {
			System.out.println("Error: Failed to create display unit.");
		} else {
			DayPartFactory dpFactory = new DayPartFactory(m_stub);
			String dpId = dpFactory.createDefaultDayPart(duId, domainId);

			if (dpId.isEmpty()) {
				System.out.println("Error: Failed to create day part.");
			} else {
				FrameFactory frameFactory = new FrameFactory(m_stub);
				String frameId = frameFactory.createDefaultFrame(dpId, loopPolicyId, domainId);

				if (frameId.isEmpty())
					System.out.println("Error: Failed to create frame.");
			}
		}

		return duId;
	}

	public List<String> list(String domainId) throws Exception
	{
		List<String> displayUnits = new ArrayList<String>();
		DisplayUnitMgrListRequestBody duMgrListRequestBody = DisplayUnitMgrListRequestBody.Factory.newInstance();
		WsdlRequest duWsdlRequest = WsdlRequest.Factory.newInstance();
		XmlObject duBodies[];
		RequestDocument duRequestDocument = RequestDocument.Factory.newInstance();
		ResponseDocument duResponseDocument;

		duMgrListRequestBody.setDomainId(domainId);
		duWsdlRequest.setName("display_unit_mgr_list");
		duWsdlRequest.setVersion(10);
		duWsdlRequest.setDisplayUnit(duMgrListRequestBody);
		duRequestDocument.setRequest(duWsdlRequest);
		duRequestDocument.documentProperties().setEncoding("utf-16");
		System.out.println(duRequestDocument.xmlText());
		duResponseDocument = m_stub.display_unit_mgr_list_v10(duRequestDocument);
		System.out.println(duResponseDocument.xmlText());
		WsdlResponse response = duResponseDocument.getResponse();
		duBodies = response.getDisplayUnitArray();

		if (duBodies.length > 0) {
			for (XmlObject duBody : duBodies) {
				DisplayUnitMgrListResponseBody displayUnit = DisplayUnitMgrListResponseBody.Factory.parse(duBody.xmlText());
				
				displayUnits.add(displayUnit.getName());
			}
		}

		return displayUnits;
	}
	
	public List<String> listByIds(String displayUnitIds, String domainId) throws Exception
	{
		List<String> displayUnits = new ArrayList<String>();
		DisplayUnitMgrListManyRequestBody duMgrListRequestBody = DisplayUnitMgrListManyRequestBody.Factory.newInstance();
		WsdlRequest duWsdlRequest = WsdlRequest.Factory.newInstance();
		XmlObject duBodies[];
		RequestDocument duRequestDocument = RequestDocument.Factory.newInstance();
		ResponseDocument duResponseDocument;

		duMgrListRequestBody.setDomainId(domainId);
		duMgrListRequestBody.setIds(displayUnitIds);
		duWsdlRequest.setName("display_unit_mgr_list_many");
		duWsdlRequest.setVersion(10);
		duWsdlRequest.setDisplayUnit(duMgrListRequestBody);
		duRequestDocument.setRequest(duWsdlRequest);
		duRequestDocument.documentProperties().setEncoding("utf-16");
		System.out.println(duRequestDocument.xmlText());
		duResponseDocument = m_stub.display_unit_mgr_list_many_v10(duRequestDocument);
		System.out.println(duResponseDocument.xmlText());
		WsdlResponse response = duResponseDocument.getResponse();
		duBodies = response.getDisplayUnitArray();

		if (duBodies.length > 0) {
			for (XmlObject duBody : duBodies) {
				DisplayUnitMgrListManyResponseBody displayUnit = DisplayUnitMgrListManyResponseBody.Factory.parse(duBody.xmlText());

				displayUnits.add(displayUnit.getName());
			}
		}

		return displayUnits;
	}

	private BsapiStub m_stub = null;
}

/*
 * (c) 2002 - 2015 BroadSign International, LLC
 */

/*
 * DayPartFactory Class
 *
 * This class allows the creation of day parts
 */

import java.util.ArrayList;
import java.util.List;

import org.apache.xmlbeans.*;

import com.broadsign.www.wsdl_ops.*;

class DayPartFactory {

	public DayPartFactory(BsapiStub stub)
	{
		assert(stub != null);
		m_stub = stub;
	}

	public String createDefaultDayPart(String displayUnitId, String domainId)
	{
		try {
			return createDayPart("24/7",
				displayUnitId,
				127,
				null,
				null,
				"00:00:00",
				"00:00:00",
				"1756-01-01",
				"8000-12-31",
				-1,
				0,
				domainId);
		} catch (java.lang.Exception e) {
			System.out.println("Error:" + e.toString());
		}

		return "";
	}

	public String createDayPart(String name,
		String displayUnitId,
		int dayMask,
		String startDate,
		String endDate,
		String startTime,
		String endTime,
		String virtualStartDate,
		String virtualEndDate,
		int impressionsPerHour,
		int weight,
		String domainId)
	{
		String dpId = null;

		try {
			DayPartMgrAddRequestBody dpMgrAddRequestBody = DayPartMgrAddRequestBody.Factory.newInstance();
			WsdlRequest dpWsdlRequest = WsdlRequest.Factory.newInstance();
			RequestDocument dpRequestDocument = RequestDocument.Factory.newInstance();
			XmlObject dpBodies[];
			ResponseDocument dpResponseDocument;

			dpMgrAddRequestBody.setName(name);
			dpMgrAddRequestBody.setDayMask(dayMask);
			dpMgrAddRequestBody.setParentId(displayUnitId);
			dpMgrAddRequestBody.setEndDate(endDate);
			dpMgrAddRequestBody.setEndTime(endTime);
			dpMgrAddRequestBody.setStartDate(startDate);
			dpMgrAddRequestBody.setStartTime(startTime);
			dpMgrAddRequestBody.setImpressionsPerHour(impressionsPerHour);
			dpMgrAddRequestBody.setVirtualEndDate(virtualEndDate);
			dpMgrAddRequestBody.setVirtualStartDate(virtualStartDate);
			dpMgrAddRequestBody.setWeight(weight);
			dpMgrAddRequestBody.setDomainId(domainId);
			dpWsdlRequest.setName("day_part_mgr_add");
			dpWsdlRequest.setVersion(5);
			dpWsdlRequest.setDayPart(dpMgrAddRequestBody);
			dpRequestDocument.setRequest(dpWsdlRequest);
			dpRequestDocument.documentProperties().setEncoding("utf-16");
			System.out.println(dpRequestDocument.xmlText());
			dpResponseDocument = m_stub.day_part_mgr_add_v5(dpRequestDocument);
			System.out.println(dpResponseDocument.xmlText());
			dpBodies = dpResponseDocument.getResponse().getDayPartArray();

			if (dpBodies.length == 1) {
				DayPartMgrAddResponseBody dayPart = DayPartMgrAddResponseBody.Factory.parse(dpBodies[0].xmlText());

				dpId = dayPart.getId().toString();
			} else {
				System.out.println("Error: Failed to create day part.");
			}
		} catch (java.lang.Exception e) {
			System.out.println("Error:" + e.toString());
		}

		return dpId;
	}

	public List<String> list(String domainId, String parentContainerIds) throws Exception
	{
		List<String> results = new ArrayList<String>();
		WsdlRequest wsdlRequest = WsdlRequest.Factory.newInstance();
		XmlObject xmlBodies[];
		RequestDocument requestDocument = RequestDocument.Factory.newInstance();
		ResponseDocument responseDocument;
		WsdlResponse response;

		if (!parentContainerIds.isEmpty()) {
			DayPartMgrListScopedRequestBody requestBody = DayPartMgrListScopedRequestBody.Factory.newInstance();

			requestBody.setDomainId(domainId);
			requestBody.setParentContainerIds(parentContainerIds);
			wsdlRequest.setName("day_part_mgr_list_scoped");
			wsdlRequest.setVersion(5);
			wsdlRequest.setDayPart(requestBody);
		} else {
			DayPartMgrListRequestBody requestBody = DayPartMgrListRequestBody.Factory.newInstance();

			requestBody.setDomainId(domainId);
			wsdlRequest.setName("day_part_mgr_list");
			wsdlRequest.setVersion(5);
			wsdlRequest.setDayPart(requestBody);
		}

		requestDocument.setRequest(wsdlRequest);
		requestDocument.documentProperties().setEncoding("utf-16");
		System.out.println(requestDocument.xmlText());

		if (!parentContainerIds.isEmpty())
			responseDocument = m_stub.day_part_mgr_list_scoped_v5(requestDocument);
		else
			responseDocument = m_stub.day_part_mgr_list_v5(requestDocument);

		System.out.println(responseDocument.xmlText());
		response = responseDocument.getResponse();
		xmlBodies = response.getDayPartArray();

		if (xmlBodies.length > 0) {
			for (XmlObject xmlBody : xmlBodies) {
				if (!parentContainerIds.isEmpty()) {
					DayPartMgrListScopedResponseBody dayPart = DayPartMgrListScopedResponseBody.Factory.parse(xmlBody.xmlText());

					results.add(dayPart.getId().toString());
				} else {
					DayPartMgrListResponseBody dayPart = DayPartMgrListResponseBody.Factory.parse(xmlBody.xmlText());

					results.add(dayPart.getId().toString());
				}
			}
		}

		return results;
	}

	private BsapiStub m_stub = null;
}

/*
 * (c) 2002 - 2015 BroadSign International, LLC
 */

/*
 * FrameFactory Class
 *
 * This class allows the creation of frames
 */

import org.apache.xmlbeans.*;

import com.broadsign.www.wsdl_ops.*;
import com.broadsign.www.wsdl_types.GeometryType;

class FrameFactory {
	public FrameFactory(BsapiStub stub)
	{
		assert(stub != null);
		m_stub = stub;
	}

	public String createDefaultFrame(String parentId,
		String loopPolicyId,
		String domainId)
	{
		return createFrame("Fullscreen",
			parentId,
			GeometryType.X_1,
			100,
			100,
			loopPolicyId,
			1,
			0,
			0,
			0,
			domainId);
	}

	public String createFrame(String name,
		String parentId,
		GeometryType.Enum type,
		int height,
		int width,
		String loopPolicyId,
		int screenNumber,
		int x,
		int y,
		int z,
		String domainId)
	{
		String skinId = null;

		try {
			SkinMgrAddRequestBody skinMgrAddRequestBody = SkinMgrAddRequestBody.Factory.newInstance();
			WsdlRequest skinWsdlRequest = WsdlRequest.Factory.newInstance();
			RequestDocument skinRequestDocument = RequestDocument.Factory.newInstance();
			XmlObject skinBodies[];
			ResponseDocument skinResponseDocument;

			skinMgrAddRequestBody.setParentId(parentId);
			skinMgrAddRequestBody.setDomainId(domainId);
			skinMgrAddRequestBody.setGeometryType(type);
			skinMgrAddRequestBody.setHeight(height);
			skinMgrAddRequestBody.setWidth(width);
			skinMgrAddRequestBody.setName(name);
			skinMgrAddRequestBody.setLoopPolicyId(loopPolicyId);
			skinMgrAddRequestBody.setScreenNo(screenNumber);
			skinMgrAddRequestBody.setX(x);
			skinMgrAddRequestBody.setY(y);
			skinMgrAddRequestBody.setZ(z);
			skinWsdlRequest.setName("skin_mgr_add");
			skinWsdlRequest.setVersion(7);
			skinWsdlRequest.setSkin(skinMgrAddRequestBody);
			skinRequestDocument.setRequest(skinWsdlRequest);
			skinRequestDocument.documentProperties().setEncoding("utf-16");
			System.out.println(skinRequestDocument.xmlText());
			skinResponseDocument = m_stub.skin_mgr_add_v7(skinRequestDocument);
			System.out.println(skinResponseDocument.xmlText());
			skinBodies = skinResponseDocument.getResponse().getSkinArray();

			if (skinBodies.length == 1) {
				SkinMgrAddResponseBody skin = SkinMgrAddResponseBody.Factory.parse(skinBodies[0].xmlText());

				skinId = skin.getId().toString();
			} else {
				System.out.println("Error: Failed to create frame.");
			}
		} catch (java.lang.Exception e) {
			System.out.println("Error:" + e.toString());
		}

		return skinId;
	}

	private BsapiStub m_stub = null;
}

/*
 * (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.CriteriaMgrListRequestBody;
import com.broadsign.www.wsdl_ops.CriteriaMgrListResponseBody;
import com.broadsign.www.wsdl_ops.RequestDocument;
import com.broadsign.www.wsdl_ops.ResourceCriteriaMgrAddRequestBody;
import com.broadsign.www.wsdl_ops.ResourceCriteriaMgrAddResponseBody;
import com.broadsign.www.wsdl_ops.ResponseDocument;
import com.broadsign.www.wsdl_ops.WsdlRequest;
import com.broadsign.www.wsdl_ops.WsdlResponse;

public class CriteriaFactory {

	public CriteriaFactory(BsapiStub stub)
	{
		assert(stub != null);
		m_stub = stub;
	}

	public List<String> list(String domainId) throws Exception
	{
		List<String> criterias = new ArrayList<String>();
		CriteriaMgrListRequestBody criMgrListRequestBody = CriteriaMgrListRequestBody.Factory.newInstance();
		WsdlRequest criWsdlRequest = WsdlRequest.Factory.newInstance();
		XmlObject criBodies[];
		RequestDocument criRequestDocument = RequestDocument.Factory.newInstance();
		ResponseDocument criResponseDocument;

		criMgrListRequestBody.setDomainId(domainId);
		criWsdlRequest.setName("criteria_mgr_list");
		criWsdlRequest.setVersion(7);
		criWsdlRequest.setCriteria(criMgrListRequestBody);
		criRequestDocument.setRequest(criWsdlRequest);
		criRequestDocument.documentProperties().setEncoding("utf-16");
		System.out.println(criRequestDocument.xmlText());
		criResponseDocument = m_stub.criteria_mgr_list_v7(criRequestDocument);
		System.out.println(criResponseDocument.xmlText());
		WsdlResponse response = criResponseDocument.getResponse();
		criBodies = response.getCriteriaArray();

		if (criBodies.length > 0) {
			for (XmlObject criBody : criBodies) {
				CriteriaMgrListResponseBody criteria = CriteriaMgrListResponseBody.Factory.parse(criBody.xmlText());

				criterias.add(criteria.getName());
			}
		}

		return criterias;
	}

	public String assignCriteriaToResource(String targetResourceId, String criteriaId, String domainId)
	{
		String id = null;

		try {
			ResourceCriteriaMgrAddRequestBody rcMgrAddRequestBody = ResourceCriteriaMgrAddRequestBody.Factory.newInstance();
			WsdlRequest rcWsdlRequest = WsdlRequest.Factory.newInstance();
			RequestDocument rcRequestDocument = RequestDocument.Factory.newInstance();
			XmlObject rcBodies[];
			ResponseDocument rcResponseDocument;

			rcMgrAddRequestBody.setCriteriaId(criteriaId);
			rcMgrAddRequestBody.setParentId(targetResourceId);
			rcMgrAddRequestBody.setDomainId(domainId);
			rcWsdlRequest.setName("resource_criteria_mgr_add");
			rcWsdlRequest.setVersion(7);
			rcWsdlRequest.setResourceCriteria(rcMgrAddRequestBody);
			rcRequestDocument.setRequest(rcWsdlRequest);
			rcRequestDocument.documentProperties().setEncoding("utf-16");
			System.out.println(rcRequestDocument.xmlText());
			rcResponseDocument = m_stub.resource_criteria_mgr_add_v7(rcRequestDocument);
			System.out.println(rcResponseDocument.xmlText());
			rcBodies = rcResponseDocument.getResponse().getResourceCriteriaArray();

			if (rcBodies.length == 1) {
				ResourceCriteriaMgrAddResponseBody rc = ResourceCriteriaMgrAddResponseBody.Factory.parse(rcBodies[0].xmlText());

				id = rc.getId().toString();
			} else {
				System.out.println("Error: Failed to create frame.");
			}
		} catch (java.lang.Exception e) {
			System.out.println("Error:" + e.toString());
		}

		return id;
	}

	private BsapiStub m_stub;
}