A BlackBerry smartphone
application has multiple paths that it can use to access data located
outside of the device (most likely on a server somewhere). A path is the
route the request (and corresponding response) takes to get from the
device to the server and back. The BlackBerry browser and BlackBerry Java applications can access servers using any of the paths. The options are
Wireless Application Protocol (WAP)
Direct TCP
BlackBerry Internet Service (BIS)
BlackBerry Mobile Data System (MDS)
Wi-Fi
A
good understanding of connections is important because application
developers often need to decide which path to use to get to their data
and write the code that the connection needs to use that path. When a
developer doesn’t understand all the available options, the option
selected might not be the best one for the application or the mobile
user, and the application might not work if the wrong connection path is
used. When building applications, RIM recommends a different
prioritization of transports, depending on the intended audience for the
application. Applications should try the first transport and move down
the list until a connection can be made.
For Enterprise applications, RIM recommends the following prioritization:
BlackBerry Mobile Data System (MDS)
Wireless Application Protocol (WAP) 2.0
BlackBerry Internet Service (BIS)
For consumer applications, RIM recommends the following prioritization:
Wireless Application Protocol (WAP) 2.0
BlackBerry Internet Service (BIS)
BlackBerry Mobile Data System (MDS)
The following sections cover the various connection paths and highlight the strengths and limitations of each.
1. Wireless Application Protocol (WAP) Connection
Before smartphones, back in
the days of the early feature phones, carriers wanted to provide their
customers with access to Internet-based resources. Because of the
limitations of these devices (processing power, browser capabilities,
and network bandwidth) a special protocol was created to provide a
subset of typical desktop web-browsing capabilities to mobile devices.
This protocol, WAP, required special gateways provided by the wireless
carriers and used a special, reduced capability mobile page markup
language called Wireless Markup Language (WML).
WAP
used to be the most consistent way to access the Internet from mobile
phones—both smartphones and regular mobile phones supported the
protocol. Today, WAP gateways are still provided by carriers and there
are a lot of services still offered via WAP.
When you open a WAP
connection, either through a URL opened in the WAP browser or through a
connection from a Java application, the request takes a special route
through the WAP gateway provided by your wireless carrier. As shown in Figure 1,
a WAP request travels from the BlackBerry device (1) to the carrier’s
WAP gateway (2), and then out to the public Internet (3). The response from the server
follows the same path only in reverse order. The WAP gateway acts as a
proxy for the requests made by the device and can reformat the data
(convert HTML to WML, for example) returned to the requesting
application.
When connecting via WAP from a
Java application, the way it’s done varies depending on which version
of WAP you use. With WAP 2.0, your application must append the unique ID
(UID) of the WAP 2.0 Service Book to the Connector.open
command. To implement this, your application must first locate the WAP
2.0 Service Book, then retrieve the UID for the Service Book and include it as a parameter in the call to Connector.open:
HttpConnection conn = (HttpConnection)Connector.open(
"http://somewapsite.com;ConnectionUID=WAP2 trans");
You can’t just assume the name
of the UID; you must look up the WAP 2.0 Service Book on every device
your application runs on, unless your application is only targeted to a
single carrier’s customers and you are comfortable hard-coding
it in your application. Although it might look like you can make an
assumption about the UID for the Service Book, it is possible that the
carrier will use a different value in the Service Book it pushes to a
device. Additionally, Service Book settings can change at any time and
be pushed to the device, so it is risky to hard-code the Service Book
information.
Note
On the BlackBerry, the implementation of WAP 2.0 is just a Service Book-based TCP connection. |
If your application is using a WAP 1.0 or WAP 1.1 connection, you must append the Access Point Name (APN) provided by the carrier for the WAP connection. In the following sample Java code, both WAPGatewayAPN and WAPGatewayIP are required parameters for the call to Connector.open:
HttpConnection conn = (HttpConnection)Connector.open(
"http://somewapsite.com;WapGatewayIP=0.0.0.0;WapGatewayAPN=
apn_name");
As with the WAP 2.0 connection,
to use the WAP 1.0/1.1 connection provided by the carrier, you need to
locate the Service Book for the connection and retrieve the values for WAPGatewayAPN and WAPGatewayIP to use in your application.
2. Direct TCP Internet Connection
Another way to access the
Internet from either a browser or Java application is to use an Internet
connection using Transmission Control Protocol (TCP), called Direct
TCP. The Direct TCP request takes a route from the BlackBerry device (1)
through an Internet gateway provided by the carrier (2) to the server
processing the request (3), as shown in Figure 2. The path is similar to the one shown in Figure 1,
except that the request is delivered through an Internet gateway
located at the carrier data center rather than a WAP gateway. The
Internet gateway does not perform any reformatting of the data as it is
returned to the application requesting the data.
When opening a connection
using Direct TCP, the application must use the APN for the particular
device’s current wireless carrier. The easiest way to do this is to
direct the BlackBerry to select the APN automatically as shown in the
following Java code:
HttpConnection conn = (HttpConnection)Connector.open(
"http://www.somesite.com;deviceside=true");
In this example, the deviceside=true
parameter tells the device to manage the connection rather than
directing it through MDS (described next) or through a specific APN
(either provided by the user or the carrier). In many cases, the device
will not be provisioned by the carrier with the information the device
needs to determine the APN, and the connection will fail.
You can specify the specific APN to use for the connection, as follows:
HttpConnection conn = (HttpConnection)Connector.open(
"http://www.somesite.com;deviceside=true;apn=apn_name");
This might be problematic
because you need the user to provide the name of the carrier’s APN or
you have to build logic into your application to know the APNs for every
carrier network you support with your application.
Some APNs require that
credentials are provided when the connection is made. The credentials
are appended to the URL string passed to Connector.open, as shown here:
HttpConnection conn = (HttpConnection)Connector.open(
"http://www.blackberry.com;deviceside=true;
apn=wap.cingular; TunnelAuthUsername=some_username;
TunellAuthPassword=some_password");
3. BlackBerry Internet Service Connection
The
BlackBerry Internet Service (BIS) is a special service that BlackBerry
users can subscribe to from their carriers to provide Internet access to
BlackBerry smartphones. In most cases, enterprise-activated BlackBerry
devices already have this capability (BIS is included with most, if not
all, BES plans), but consumers purchasing BlackBerry devices must be
provisioned for BIS to be able to access their mail (up to ten personal
mail accounts) on the device, browse the Internet, and run
Internet-enabled applications.
One of the issues with
Direct TCP connections to Internet-based servers is that an application
might not be sure whether the connection parameters have been set or set
correctly or, if not set, what they might be. RIM created a special
connection type called BlackBerry Internet Service – Browser (BIS-B),
which eliminates the carrier dependencies inherent in making
connections.
BIS-B routes the request
from the BlackBerry smartphone (1) through the carrier’s network (2) to
the BlackBerry infrastructure (3) to the destination server (4), as
shown in Figure 3.
It eliminates any requirement for the device to understand anything
about the carrier’s connection to the Internet. Unfortunately, today,
this option is only available to ISV Alliance Partners, but RIM has
stated that it might open this to other developers in the future.
When
using this connection type, be careful how much data you send across
it. Because the connection goes through the BlackBerry infrastructure,
it is possible that RIM will restrict how much data you send through
this connection. Contact RIM for information about how to become a
member of the ISV Alliance Program.