Examples of code to create the connection of BWS

Hi I started using BWS (Blackberry Web Services) recently after the use of BAA (Blackberry Administration API) for some time. I would get a tutorial or sample code showing the initialization of the connection to the BWS and then use it to call the getUsersDetail method. I have the below code is missing the connection of BWS.

import java.util.List;

import com.rim.ws.enterprise.admin.*;
public class BWSTest {

    public static String locale = "en_US";
    public static void main(String[] args){

        RequestMetadata requestMetadata = new RequestMetadata();
        requestMetadata.setLocale(locale);
        GetUsersDetailRequest userRequest = new GetUsersDetailRequest();
        userRequest.setMetadata(requestMetadata);
        userRequest.setLoadDevices(true);
        userRequest.setLoadAccounts(true);
        userRequest.setLoadITPolicies(true);
        userRequest.setLoadSWConfigs(true);
//      List allUsers=userRequest.getUsers(); this method reflects users added as part of the request, not resulting from it
        GetUsersDetailResponse response = bws.getUsersDetail(request);

        if (response.getReturnStatus().getCode().compareTo("SUCCESS") !=0){
            System.out.println("Error occurred: "+response.getReturnStatus().getMessage() );
        }

        for(GetUsersDetailIndividualResponse individualResponse:response.getIndividualResponses()){
            individualResponse.getUserDetail().getDisplayName();
        }

    }

}

I found this code on the following link in a zip file:

BWS Java sample

import java.net.MalformedURLException;
import java.net.URL;

import javax.xml.ws.BindingProvider;

import com.rim.ws.enterprise.admin.BWS;
import com.rim.ws.enterprise.admin.BWSService;
import com.rim.ws.enterprise.admin.BWSUtil;
import com.rim.ws.enterprise.admin.BWSUtilService;
import com.rim.ws.enterprise.admin.GetEncodedUsernameRequest;
import com.rim.ws.enterprise.admin.GetEncodedUsernameResponse;
import com.rim.ws.enterprise.admin.GetUsersRequest;
import com.rim.ws.enterprise.admin.GetUsersResponse;
import com.rim.ws.enterprise.admin.GetUsersSearchCriteria;
import com.rim.ws.enterprise.admin.GetUsersSortBy;
import com.rim.ws.enterprise.admin.RequestMetadata;
import com.rim.ws.enterprise.admin.User;

/**
 * This simple program finds users on the BlackBerry Administration Server,
 * and displays the existing users in the Console output.
 *
 * @author gbeukeboom
 *
 */

public class TestMain {

    public static BWSService _myBWSService;
    public static BWS _bws;
    public static BWSUtilService _myBWSUtilService;
    public static BWSUtil _bwsUtil;
    private static String _locale = "en_US";
    private static String _clientVersion = "5.0.3"; //The version of BAS this application was created for
    private static RequestMetadata _meta = new RequestMetadata();;

    private static boolean setup() {
        String strBASURL=System.getProperty("basurl");
        URL serviceUrl = null;
        URL utilServiceUrl=null;

        //The Metadata object includes information about this application, it is included with every call
        _meta.setClientVersion(_clientVersion);
        _meta.setOrganizationUid("0"); //Not used currently, set to "0"
        _meta.setLocale(_locale);

        try {
            serviceUrl = new URL("https://" + strBASURL + "/enterprise/admin/ws?wsdl");
            utilServiceUrl = new URL("https://" + strBASURL + "/enterprise/admin/util/ws?wsdl");
        } catch (MalformedURLException e) {
            System.err.println("Cannot initialize the wsdl");
            return false;
        }

        //Initialize our web service stubs that will be used for all calls
        _myBWSService = new BWSService(serviceUrl);
        _bws = _myBWSService.getBWS();
        _myBWSUtilService = new BWSUtilService(utilServiceUrl);
        _bwsUtil = _myBWSUtilService.getBWSUtil();

        String username=System.getProperty("username");
        String password=System.getProperty("password");

        GetEncodedUsernameRequest request=new GetEncodedUsernameRequest();
        request.setMetadata(_meta);
        request.setUsername(username);
        request.setDomain(strBASURL);

        //The BAS expects the username to be encoded, this call returns the encoded value
        GetEncodedUsernameResponse geurResponse = _bwsUtil.getEncodedUsername(request);

        if (geurResponse.getReturnStatus().getCode().compareTo("SUCCESS") != 0){
            System.out.println("Error occurred: " + geurResponse.getReturnStatus().getMessage());
            return false;
        }

        String myEncodeUsername = geurResponse.getEncodedUsername();

        //Set http basic authentication on the web service
        BindingProvider bp = (BindingProvider)_bws;
        bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, myEncodeUsername);
        bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);

        return true;
    }

    public static void getUsers() {

        GetUsersRequest request = new GetUsersRequest();
        request.setMetadata(_meta); //Assign our Metadata to the call

        //This criteria object could be used to specify search parameters
        GetUsersSearchCriteria searchCriteria = new GetUsersSearchCriteria();

        request.setSearchCriteria(searchCriteria);
        request.setPageSize(500);

        GetUsersSortBy sortBy = new GetUsersSortBy();
        sortBy.setEMAILADDRESS(true);
        sortBy.setValue("EMAIL_ADDRESS");
        request.setSortBy(sortBy);
        request.setSortAscending(true);

        GetUsersResponse response = _bws.getUsers(request);

        //If the result returned from the call is SUCCESS then we loop through all returned users
        //outputting their information to the console.
        if (response.getReturnStatus().getCode().compareTo("SUCCESS") != 0){
            System.out.println("Error occurred: " + response.getReturnStatus().getMessage());
        } else if (response.getUsers() != null) {
            for (User itr: response.getUsers()) {
                System.out.println("Display name: " + itr.getDisplayName());
                System.out.println("User ID: " + itr.getUid());
                for (String emailAddress :itr.getEmailAddresses() ){
                    System.out.println("Email Address: " + emailAddress);
                }
                System.out.print("\n");
            }
        }
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        System.out.println("Starting to intiialize credentials...");
        if (!setup()){
            System.out.println("Problem occurred while setting up credentials.");
            System.exit(0);
        }
        System.out.println("Credentials initialized.\n");
        System.out.println("Starting to retrieve users...");
        getUsers();
    }

}

Tags: BlackBerry Developers

Similar Questions

  • ConnectionFactory cannot create the connection using BIS_B

    By using the code below

    Import net.rim.device.api.io.transport.ConnectionDescriptor;

    Import net.rim.device.api.io.transport.ConnectionFactory;

    Import net.rim.device.api.io.transport.TransportInfo;

    SerializableAttribute public class MyConnectionFactory extends ConnectionFactory {}

    public MyConnectionFactory() {}

    Super();

    setPreferredTransportTypes (new int [] {TransportInfo.TRANSPORT_TCP_WIFI, TransportInfo.TRANSPORT_BIS_B});
    setDisallowedTransportTypes (new int [] {TransportInfo.TRANSPORT_WAP,

    TransportInfo.TRANSPORT_MDS,

    TransportInfo.TRANSPORT_WAP2,

    TransportInfo.TRANSPORT_TCP_CELLULAR});

    setConnectionMode (ConnectionFactory.ACCESS_READ_WRITE);

    }

    }

    I am unable to create the connection BIS_B...

    If anyone can help...

    Read the documentation of BisBOptions. You will discover.

    Please accept as solution if my suggestion works for you.

  • When I try to connect directly in multiplayer FSX without gamespy, every time I get an error message saying: unable to create the connection to the host.

    When I try to connect directly in multiplayer FSX without gamespy, every time I get an error message saying: unable to create the connection to the host.

    I need help
    Kind regards

    Thank you very much!

    To host successfully a FSX session what follows is the key enabling

    my client (s) to join my host FSX session!

    "Players Maximum (for a shared together plane 2) leave the locations reserved for friends to 0 set."

    6122 6112 UDP port translation FSX multiplayer traffic of my remote 2 wire gateway to my router Linksys Wireless N DMZ to access game FSX host...

    Only a single router in my configuration of the DMZ, the external network to the router,

    in this case, the 2 wires, had defined port forwarding.

    Am now enjoying Gamespy (R.I.P.) FSX free hosting for my MP FSX sessions via direct connection.

    5 high to the author!

  • Mapping to a Windows 7 disc from a XP platform, it creates the connection but it says "share: denied \Access.»

    Original title: mapping to a Windows 7 disc for XP platform

    Hi all is there anyone who can help me with the mapping a drive of windows 7 from my xp machine? I shared the drive on the computer 7 and everyone has permissions with full game. I can map other machines windows 7 itself but not some xp machines. I can ping the machine 7 machine xp with the address and the name of the computer. Now when I map the drive to create the connection but it says "share: denied \Access.»
    Any help is greatly appreciated.

    Hello Jgg5037,

    Double check to make sure that all computers are part of the same working group:
    Disable host group on the Windows 7 computer:
    Let us know if any of these methods help you resolve the error "access denied."
  • Failed to create the connection to the server application using jdev

    Hi"

    I'm unable to create the connection to the server using JDeveloper 10.1.3.1 version after "configuration Service 10.1.3.1.0 with 10.1.2 Oracle Internet application Identity

    Directory"I followed" Guide the administrator Oracle® BPEL Process Manager 10 g (10.1.3.1.0) "part number B28982-03".
    URL-> "http://download-uk.oracle.com/docs/cd/B31017_01/integrate.1013/b28982/service_config.htm#BABIBGFF".

    I was successfully able to integrate and capable "2.1.3.3 step 3: the Oracle Internet Directory test Configuration.

    But now when I try to establish a new connection to the application server with JDeveloper it gives below error.

    error: No process OC4J up AS instance identified by field: opmn oc4j_soa + oc4j-hostname-6003-default

    Please advice,

    Thank you
    Yatan

    Published by: Yatan on June 30, 2009 15:05

    What is the result of opmnctl status - app? You give the right opmn... other datails as and IS &?

  • option 4-digit PIN code disappeared in the connection of Windows 8 options

    Hello

    I hope someone can help with the above?

    I have mistakenly entered the identification number that has been set up on my laptop in the password field when you connect on my new laptop and now I see more PIN option when he said options sign of change.  Clearly my fault because I wasn't really paying attention!

    Now, I read somewhere that with W8 when you enter incorrectly the password 3 times now, which is clearly what I have done, that the option to connect using a 4 digit PIN, disappears!  If this is the case, how the hell do I now the connection option if there is no code pin to connect you to the help?  Please help and advise.  Thank you.

    Hello
     
    Welcome to the Microsoft community forums.
    Sorry to know that you are facing this problem with the connection to the computer with the Pin number.
     
    Please help me with the following information:
     
    1. did you remove the old PIN until you have tried to create a new?
    2. is your computer connected to a domain network?
     
    Windows 8 has a feature where you can use a PIN digit 4 to connect to your Windows account. If you are a domain user, this feature is disabled by default.
     
    We will try the following methods and check if it helps.
     
    Method 1: Try the following steps to remove your old PIN:
     
    1. Press 'Windows Logo' + 'C' keys on the keyboard to show the charms.
    2. click on "Settings" and then click on "Change PC settings" at the bottom
    3. Select 'Users' on the left of 'PC settings' Panel
    4. click on "Remove the PIN" under "sign in options.
    5. once the old PIN code is removed, try to create the new PIN and check to see if that solves the problem.

    Method 2: If the problem persists, refer to the suggestions for arnavsharma
    http://social.technet.Microsoft.com/forums/Windows/en-us/4d026aeb-ABEA-42f6-B67C-51a3db2e06e9/Windows-8-signin-options-missing?Forum=w8itprosecurity
     
    Hope this information helps, just reply to the State of the question to get help.

  • Failed to create the connection to the Oracle Java Cloud Server

    Hi all

    I'm deploying simple ADF Oracle Cloud application.

    I am transferred HR diagram to my cloud database service and now I'm trying to create a connection to the instance of oracle java cloud service

    but it's not to create a connection to the cloud server and throwing the error message


    Tests of cloud-Admin... has failed.

    listApplications failed.

    Check the username, password, domain, for example.

    Check the location of the sdk cloud & version: Tools-> Preferences-> Oracle Cloud

    0 out of 1 tests successfully.

    Here are the details MyService

    JDEV: Build JDEVADF_11.1.1.6.0CLOUD_GENERIC_121118.1600.6229

    Cloud-version: 13.2.2.0.0

    I'm sure, that I am using the appropriate powers since am capable of service cloud console java with the same credentials.

    Please help me on this.

    Thank you

    Check the location of the SDK by browsing "Tools-> preferences-> Oracle Cloud-> Cloud Service SDK Java", navigate to the folder and navigate to the directory of sup 'lib '. Check the version with the command:

    java-jar javacloud.jar - version

    Oracle Cloud Java Deployer of Service tool.

    Version: 13.2.7.0

    What is the version that was posted to you? If something else "13.2.7.0" try to download the latest version of the SDK, unzip it somewhere and point your Jdev on the new version.

    --

    Jani Rautiainen

    Relationship with the developers of Applications in fusion

    https://blogs.Oracle.com/fadevrel/

  • Create the connection using MySQLi?

    I / authentication of the connection of the lines of existing code on my web site, but they are written in MySQL. I understand that I have to upgrade these procedures for MySQLi language. While most of my server behaviors have been improved using the 3rd party of WebAssist extension, they do not have a solution out of the box for this problem, and I'm NOT a programmer. Ideally, I would like that the site works like most of the major sites where, if the user has forgotten his or her password, an e-mail link is sent to them where they have a link back in and reset his password. Can someone point me in the right direction? I use DreamWeaver CC on a Windows 7 system.

    I didn't know if the page Add - ons whatever it is for you or not, just a wild guess on my part.

    See #3 post in this discussion.  Osgood has posted an example of a safe log in MySqli.

    Re: Server behavior Extension & Database keeps re-download

    The part of password reset should a separate form and the script.

    Nancy O.

  • create the connection to the datafinder Server

    Is there a way to create a connection to the datafinder server in the script? I have a file location that must be typed in (you cannot find by browsing through the folders) and want to know if there are other methods of adding connections to the server.

    Thank you

    Artemis

    I was able to use the following which fixed my problem

    Call Navigator.ConnectDataFinder ("my DataFinder"). GetSettings(). SearchAreas.Add)
    Call Navigator.ConnectDataFinder ("my DataFinder"). Indexer.IndexFolder)

    But now I wonder if there is a way to check if a search box already exists in the datafinder.

  • Create the connection to the Oracle database

    How do I create oracle database connection using flex.

    Please mention all necessary codewise and sage (for flex as well as Oracle9i) configuration

    Thanks in advance.

    VjFlex,

    looking at your line of code

    url="DataConn.php?lal='sds'"
    

    I would not have thought you need them ' brands around sds. Unless your php code is something dindane special to manipulate, you would put normally just lal = sds and everything would be fine.

    You also say "Please pass the asp.net code, you did to do the same thing. Of course, I can't at the moment past on the actual code but the principles are the following (I use c# in ASP.NET as language server-side in this case and SQL server in the database and did not show the string for connection etc - you already know how to do as your database)

    sql_call = "select top 10 t1.a, t2.b, t2.c from t1, t2 where t1.id=t2.id order by a";sql_server_command = new SqlCommand(sql_call, sql_server_connection);sql_server_command.CommandType = CommandType.Text;sql_server_data_adapter = new SqlDataAdapter(sql_server_command);dataset = new DataSet();sql_server_data_adapter.Fill(dataset);datatable = dataset.Tables[0];call_encoded = "";for (int i = 0; i < datatable.Rows.Count; i++)  {    data_record = "" +      "" + datatable.Rows[i][0].ToString() + "" +      "" + datatable.Rows[i][1].ToString() + "" +      "" + datatable.Rows[i][2].ToString() + "" +      "";    call_encoded += data_record;  } // for icall_encoded += "";return call_encoded;
    

    Hope that helps. You can see that the returned table is converted into XML so that once back in Flex, it can be easily managed.

    Richard

  • Is there any example of code c# for the NI 9485 RSS

    Or how can I create my own code? I looked at the supplied dll and they do not seem to cover this module.

    As far as I know, you simply use the digital I/o functions. A 1/true to enable the relay and a 0/false to turn it off.

  • Example of Code that shows the geocoding reverse to a mailing address?

    Can someone well want to show an example or two so that I can have for clarification. I need to have a developed application that can get the current GPS position and reverse geocode the address.  I googled cela and have not been able to find a solution.

    Any help in this matter would be greatly appreciated

    Thank you

    I have a webwork extension that runs this code

    Historic landmark [] = Locator.reverseGeocode (address, Locator.ADDRESS);
    {If (landmark! = null & landmark.length > 0 & {landmark [0]! = null})}
    AddressInfo info = landmark [0] .getAddressInfo ();

    info.getField (AddressInfo.STREET)
    }

    But I think you coud use google gears on BB5 and BB6 on HTML5 Geolocation.

  • Need examples of code to parse the xml using kxml2

    Hello world

    I am a beginner for Blackberry, I want to get the data from the xml file. I look and see the section use of kxml2 is a better choice.

    But I can't find an example code for it on the Blackberry.  Can someone share me?

    I open kxml2.jar, I see xmlParser and kxmlParser, whoever I'm use()?

    Anbody can help me contact how to use kxml2 clearly?

    Thank you very much. Sorry for the bad English.

    --------

    Binh - VietNam

    Ah yes, sorry, I assumed automatically kxml to be used with ksoap2.

    kxml is a j2me parser commonly you can find sources in other forums, for example
    http://www.developer.Nokia.com/community/wiki/How_to_parse_an_XML_file_in_Java_ME_with_kXML
    http://j2mesamples.blogspot.com/2009/04/XML-parsing-in-J2ME.html

  • problem calling sql code when creating the record.

    Hi all

    I have an oracle form code where a fire trigger When_Create_Record in the code to trigger as follows:
    declare
                    v_cnt  number:=0;
                    v_frdt date;
                    v_todt date;
                    Y1     CHAR(2);
                    Y2     CHAR(2);
                    V_ID      PAY_APPLY_HDR.APPLY_NO%TYPE;
                    C      VARCHAR2(10);
                    
    begin
                    C:=FA_PKG_MST.FUN_FINYR(:PAY_APPLY_HDR.APPLY_DATE,V_FRDT,V_TODT);
                    
                    Y1:=TO_CHAR(V_FRDT,'YY');
                    Y2:=TO_CHAR(V_TODT,'YY');
                    
                    SELECT nvl(MAX(TO_NUMBER(SUBSTR(APPLY_NO,9))),0)+1 INTO V_CNT FROM PAY_APPLY_HDR
                    WHERE DIVN=:PAY_APPLY_HDR.DIVN AND SUBSTR(APPLY_NO,3,2)=:PARAMETER.P_PURPOSE_CD
                    AND APPLY_DATE BETWEEN V_FRDT AND V_TODT;
                                                                                                                     
                    V_ID:=:PAY_APPLY_HDR.DIVN||:PARAMETER.P_PURPOSE_CD||Y1||Y2||LPAD(V_CNT,6,'0');
      :PAY_APPLY_HDR.APPLY_NO:=V_ID; 
    END;
    How can I do this in class entity adf impl substitute create method.

    Is probably the simplest solution to this:

    (a) correction of your original code so that it uses a sequence number, and not the SQL courses

    (b) transform your original code in a PLSQL function in the database, and then in your EntityImpl create a JDBC wrapper function to call the stored procedure in database and call it from your create() EntityImpl and apply it to the Set accessor of the identification. This will fill the ID attribute that the folder is created.

    You do not forget however of this sequence number.

    CM.

  • Error - 21 code when create the installer for windows platform

    Hi experts, I am a beginner on labview, encounter this error when the application install build could any body help me on the error - 21, as shown below.

    what might be the cause? Thank you very much!

    CDK_Item_OnDblClick.VI.ProxyCaller > CDK_Item_OnDblClick.vi > CDK_InstallerConfiguration_Editor.vi > CDK_Build_Invoke.vi > CDK_Engine_Main.vi > CDK_Engine_BuildDevPart.vi > NI_MDF.lvlib:MDFBuildDevPart_SetOtherProperties.vi

    Loading information of product deployment
    Loading information of product deployment
    Loading information of product deployment
    Loading information of product deployment
    Adding files to install
     
    **************
    Internal error: A tool or the library returned an error. (Error code - 21)
    Final report of the error
    **************
     
     
    **************
    Error: Windows SDK function returned an error. (Error code - 12)
    Final report of the error
    **************

    Hi chenghao,.

    The error messages you provided are in fact rather generic, and as such, it is quite difficult to troubleshoot the problem only on that basis. I would like to ask you some questions to help me understand your problem better.

    What version of LabVIEW are you using? Also, the VI (or screws) you want to compile into an executable running on its own LabVIEW?

    Perhaps, it would be useful that you have downloaded your file VI and LabVIEW project (if you have one) as well as all other relevant records. If you do not have a LabVIEW project, please submit your application configuration settings.

    Thank you and looking forward to your response.

Maybe you are looking for

  • 30 GB of "other."

    I have 30 GB of 'other', how do I delete this?

  • Interference to Radio Mike

    When connect us our Toshiba Satellite M40 on our mixer and have plugged the radio microphone we get interference on the audio output of the laptop. We do not get interference with the standard pickups. This happens when we have another laptop (an Eve

  • Records of the initialization of the array of strings

    Hello. I posted my project. It's not even close to finished, but I have a problem during the initialization of the table entitled 'values' and 'down of values', '0' for all elements, at the beginning of the Vi run. So, when I'm at the front and execu

  • What version of XP Pro need me?

    Hi, I apologize in advance if this is a topic to repeat, but I can't find the answer I'm looking for. I recently asked to re - install windows on a laptop that has bought one of my friends off ebay it came pre-installed with Windows XP (he didn't say

  • HOW TO DOWNLOAD VIDEOS ON SANSA FUZE - SANSA MEDIA CONVERTER

    I DID IT! YAY! I AM ABLE TO CONVERT VIDEOS USING SANSA MEDIA CONVERTER! OK THIS IS WHAT I DID. I CALLED SANSA WHICH IS 1 800 SANSA. THEN I FOLLOWED ALL THE STEPS, THEY TOLD ME TO DOWNLOAD AND DO. IT IS WHAT YOU NEED TO DOWNLOAD IN ORDER TO CONVERT VI