BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 09-10-2009, 08:35 AM   #1
Anil
New Member
 
Join Date: Jun 2009
Model: 8330
PIN: N/A
Carrier: None
Posts: 3
Default Need help with 5.0 Admin api

Please Login to Remove!

Hi

Has anybody used bkackberry admin api. What Iam looking for is to find deviceid for user given a userid, rather i should say display name. There is a method called findDeviceforUser in core Ws but that needs an userid, an integer. And to get the userid , there is method called findUsers where you can use displayName to get the userid. This all looks simple

But the problem is the code sample snippets given in the document have all mistakes. First I have created the javaproxy with wsdl2java by passing core ws wsdl. 1) From then its not clear how to use proxy code 2) then sample snippet of code given for findUsers and findDeviceForuser code is not correct

I need some immediate help on this. Please let me know. Iam looking
1) how to use proxy client after generating the code with wsdl2java
2) using findUsers and findDeviceforUser . Code samples will be of great help

Thank You
__________________
Offline  
Old 09-16-2009, 08:22 AM   #2
fbrimm
Thumbs Must Hurt
 
Join Date: Aug 2005
Model: 8830
Carrier: Verizon
Posts: 144
Default

Anil,

Here's a demo app I created from the sample apps that prompts for a user name, and message to send.

fbrimm

Code:
public partial class Form1 : Form
{
	public static BAAServiceCore coreWebService = new BAAServiceCore();
	public static BAAServiceUtil utilWebService = new BAAServiceUtil();
	public static BAAServiceEmailExchange emailExchangeWebService = new BAAServiceEmailExchange();
	public static BAAServiceDispatcher dispatcherWebService = new BAAServiceDispatcher();

	private string basURL = "XXXXXXXX.com";
	private string userName = "XXXXX";
	private string password = "XXXXXXXX";
	private int[] userIDs;

	public Form1()
	{
		InitializeComponent();

		coreWebService.Url = "https://" + basURL + "/baaws/core/ws?wsdl";
		utilWebService.Url = "https://" + basURL + "/baaws/core/wsutil?wsdl";
		emailExchangeWebService.Url = "https://" + basURL + "/baaws/emailexchange/ws?wsdl";

		encodeUsername encodeUsernameRequest = new encodeUsername();
		encodeUsernameRequest.username = userName;
		encodeUsernameResponse encodeUsernameResponse = utilWebService.encodeUsername(encodeUsernameRequest);
		String encodedUser = encodeUsernameResponse.returnValue;

		coreWebService.Credentials = new NetworkCredential(encodedUser, password);
		coreWebService.PreAuthenticate = true;
		dispatcherWebService.Credentials = new NetworkCredential(encodedUser, password);
		dispatcherWebService.PreAuthenticate = true;
		emailExchangeWebService.Credentials = new NetworkCredential(encodedUser, password);
		emailExchangeWebService.PreAuthenticate = true;
	}

	private void btnSend_Click(object sender, EventArgs e)
	{
		findUserID(txtName.Text);

		sendPIN("Testing", txtMsg.Text);

	}

	private void findUserID(string userDisplayName)
	{
		findUsers findUsersRequest = new findUsers();
		UserSearchResult lastResultElement = null;
		UserSearchCriteria searchCriteria = new UserSearchCriteria();
		BASUserSearchCriteriaServiceAttributes basServiceAttributes = new BASUserSearchCriteriaServiceAttributes();

		basServiceAttributes.displayName = userDisplayName;
		searchCriteria.userSearchCriteriaServiceAttributes = new UserSearchCriteriaServiceAttributesType[1];
		searchCriteria.userSearchCriteriaServiceAttributes[0] = basServiceAttributes;
		findUsersRequest.searchCriteria = searchCriteria;

		findUsersRequest.pageSize = 3;
		findUsersRequest.locale = "en_US";

		BASUserSearchResultSortByEnum sortBy = new BASUserSearchResultSortByEnum();
		sortBy.@enum = BASUserSearchResultSortByEnumType.DISPLAY_NAME;
		sortBy.enumSpecified = true;
		findUsersRequest.sortBy = sortBy;
		findUsersRequest.sortAscendingOrder = true;

		findUsersResponse response = coreWebService.findUsers(findUsersRequest);

		if (response.returnValue.findUsersReturnStatus.code != FindUsersReturnStatusEnumType.SUCCESS)
		{
			// handle any errors
			string dbg = "here";
		}

		userIDs = new int[response.returnValue.userSearchResult.Length];
		while (response.returnValue.userSearchResult != null && response.returnValue.userSearchResult != null)
		{
			for (int i = 0; i < response.returnValue.userSearchResult.Length; i++)
			{
				UserSearchResult searchResult = response.returnValue.userSearchResult[i];
				UserSearchResultServiceAttributesType[] serviceAttributes = searchResult.userSearchResultServiceAttributes;
				for (int j = 0; j < serviceAttributes.Length; j++)
				{
					if (serviceAttributes[j].GetType().Equals(typeof (BASUserSearchResultServiceAttributes)))
					{
						BASUserSearchResultServiceAttributesType BASAttributes =
						serviceAttributes[j] as BASUserSearchResultServiceAttributesType;
						userIDs[i] = BASAttributes.userId;
					}
				}
			}
			lastResultElement = response.returnValue.userSearchResult[response.returnValue.userSearchResult.Length - 1];
			findUsersRequest.lastResultElement = lastResultElement;

			response = coreWebService.findUsers(findUsersRequest);
		}
	}

	private void sendPIN(string messageSubject, string messageBody)
	{
		sendMessageToUsers request = new sendMessageToUsers();
		sendMessageToUsersResponse response;
		
		UserMessage message = new UserMessage();
		message.subject = messageSubject;
		message.body = messageBody;

		DispatcherMessageTypeEnum messageType = new DispatcherMessageTypeEnum();
		messageType.@enum = DispatcherMessageTypeEnumType.PIN;
		messageType.enumSpecified = true;

		request.userIds = userIDs;
		request.message = message;
		request.messageTypeEnum = messageType;

		response = coreWebService.sendMessageToUsers(request);

		if (response.returnValue.sendMessageToUsersReturnStatus.code != SendMessageToUserReturnStatusEnumType.SUCCESS)
		{
			// handle any errors
			string dbg = "here";
		}
	}
}
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


IXYS SEMICONDUCTOR MEO 450-12 DA picture

IXYS SEMICONDUCTOR MEO 450-12 DA

$80.00



IXYS SEMICONDUCTOR MEO 450-12DA (H) picture

IXYS SEMICONDUCTOR MEO 450-12DA (H)

$90.00



Dual Range Transistor Diode Semiconductor & Passive Curve Tracer Tester/Tracker picture

Dual Range Transistor Diode Semiconductor & Passive Curve Tracer Tester/Tracker

$26.99



MR2535L On Semiconductor Original Diode CASE194 picture

MR2535L On Semiconductor Original Diode CASE194

$10.95



Thermoelectric Cooler Peltier System Semiconductor Water Chiller Aquarium 180W picture

Thermoelectric Cooler Peltier System Semiconductor Water Chiller Aquarium 180W

$30.40



ON SEMICONDUCTOR NBSG16VSBA picture

ON SEMICONDUCTOR NBSG16VSBA

$140.17







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.