Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Updated using 4PSA automated script

Excerpt

This example written in Java allows developers to manage VoipNow accounts. Download.

Table of Contents
maxLevel3

...

What This Example Does

This example uses SOAP calls to do the things specified below.

...

The parent of this organization is a randomly chosen service provider. Also, a random charging plan is assigned to this account from account from those created by its parent.

...

The parent of this user is a randomly chosen organization. Also, a random charging plan is assigned to this account from account from those created by its parent.

...

The parent of this extension is a a a a randomly chosen user. Also, a random charging plan is assigned to this account from account from those created by its parent.

...

Note
titlePossible Problem

You might have a problem if the tool for running the example uses a JDK JDK used to run the examples is older than the JDK used for building to build the .jar files.

Setup

Please download the tool archive.files from our GitHub repository:

Code Block
git clone https://github.com/4psa/systemapi-example-java.git

 

In order to be able to test the tool, you need a Java IDE. Please follow these steps:

...

The jars from the archive

  • Services-test-client.jar
  • XBeans-packaged.jar
The jars required by Axis2You can find them in AXIS2_HOME\lib and AXIS2and AXIS2_HOME\lib\endorsed.

STEP 4: Configure some variables from the the Constants.java file.  The The following constants must be changed for the example to work:

  • VOIPNOW_URL: the URL of your your VoipNow server with the http://<VOIPNOW_SERVER_IP>/ or https://<VOIPNOW_SERVER_IP>/ format
  • ACCESS_TOKEN: the token generated with an authorized VoipNow application. You may find more info about how to generate the token here:   Access Management.

STEP 5: Run the project. Observe the results in the console of the IDE. Look in the the VoipNow interface to check the results. At least a service provider must be added.

...

The credentials are passed as a UserCredentialsDocument  UserCredentialsDocument class:

Code Block
languagejava
// this is the object representing the credentials
UserCredentialsDocument ucd = UserCredentialsDocument.Factory.newInstance();
UserCredentialsDocument.UserCredentials cred = UserCredentialsDocument.UserCredentials.Factory.newInstance();
// set the token generated with an authorized application
cred.setAccessToken(Constants.ACCESS_TOKEN);
ucd.setUserCredentials(cred);

...

Code Block
java
java
// Create the AddServiceProvider object
AddServiceProvider add_sp = AddServiceProvider.Factory.newInstance();

//Set the company for the Service Provider
add_sp.setCompany(Constants.COMPANY);

//Set the name of the Service Provider
add_sp.setName(Constants.NAME);
...

STEP 4: Wrap the the AddServiceProvider object into AddServiceProviderDocument a AddServiceProviderDocument object and call the the addServiceProvider method on the stub:

...

The response is represented by an AddServiceProviderResponse an AddServiceProviderResponse object:

Code Block
languagejava
AddServiceProviderResponse response = response_document.getAddServiceProviderResponse();
// information from the response 
System.out.println("operation status: " + response.getResult());
Tip

This and more examples can be found in the downloaded packagecloned repository.

Except where otherwise noted, content in this space is licensed under a Creative Commons Attribution 4.0 International.