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
Developer
bb_cladsa
Posts: 58
Registered: ‎01-14-2010
My Device: 9000

Unathorized exception when communicating with BlackBerry Administration API webservices

[ Edited ]

 

I was trying to use the sample BAA application (TestMain.java) after following the steps in the BlackBerry Administration API knowledge base article - http://supportforums.blackberry.com/t5/BlackBerry-Enterprise-Server/Sample-application-demonstrating...

 

I noticed that the code fails when trying to find matching users using findUsers.

 

Here is a part of the stack trace: 

 

Exception in thread "main" javax.xml.ws.WebServiceException: Could not send Message.
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
at $Proxy33.findUsers(Unknown Source)
at ref.findUsers(ref.java:120)
at ref.main(ref.java:169)
Caused by: org.apache.cxf.transport.http.HTTPException: HTTP response '401: Unauthorized' when communicating with https://my_bas_url/baaws/core/ws
I have also attached my console log for more information.

Anyone have any similar issues?
Thanks
Retired
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: Unathorized exception when communicating with BlackBerry Administration API webservices

Are you using BAS or AD credentils? Have you set up your code to authenticate properly against these credntials?

http://docs.blackberry.com/en/developers/deliverables/25824/Specify_the_auth_credentials_1430117_11....

 

Please include the snippet of code being used for authentication in your reply.

Garett
@garettBeuk
--
Goodbye everybody!
Developer
bb_cladsa
Posts: 58
Registered: ‎01-14-2010
My Device: 9000

Re: Unathorized exception when communicating with BlackBerry Administration API webservices

I'm using BAS credentials.  Here is the snipet of code:

 

 

String username=System.getProperty("username");
String password=System.getProperty("password");
//call encodeUsername
String myEncodeUsername=_myUtilWSStub.encodeUsername(username, null, null, 0, "0");
//set http basic authentication on web service
BindingProvider bp = (BindingProvider)_myCoreWSStub;
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, myEncodeUsername);
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
String username=System.getProperty("username");
String password=System.getProperty("password");
//call encodeUsername
String myEncodeUsername=_myUtilWSStub.encodeUsername(username, null, null, 0, "0");
//set http basic authentication on web service
BindingProvider bp = (BindingProvider)_myCoreWSStub;
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, myEncodeUsername);
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);

 

 

 

I have also attached the file for reference.

 

Thanks

Developer
bb_cladsa
Posts: 58
Registered: ‎01-14-2010
My Device: 9000

Re: Unathorized exception when communicating with BlackBerry Administration API webservices

Forgot to attach the file.

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

Re: Unathorized exception when communicating with BlackBerry Administration API webservices

[ Edited ]

What are the values of your username and myEncodeUsername? Are you able to log in to the BAS console using the same username and password? If so, can you successfully search for users with this account?

Garett
@garettBeuk
--
Goodbye everybody!
Developer
bb_cladsa
Posts: 58
Registered: ‎01-14-2010
My Device: 9000

Re: Unathorized exception when communicating with BlackBerry Administration API webservices

Say my username is BAdmin, encodeUsername is "8,0,0,1,1,0;BAdmin00"

 

I can log into BAS console and search for users.

 

Thanks for the quick responses.

Developer
bb_cladsa
Posts: 58
Registered: ‎01-14-2010
My Device: 9000

Re: Unathorized exception when communicating with BlackBerry Administration API webservices

Just found out my problem - The admin user i was using had an authentication type of Active Directory and I was trying to use BAS instead. Fixed it :smileyhappy:. Thanks for all the help.