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

Java Development

Reply
Contributor
Posts: 10
Registered: ‎12-12-2011
My Device: Developer- 9800, 9780, 9300, 9700, 9105, 9900, 9360
My Carrier: Wind
Accepted Solution

Problem connecting to server using the url with logical name!

[ Edited ]

Hello to everyone!

 

I've been searching a information on this matter, but haven't seem to found a solution.

 

I am developing a Smartphone application which needs to connect to a server  to retrieve some data. So I'm using a direct connection with the correct settings (I hope):

 

   url =   " server url"+ "deviceside:true" + "apn: ......"

 

The problem is that the connection should be done without hardcoding the  "apn". These are the tests I have done so far   (assuming I am always adding the "deviceside : true" parameter):

 

URL (logical name)    +   apn       OK!
URL (logical name)                      FAIL
URL (static ip)   OK !

 

*by logical name I mean an url like  www.google.com

 

What I need is to just use the logical name, without the apn parameter!!  Maybe I'm missing another parameter which I am not aware of??  

 

Some additional info which might be useful!:

  -  The server is a Vodafone server which, as it has been explained to me, should be on a RIM's white list (not sure what this means, but I guess it has to do with the fact that BB connections pass through RIM's servers at some point, and being in this list gives some kind of "privilege" when going through RIM's servers), and I am sure it is publicly accesible because (see next point)

 -  An android version of the application works fine without hardcoding the apn and using the logical name (I guess this has to do with RIM's servers! )

 

Any help or any ideas towards resolving this is greatly appreciated!!!  if I'm missing some info which you think I should add! please tell me so! 

 

Thanks for your help!!

Juan

 

 

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified
Contributor
Posts: 10
Registered: ‎12-12-2011
My Device: Developer- 9800, 9780, 9300, 9700, 9105, 9900, 9360
My Carrier: Wind

Re: Problem connecting to server using the url with logical name!

Thanks Peter!!!!

 

I was able to resolve it by looking at the code from the Network Api alternative in the link you sent me!

 

The solution was adding the ConnectionUID parameter to the url String!  as to why this resolves the problem I still don't understand it! (If you can enlighten me with the reason, I'd be most grateful )

 

This value was found inside the service books!, I post the code just in case it helps somebody!

 

String mUid = null

 

ServiceBook sb = ServiceBook.getSB();

ServiceRecord[] records = sb.getRecords();

 

for (int i = 0; i < records.length; i++)

{

         String cid = records[i].getCid().toLowerCase();

         String uid = records[i].getUid().toLowerCase();

 

         if ((cid.indexOf("wptcp") != -1) && (uid.indexOf("wifi") == -1) && (uid.indexOf("mms") == -1))

         {

              mUid = records[i].getUid();

         }

}

 

and then add the parameter :  ConnectionUID=mUid

 

Again, Thank you!!

 

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem connecting to server using the url with logical name!

"(If you can enlighten me with the reason, I'd be most grateful )"

 

perhaps.

 

Instead of using direct TCP, the option you are now using is WAP2, i.e the carrier gateway that was intended to be used for WAP web sites. The code you have will work for any carrier.  The isue with WAP is that I understand it is chargeable for some users.

 

In fact, for Vodafone, my experience suggests that WAP2 is the default connection method for Vodafone devices.  In addition, when Vodafone white lists a web site, my experience is that means that Vodafone (the carrier) will let you through to this site and will NOT interfere with the data passed between mobile phone and device (which they apparently can do).  This white listing only applies to Vodafone (as I understand it).

 

Anyway, if you are writing something for Vodafone, I think what you have is OK.  If you are writing it to be used in other carriers, then I'm not usre.  You might also think about popping up a warning that the data may cost the user. 

Highlighted
Contributor
Posts: 10
Registered: ‎12-12-2011
My Device: Developer- 9800, 9780, 9300, 9700, 9105, 9900, 9360
My Carrier: Wind

Re: Problem connecting to server using the url with logical name!

I had read some information on making a wap2 connection, but did not think it was the case as i had previously been able to make a connection by using direct TCP (with some test servers)... but as always in the "real world" things tend not to work as excepted!
Thanks again!!