|
||||||||||
| PREV NEXT | FRAMES NO FRAMES | |||||||||
See:
Description
Before starting, please ensure you have done the following:
1. Installed Java Development Kit 1.5.
2. Installed Eclipse 3.2 or higher.
3. Extracted the contents of this ZIP file to a folder.
4. Extracted the contents of the samples folder.
To use the Web21C SDK Services you will need to register your application and obtain a certificate from our website here: http://web21c.bt.com/.
The easiest way to get a certificate is running the Certificate Tool available to download in http://web21c.bt.com/application_registration. You can run the certificate tool as an executable JAR or as a Java webstart application.
On running the certificate tool you will be prompted to provide a name for your application, your web21c website user name, and your password. Select whether you would like the certificate for Sandbox (testing - free) or Production (release - charging) purposes using the radio buttons at the foot of the form. On clicking "Submit Certificate to web21c.bt.com for signing" the tool will submit a request for a certificate.
Save the certificate file (i.e. myNewApplication.pfx) to a suitable folder (i.e. myCertificates). You will need later to run your application.
The following steps will show you step by step how to create a simple application which uses the BT Web21C SDK.
Open Eclipse and create a new project for your application. Select File -> New Project -> JavaProject and hit Next. In the following screen, enter the name of your application (i.e MyApplication) and then click finish.
The next step is to add the Web21C JAVA SDK libraries. To do that, go to the Package Explorer Window and right click the Project -> properties. Select the Build Path on the left hand side panel and select the "Libraries" tab.
Click Add External JAR’s and browse to the folder where you extracted the Web21CSDK. Select the Web21C JAR file. Click OPEN to add them. Do the same for all the JAR files inside the Web21CSDK/Lib folder also. The references should now be added to the project.
Let’s now add a class to call the service. Right click the project heading under "Package Explorer" and select New-> Class. Specify a name for this (e.g. HelloSMS) and tick the "public static void main(String[] args)" checkboxes and click finish.
Add the following line at the top of the file to import the service. For this example we will be using MessagingOneWay.
import com.bt.sdk.capabilities.messaging.oneway.*;
Copy the following lines inside the Main function:
MessagingOneWayManager mm = new MessagingOneWayManager();
Message msg = mm.sendMessage("tel:+44xxxxxxxxxx", "SDKSample", "Hello from the sample app.");
System.out.println("MessageID: "+msg.getMessageId());
Before running the code, remember to replace the number with a valid telephone in the format: "tel:+<country code><telephone>" e.g. tel:+155555512345.
You need to associate the certificate we obtained earlier, with the application you have just created. To do this, copy the certificate file (i.e. myNewApplication.pfx) to the folder containing the sample application (i.e /MyFirstApplication).
Finally, copy the security.properties file which is inside the Web21C JAVA SDK Installation folder to the sample’s application folder.
The security file contains the following lines:
org.apache.ws.security.crypto.provider=com.bt.security.PKCS12Crypto
org.apache.ws.security.crypto.merlin.keystore.type=pkcs12
org.apache.ws.security.crypto.merlin.keystore.password=password
org.apache.ws.security.crypto.merlin.alias.password=password
org.apache.ws.security.crypto.merlin.file= <The name of your application pfx file>
constants.provider=com.bt.sdk.common.SandboxConstants
#constants.provider=com.bt.sdk.common.ProductionConstants
Specify the name of your certificate (.pfx file) where indicated, and replace the password with the password you entered when registering the application certificate. For example, if the certificate name is sampleApplication.pfx and the password selected is "PASS" then your security properties file should look like this:
org.apache.ws.security.crypto.provider=com.bt.security.PKCS12Crypto
org.apache.ws.security.crypto.merlin.keystore.type=pkcs12
org.apache.ws.security.crypto.merlin.keystore.password=PASS
org.apache.ws.security.crypto.merlin.alias.password=PASS
org.apache.ws.security.crypto.merlin.file= sampleApplication.pfx
constants.provider=com.bt.sdk.common.SandboxConstants
#constants.provider=com.bt.sdk.common.ProductionConstants
If the application is to use production services instead of sandbox, place a # symbol before the appropriate line to comment it out, like so:
#constants.provider=com.bt.sdk.common.SandboxConstants
constants.provider=com.bt.sdk.common.ProductionConstants
Everything is ready now to send a message. Run your sample by selecting RUN in the toolbox (If the configuration window is shown, just select Java Application on the left hand side and click ok).
If you have any questions or issues, please check our forums on http://web21c.bt.com/.
It should be noted that the Java SDK throws ArgumentExceptions for: Null and empty strings passed into for required parameters unless otherwise noted. Additionally, this exception can be expected for improperly formatted Uris and email addresses.
Thanks, and enjoy!
|
||||||||||
| PREV NEXT | FRAMES NO FRAMES | |||||||||