⚠️ DEPRECATED⚠️ Server side of the reference app for Bandwidth Voice and Messaging APIs
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Bandwidth Java Server Example for Mobile Voice Clients

The java-reference-app-voice is an example application to show how the Bandwidth Application Platform APIs can be used to build mobile voice applications. This example app is intended to work with the catapult-reference-app-voice-android and catapult-reference-app-voice-ios mobile applications to provide a working example of all the components synched together to provide SIP voice on your mobile device.

The java-reference-app voice is a spring based application that can be deployed as war in Tomcat or Jetty. These instructions document how to deploy the example on Heroku using jetty runner.

The java-reference-app-voice app exposes a simple REST interface to create an end user and return the credentials that allow the mobile device to connect to the App Platform registrar. A user is created as follows:

 POST /users
	"userName" : "steve", 
	"password" : "asdf1234876"

This returns the following:

HTTP/1.1 201 Created 
Location: /users/steve

	“userName”: “steve”,
	“phoneNumber”: “+13031234567”,
    	"id": "re-4kafmcjrd3hkrjyjf7o7v2q",
    	"name": "steve",
    	"domainId": "rd-5vvpzrsuwhiynrgkfw35miy",
    	"enabled": true,
    	"applicationId": "a-xiaoeen22dr44gfy5bpqgpy",
    	"credentials": {
      		"realm": "myDomain.bwapp.bwsip.io",
      		"username": "steve"
    	"sipUri": "sip:steve@myDomain.bwapp.bwsip.io"

The mobile app calls the server on start-up to create a user. It then uses the endpoint credentials to register with the App Platform SIP registrar.

The java-reference-app-voice app also processes calls. When creating the user, it associates the new App Platform phone number to an App Platform application, with the server url as the callbackUrl. This means all calls to that number are routed to the The java-reference-app-voice app.

When a call from the device comes in, the java-reference-app-voice app looks up the user associated with the SIP url to get the phoneNumber for that user. It then makes an outbound call to that number.

When a call is made to the phoneNumber, the java-reference-app-voice app looks up the sipUri for that phone and makes an outbound call to the device.

All this is enabled with the single REST API call to create a user.


To deploy this app on Heroku, you'll need the following:

  1. An Application Platform Account. Sign up here from one
  2. A Heroku account. Sign up here for one
  3. The Heroku toolbelt installed. See here for instructions on how to do this.
  4. A working Java 1.7 development environment.
  5. Maven 3.0 or greater

Steps to deploy

  1. Clone the repo
  2. Build it
  3. Create a new Heroku site
  4. Edit the properties file with user-id, api-token and api-secret, heroku server
  5. Push the app to the Heroku site
  6. Test it

Clone the repo

From a command prompt run the following:

git clone https://github.com/bandwidthcom/java-reference-app-voice.git
cd java-reference-app-voice

Build it

From the command line run:

mvn clean install

Create a new Heroku app

From the command line run the following:

heroku create

Edit the properties file with user-id, api-token and api-secret, heroku-url

With your favorite text editor open the src/main/resources/catapult-app-example.properties file and replace the following (these value are available in the App Platform developer console from the Accounts tab):

sandbox.user.id=<your app platform user id>
sandbox.api.key=<your app platform api token>
sandbox.api.secret=<your app platform api secret>

Push the app to the Heroku site

From the command line run the following:

git add .
git commit -m "updated config file"
git push heroku master
heroku open

Test it

Use the url from the heroku app to run the following curl command:

curl -H 'Content-Type: application/json' -d '{"userName" : "user1", "password" : "j7qIpoX48"}' -XPOST 'https://<heroku-site-url>/users'

Which returns: