Tech Blog

SMS Proxy Adapter

General Purpose

This post explains how to add a Java class file that implements an SMS Proxy adapter supporting an additional provider.

An SMS Proxy is installed as a “.war” file in your JBoss / Tomcat  _deploy_  directory.

By default, the SMS Proxy supplies two adapters. Each adapter supports sending SMS messages via one of the following
providers:

Interface Type

Adapter.

 

Instructions

To add this SMS Proxy adapter:

  1. Download the OneSMSProvider.zip file by clicking the Attachments link at the top of this page. This zip file includes a directory called OneSMSProvider.
  2. Extract this directory to your hard drive (for example, to: C:\eclipse\workspace).
  3. Open your Eclipse application.
  4. In the Java perspective, right-click within the Package Explorer area and select Import.

  1. In the Import dialog box, select General > Existing Project into Workspace and click Next.
  2. Browse for the location in which you placed the OneSMSProvider directory, and select this directory.

  1. Create a new Java class file that implements the provider.java interface. The class may have any name, but a good practice is to use the suffix Provider at the end of the name. You can look at ClickatellProvider.java class for an example. Alternatively, you can rename the ClickatellProvider.java file and use it as a template.
  2. To build the .jar file, right-click the build.xml file and select Run As > Ant Build. The build.xml file is an Ant file, which will compile your Java source file into a class file and pack it into SMS-Provider.jar (it will exclude for packaging both ClickatellProvider.class and Provider.class).
  3. Copy the .jar file from C:\eclipse\workspace\OneSMSProvider\target\lib to a directory on the server. For example:
    /exlibris/primo/OneSMSProvider/target/lib
  4. Configure SmsProxyConf.xml to use the class you have just created (see the SMS Proxy documentation for more information).
    Note that you must include the ExternalJarLocation element to tell the system where your JAR file is located. For example: <ExternalJarLocation>/exlibris/primo/OneSMSProvider/target/lib</ExternalJarLocation>
  5. Restart JBoss so that the changes in SmsProxyConf.xml take effect.

You are now able to use the SMS Proxy APIs to send SMS messages with your SMS provider.

Methods

submitMessage

public void submitMessage(java.lang.String user,
        java.lang.String password,
        java.lang.String phone,
        java.lang.String callback,
        java.lang.String message)

Submit an SMS message according to the SMS provider API spec.

It is not expected to return a value, but is expected to fill the string variables which are required for the reply XML:

proxyCode and proxyText are meant to be used for issues that were identified before contacting the provider.
providerCode and providerText are meant for the messages received from the provider.
messageID is a string which the provider returns as an identifier to check the status of the SMS, and it can be used with the method statusQuery.

Specified by:
submitMessage in interface com.exlibris.core.sms.proxy.Provider

Parameters:
user – as defined in SmsProxyConf.xml as ‘ProviderUser’
password – as defined in SmsProxyConf.xml as ‘ProviderPassword’
phone – phone number of the recipient
callback – the name or phone number of the sender as will be displayed in the SMS
message – the body of the SMS message

 

statusQuery

public void statusQuery(java.lang.String user,
        java.lang.String password,
        java.lang.String messageId)

Check the status of an SMS message submitted – whether it has reached the recipient or not.
It is not expected to return a value, but is expected to fill the string variables which are required for the reply XML:

proxyCode and bt are meant to be used for issues that were identified before contacting the provider.
providerCode and providerText are meant for the messages received from the provider.
messageID is a string which the provider returns as an identifier to check the status of the SMS, and it can be used with the method statusQuery.

Specified by:
statusQuery in interface com.exlibris.core.sms.proxy.Provider

Parameters:

user – as defined in SmsProxyConf.xml as ‘ProviderUser’
password – as defined in SmsProxyConf.xml as ‘ProviderPassword’
messageId – a alphanumeric string which was received from the provider identifying the specific SMS message, when running the method submitMessage 

 

getMessageId

public java.lang.String getMessageId()

Specified by:
getMessageId in interface com.exlibris.core.sms.proxy.Provider

 

getProviderCode

public java.lang.String getProviderText()

Specified by:

getProviderText in interface com.exlibris.core.sms.proxy.Provider

 

getStatus

public java.lang.String getStatus()

Specified by:

getStatus in interface com.exlibris.core.sms.proxy.Provider 

Attachments:

TypeNameSizeCreatorCreation date
GIF Filestructure_project.gif4 kBIlana SacknovitzJul 21, 2008 14:22
GIF Fileimport.gif12 kBIlana SacknovitzJul 21, 2008 14:20
GIF Fileaccess_details.gif13 kBIlana SacknovitzJul 21, 2008 14:16
ZIP ArchiveOneSMSProvider.zip13 kBIlana SacknovitzJul 21, 2008 14:10

2 Replies to “SMS Proxy Adapter”

  1. Hi,

    Has anyone successfully enabled SMS in Primo? We have followed the documentation. Configured SmsProxyConf.xml to use a built in Provider Clickatell. We even created our own jar file using Twilio. Configured the SmsProxyConf.xml. We still get this error when trying to send SMS.

    configuration error:failed to parse SmsProxyConf.xml

    Are there any logs we can look at to determine what we are missing? To the best of our knowledge, we haven’t found any institution that has got this working. So many have been looking for answers.

    Thanks

  2. Hallo, has this guide worked for anyone ? In my Aleph instance it seems the SMS proxy application doesn’t load my custom jar, even if is correctly declared on SmsProxyConf.xml. The error I receive is [http-bio-1891-exec-1] [] [SmsProxy] configuration error: illegal provider component definition [http-bio-1891-exec-1] [] [[/core-sms-proxy]] Error: com.exlibris.core.sms.proxy.MyOwnProvider is defined in SmsProxyConf.xml, and cannot be located. Do I need to reference my custom provider class in a different way ?
    Thanks

Leave a Reply