08-26-2008 10:13 AM
hi, I just started leaning java development on BlackBerry about ten days ago.
Honestly, I feel a little bit frustrated. I read a lot of document, manual, watched instructional videos on the forum.
I havn't find a good starting point to accomplish my task yet.
Here is what I want to accomplish, I want to check an xml file on Internet, if the xml file is newer than the copy on BB, I have to download it, the access needs username/password. Then I have to parse the file, show the information on screen in different categories. for example, first screen would be all book names(should be a list, user can scroll down), then the user can pick a book, next screen will should show other details about the boot.
sounds not that complicate, right.
I have problem with the first step though. accessing the protected xml file.
when I started, I found two sample programs coming with JDE might help me.
BrowerFieldDemo and HTTPDemo.
The problem is when I typed the URL for the xml file(http://www.example.com/example.xml) in Internet Explorer, a message box will pop up and ask for username/password, but on BB, something else returned, a blank page with website name on the title, but the page is blank. I set breakpoint within the HTTPDemo program, I found the the response code is HttpConnection.HTTP_OK, instead of HttpConnection.HTTP_UNAUTHORIZED, which was I expected. I think that's why I don't even have a chance to provide the username/password to the website.
I am stuck here now. Any one can give me some direction? any link, document, sample code will help.
Thanks a million in advance.
08-26-2008 10:40 AM
Assuming your web server is using HTTP basic authentication, this sample should help you.
How To - Implement basic HTTP authentication
Article Number: DB-00468
08-26-2008 10:47 AM
Thank you for your reply.
Actually, that's excatly what frustrated me.
I already tried the code you gave me .
the program goes to HttpConnection.HTTP_OK branch, instead of HttpConnection.HTTP_UNAUTHORIZED branch.
in IE, if I type the url for the xml file, a messagebox will pop out and ask for username/password, if I click Cancel on that messagebox, then I can see Error 401, which is Unauthorized.
On BB, it gets the response HTTP_OK in the first place, then keepGoing = false and the loop is over. it won't do anything more.
I really don't know what I should do now.
08-26-2008 11:02 AM
Is your web server configured to use basic HTTP authentication or something else? You'll need this information before you can start to create an application that implements the correct authentication scheme.
08-26-2008 01:37 PM
HTTP Authentication section, I see
"The Mobile Data Service supports Basic Authentication only." and "By default, HTTP authentication is disabled on the Mobile Data Service. "
Are these true? So if the web server is not Basic Authentication, there is nothing else I can do?
And is the "By default, HTTP authentication is disabled on the Mobile Data Service." has anything to do with my program problem?
08-26-2008 02:40 PM
That article is out of date.
However, note that the MDS Connection Service does handle authentication for the BlackBerry Browser. The BlackBerry Browser will prompt a user for their login information, which will be used when making the connection.
This is not done automatically for third party applications. This means your application will need to set up the connection, request the login credentials from the user and provide them to the server in a manor appropriate with the authentication scheme in use on the server.
08-26-2008 03:28 PM
thank you. your reply enlightened me to try BB browser(not third party program) to test the link.
yes, it did prompt user the login screen(Great!).
But after I typed in username and password(I tried several times, to make sure I didn't typed them wrong), the page goes to a blank page with "abc company" as the title. after waiting long enough(just in case the slow downloading speed), still blank, so I believe it's not going anywhere. in IE, I do see the xml file content displaying. so the link is not invalid.
and one more different thing from IE is when I click Cancel on the login screen, IE gives me a page says Error 401: Unanthenticated. but on BB, when I click Cancel, it goes a blank page, same as I provide username/password, and click OK.
08-26-2008 03:57 PM