BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 10-19-2009, 08:01 AM   #1 (permalink)
New Member
 
Join Date: Oct 2009
Model: 9100
PIN: N/A
Carrier: BES
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Localhost connection setup for a newbie

Please Login to Remove!

hi
I am Newbie to blackberry development. I was working with wamp setup.i.e. Windows with apache, mysql and php. I have configured it read localhost. I have put an xml file in wamp folder such that when i access localhost file(ttp://localhost /xmlfile.ml), it renders me an sample xml file. now i want this xml output to be read by blackberry.
I searched for some threads in this forum. they suggested that chage localhost to some domain name, to do that add domain in system32\drivers\etc\hosts. This change was made but it didnot work. in some other thread they suggested to run mds server run localhost:8080 it gives the computer name from that you can access the site. but that to didnt work. in both cases i getting connection.getResponseCode() as HTTP_MOVED_TEMP(302).
Can any one tell me What is going wrong or how can we do it.

or suppose i want to put that xml file in mds server where to place that.

If i chage the URL from localhost to some URL which displays xml examples it is working fine but not in localhost.

Please guide me.

Last edited by skalluraya : 10-19-2009 at 08:04 AM.
Offline  
Old 10-19-2009, 08:30 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

Wirelessly posted (Bold)

You can't use localhost from the Blackberry to refer to the MDS server. You have to us the server's name or IP address.
__________________
My other Blackberry is a PlayBook.
Offline  
Old 10-19-2009, 09:10 AM   #3 (permalink)
New Member
 
Join Date: Oct 2009
Model: 9100
PIN: N/A
Carrier: BES
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for replying

I used Server name but I am getting 302 error
Offline  
Old 10-19-2009, 09:28 AM   #4 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

302 is not an error (necessarily), it is a redirect.

Did you look at the Location header to see what the redirect URL is?
Offline  
Old 10-20-2009, 04:54 AM   #5 (permalink)
New Member
 
Join Date: Oct 2009
Model: 9100
PIN: N/A
Carrier: BES
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Location is htp://localserver/xmlfile.xml. If this is not the location header then can u tell me from where do i get it. Sorry for my silly question but i am a newbie.

connection.getResponseCode() i get it as 302
connection.getResponseMessage() i get it as Found
but data is not there
when i access from browser i am getting the output

Last edited by skalluraya : 10-20-2009 at 04:57 AM.
Offline  
Old 10-20-2009, 05:44 PM   #6 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

When you get a 302, you should be requesting the location by retrieving the HTTP "Location" header.

Like this:

if ((m_responseCode == HttpConnection.HTTP_MOVED_TEMP) ||
(m_responseCode == HttpConnection.HTTP_MOVED_PERM)){

String location = m_httpConnection.getHeaderField("Location");

System.out.println("Redirect location: " + location);

// ....do something here
}
Offline  
Old 10-21-2009, 02:01 AM   #7 (permalink)
New Member
 
Join Date: Oct 2009
Model: 9100
PIN: N/A
Carrier: BES
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for the reply,

when i used connection.getHeaderField("Location");

it is redirecting to htp://guide.opendns.com/?url=localserver%2Fxmlfile.xml

This is redirected when the domain name is not found

that localserver i have pointed it to 127.0.0.0 in hosts file which is found in system32\drivers\etc\hosts.When accessed with browser i am getting it the xml file correctly. What might be the reason
Offline  
Old 10-21-2009, 11:01 AM   #8 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

Try stopping MDS, and using a direct connection in your program.

Append ";deviceside=true" to your URL.
Offline  
Old 10-26-2009, 01:55 AM   #9 (permalink)
New Member
 
Join Date: Oct 2009
Model: 9100
PIN: N/A
Carrier: BES
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for replying,

I got some improvement in the connection. If i use localserver/xmlfile.xml then my server was not connecting. If I use 127.0.0.1/xmlfile.xml then I will was able to connect to localhost server. I was appending ;deviceside=true to my URL. Why is it that it does not connect to localhost or renamed localhostserver. Does any one know that.

Thanks all of u guys.

Another question if i want to display the html page which is there on the server. how to do this? some thing similar to webview.
Offline  
Closed Thread


Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





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