Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

BlackBerry Web Services

Reply
New Contributor
Posts: 5
Registered: ‎11-07-2011
My Device: 8320
My Carrier: china mobile
Accepted Solution

bws sample error

I did a sample step by step by BlackBerry Web Services for Enterprise Administration Getting Started Guide document, but has an error "HTTP response '401: Unauthorized' when communicating with https://MYSERVER:3443/enterprise/admin/ws", but the user can login webconsole use blackberry administation service, I use BlackBerry Enterprise Server Express for Microsoft Exchange 5.0.3, any solution?

Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: bws sample error

Hi and welcome to the forums!

 

Are you using an active directory or BAS user? The sample was only created to handle BAS users.

Another possible cause, does the user have permission to perform the action where the 401 is returned? What line results in the HTTP 401?

 

Regards,

Garett
@garettBeuk
--
Goodbye everybody!
New Contributor
Posts: 5
Registered: ‎11-07-2011
My Device: 8320
My Carrier: china mobile

Re: bws sample error

[ Edited ]

Thanks for reply. I use BAS user, log the web console works fine. And the use has all roles and in all groups,but has error like this "HTTP response '401: Unauthorized' when communicating with https://MYSERVER:3443/enterprise/admin/ws" in this line  GetUsersResponse response = _bws.getUsers(request),

 

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

 

Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: bws sample error

What does your encoded username look like for this user?

Could you go in to the BAS console, open the user that you are using with BWS and take a screenshot of their information page including the "Authentication type" information and post back to this thread?

Garett
@garettBeuk
--
Goodbye everybody!
New Contributor
Posts: 5
Registered: ‎11-07-2011
My Device: 8320
My Carrier: china mobile

Re: bws sample error

EncodeUsername:8,22,0,1,1,0;bwsadminmyserver:344300

 

User information
Display name: bwsadmin                      User ID: 7 


Authentication type                                           User name                        Password 
BlackBerry Administration Service                bwsadmin                          ********  

Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: bws sample error

It looks like your username is being encoded incorrectly. I'm assuming "myserver" is the domain? The domain is only needed if using Active Directory, using it without would cause the 401, assuming you have no BAS user with the name "bwsadminmyserver". If you need help investigating the code to fix this then please post the snippet where you set up your GetEncodedUsernameRequest object.

 

Regards,

Garett
@garettBeuk
--
Goodbye everybody!
New Contributor
Posts: 5
Registered: ‎11-07-2011
My Device: 8320
My Carrier: china mobile

Re: bws sample error

Problem resolved! I removed  the  setDomain code as bellow by your hint. It works fine. Thanks a lot!

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

New Contributor
Posts: 3
Registered: ‎01-29-2014
My Device: 9700
My Carrier: at&t

Re: bws sample error

I am facing same issue.  am not usng setDomain().


I am trying to connect with our BES server pragmatically to get info like users and policies etc. Our enterprise server version is 5.03. I have created client classes as per RIM   documentation using CXF  1.6.1 after downloading certificate. I downloaded simple example   from RIM site to test the service calls. I am using authtication type "BlackBerry Administration Service".

I am able to make calls with BWSUtil like, getLocale and authentcators etc. But for any call with BWS like getInfo, getusers throws 401: "Caused by: org.apache.cxf.transport.http.HTTPException: HTTP response '401: Unauthorized' when communicating with https://EC2AMAZ-E2037Y4.NTTDATAMOBILELAB.COM/enterprise/admin/ws"

 am using admin credentials for testing.

 I noticed in log encoded user name put 00 at then end like:    "8,0,0,1,1,0;besadmin00"

Any idea whats wrong here?