1. Home
  2. Docs
  3. Order API
  4. Detailed information
  5. Sample code

Sample code

Sample code in JAVA can be made available to you once they have been approved and an account has been established on the Test Environment. We will provide ½ day of consultancy to support any integration should this be required and additional consultancy can be purchased.

It is recommended to use Java (JDK) 7 or 8 with the sample code. The use of Maven v3 (https://maven.apache.org/) is also required to enable execution of instructions provided in below.

The sample code shows the minimum code required using Apache CXF to create, send and receive a correctly authenticated and signed ‘checkInventory’ request for a reseller called TestReseller. There are 2 packages – com.siphon.reseller.transactions_10 and sample.

com.siphon.reseller.transactions_10

This contains the auto-generated classes from the WSDL. For reference this code was generated with the CXF wsdl2java tool – http://cxf.apache.org/docs/wsdl-to-java.html

sample

This contains 2 classes:

  • KeystorePasswordCallback.java –this provides the key password of the TestReseller private key.
  • ItemAvail.java – this contains the main method and queries the API for stock quantities for 2 products 2200-30900-025 and 2200-30900-025, printing the results to the console.

Execution Steps

To execute the sample code simply untar the package and once in the directory use the following command:

mvn clean compile exec:java

You should now see something like the below return:

Sending Request
2 records returned
2200-30900-025 : 8.0
2200-17445-001 : 3.0

It should be noted that the default log level is set to INFO so very little detail is sent to the console.

Sample Certificates

In the resources directory, you will find three certificates. These are copies of the ones contained within the TestReseller.jks keystone used by the sample code, and include:

  • SiphonAPIPublicKeyCertificate.pem – all responses will be signed with this key (except errors).
  • TestResellerPublicKeyCertificate.pem – this is the part a reseller has to provide to Nuvias during the on boarding process.
  • TestResellerPrivate.pem – the private key, which the reseller should keep secure and not disclose. The passphrase for this key is ‘TestReseller’.
Was this article helpful to you? Yes No

How can we help?