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

Web and WebWorks Development

Reply
Contributor
Posts: 15
Registered: ‎05-03-2011
My Device: 9900 Bold
My Carrier: bell

How To: Blackberry WebWorks Apps with Corporate Intranet Data Access (OS 7)

This post describes the process I followed to successfully pull Windows authenticated JSON data from a service on a corporate intranet server using a BlackBerry simulator.  These notes comprise the solution I found for an earlier post: http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Remote-data-access-to-corporate-...

 

  • You can use the Visual Studio 2008 BlackBerry plug-in to create your initial app structure.  This will create a config.xml file and an index.htm page.  Alternatively, copy and modify config.xml from another app.

 

  • In config.xml, include an “access” tag specifically referring to your target server (ie. The one hosting the service) exactly as shown below:

<access uri="http://myServer.myCompany.ca/" subdomains="true" />

 

  • Save all relevant files in a folder to be packaged later as a .zip file by the Ripple “Package” functionality.  Make sure there are no “bin” or other similar folders; these can break the build and result in errors such as [ERROR]: Invalid application archive – reserved directory found .

 

Data Access in Ripple:

  • Use a relative path from the root of localhost (ie. /AppName/service/servicePage.ashx?param=data) to get to the service providing the data.
  • Set “Cross Domain Proxy” to “Remote”

 

 

  • In the Ripple control panel under “Build” make sure the Build and Deploy services are running (click the Start Services button if the services are not already started).

 

 

  • An important Settings note: If you want to enable debugging using the Remote Web Inspector tool, ensure the “Enable Remote Web Inspector” checkbox is checked.

 

 

  • Click “Package” to start the package and build process.  This will create a .cod file that can be used in a simulator and on a device.

 

  • When you have a successful build, open the simulator representing the device on which you want to test your app.  It is assumed that you have one or more simulators installed and are familiar with their use.  The observations detailed in this document are based on the use of the 9900 Bold OS 7.1.0.523 simulator. Note that Ripple includes a “Package and Launch” button that purports to do both steps together, but I have not had much success with it.

 

 

 

  • I used both this code

       xmlHttp = new XMLHttpRequest();  // works in simulator with MDS on

 

        xmlHttp.open('GET', urlLogin, true);

        xmlHttp.onreadystatechange = callbackFunction;

        xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

        xmlHttp.send(null);

 

and this code

       $.get(urlLogin,function (data) {

                alert(data);

            });

 

to get a working example.

 

 

 

Key Points in Summary

 

  • In Ripple, don’t include the domain name in the URL – use an absolute path without the domain name eg. /myApp/services/servicePage.ashx
  • In the code compiled for the simulator the domain name must be included eg. http://myServer/myCompany.ca/myApp/services/servicePage.ashx
  • The domain name in the code above must be matched by an access parameter in config.xml   eg. <access uri="http://myServer.myCompany.ca/" subdomains="true" />
  • The MDS simulator must be running to access data from a WebWorks app in the device simulator
  • Will work with both jQuery and vanilla Javascript

 

Hopefully this will be helpful to someone.

 

Jim Ashton

Retired
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: How To: Blackberry WebWorks Apps with Corporate Intranet Data Access (OS 7)

Thanks for posting, Jim!

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.