SOAP API

Overview

Our SOAP gateway Web Service Definition Language (WSDL) is located here: https://api.sms.optus.com.au/ModicaSoap.wsdl

To send an SMS via SOAP, use the sendMessage operation.

You must access the Web Service via https, attempts to use http will be redirected to their equivalent http URL.

Parameters

The SOAP method to use for delivering an SMS to a mobile phone is named ‘sendMessage’ in the WSDL.

The parameters of this method are:

Parameter  *(mandatory fields marked with an asterisk) Description
application * Your application name as provided by Modica.
password * Your password for the application is provided by Modica.
destination * The mobile phone number the message is to be delivered to. This string must be a valid mobile phone number in international format. This usually means removing the leading zero and replacing with the country code preceded by a plus. For example: To deliver to the New Zealand handset 0274 123 4567 would require inclusion of +64 (for NZ) giving the format: +642741234567
content * Text to be sent verbatim to the mobile phone. Content must be submitted in the UTF-8 character set. The maximum message length that may be sent is equivalent to 10 SMS messages. Concatenated messages (messages that are larger than one standard SMS) are billed by the total SMS messages contained within the concatenated SMS message content. Note: The number of characters per SMS message depends on what character set is used.
reference Free form text field for your reference which may aid in reporting. This field is optional and can contain up to 50 characters.
requestSource Allows you to select the number your SMS originates from. This is generally only useful in applications that have many source numbers. In most cases (unless otherwise advised by Modica) you can ignore this parameter and use the class parameter instead.
customer   No longer used.
class Allows you to define the type of message. Classes are used to determine how to route and bill the message, as well as provide useful reporting information. Modica will supply you with set of valid classes available to your account.
cost   No longer used.
mask If you have a requirement for your SMS message to appear to come from something other than the MSISDN or shortcode you have been provisioned with, you can use the mask parameter to set this. NOTE: If you use a mask not configured in the list of available masks, the mask will be ignored, and the message will arrive from the source address of the application (e.g. shortcode). Masks are case sensitive.
replyTo ( long ) Default is 0.
smsClass (integer) Default is 1 (std sms), otherwise ‘NIL’
Parameter  *(mandatory fields marked with an asterisk) Description
application * Your application name as provided by Modica.
password * Your password for the application is provided by Modica.
destination * The mobile phone number the message is to be delivered to. This string must be a valid mobile phone number in international format. This usually means removing the leading zero and replacing with the country code preceded by a plus. For example: To deliver to the New Zealand handset 0274 123 4567 would require inclusion of +64 (for NZ) giving the format: +642741234567
content * Text to be sent verbatim to the mobile phone. Content must be submitted in the UTF-8 character set. The maximum message length that may be sent is equivalent to 10 SMS messages. Concatenated messages (messages that are larger than one standard SMS) are billed by the total SMS messages contained within the concatenated SMS message content. Note: The number of characters per SMS message depends on what character set is used.
reference Free form text field for your reference which may aid in reporting. This field is optional and can contain up to 50 characters.
requestSource Allows you to select the number your SMS originates from. This is generally only useful in applications that have many source numbers. In most cases (unless otherwise advised by Modica) you can ignore this parameter and use the class parameter instead.
customer   No longer used.
class Allows you to define the type of message. Classes are used to determine how to route and bill the message, as well as provide useful reporting information. Modica will supply you with set of valid classes available to your account.
cost   No longer used.
mask If you have a requirement for your SMS message to appear to come from something other than the MSISDN or shortcode you have been provisioned with, you can use the mask parameter to set this. NOTE: If you use a mask not configured in the list of available masks, the mask will be ignored, and the message will arrive from the source address of the application (e.g. shortcode). Masks are case sensitive.
replyTo ( long ) Default is 0.
smsClass (integer) Default is 1 (std sms), otherwise ‘NIL’
infoNote: A valid combination of application and  password parameters is required to authenticate and use the webservice.

For more information on SMS character sets and SMS concatenation please visit:

infoThis is enabled on a per account basis and is not available on all mobile networks, please check with your account manager if you are unsure whether this function is available in the country/carrier you are sending messages to
inforequestSource and class are mutually exclusive, please use one or the other
infoWhere the parameter is not specified as mandatory, or has a default value, it should be submitted as ‘null’ rather than left blank.

Sending SMS (SOAP)

To send your SMS application via SOAP, use the  sendMessage  method as defined in the  WSDL .

Outcome Description
Successful Response The SOAP message definition for a response to a sent SMS message is named ’ sendMessageResponse ’ in the  WSDL . It consists of a SonicMobileMessageStatus object (see the type in the  WSDL ). The object contains the messageid  allocated to that message by the Modica gateway, the queued status of the message for that recipient, the recipient mobile phone number, and the reference if in use. ****** Note:  Currently only one recipient per SMS is supported.
Failed Response On failure a SOAP fault exception will be returned containing a description of the error.

MO Callback

If you have supplied an MO callback URL within your API configuration.

When an MO message is received and routed to your application, a GET request is made to your MO callback URL. When you set the MO callback URL your URL should not contain a query string as that is automatically appended.

We recommend using https:// for your callback URLs.

infoImportant: If your callback URL includes authentication credentials, ensure all special characters are correctly URL encoded. For more information please visit https://www.w3schools.com/tags/ref_urlencode.asp
warningNOTE: The security certificate must match the domain name being used, self signed certificates will not verify and will generate errors.

Your server will then receive a GET request like this:

GET https://yourserver.example.com/receiveMessage?id=12345&source=%2B642741234567&destination=4433&content=SMS+message+content+here&operator=Telecom_NZ

The will contain the following GET parameters:

Parameter Description
id The gateway message ID.
source The mobile number of the sender (including the leading + and country code)
destination The destination short code or MSISDN
content The message content
reply_to The ID of the message this message is in reply to (only when a number sequence is used, and the MO is in reply to an MT message)
operator The Operator (mobile carrier) name that the message was sent from

If the message from the handset contains binary content, one additional parameter will be supplied:

Parameter Description
encoding The value “base64” will be supplied for messages containing binary data. Content will be supplied encoded using base64, decoding content is needed to obtain the original data. NOTE: Regular SMS messages with GSM 7-bit or Unicode content will not supply this parameter.

DLR Callback

If you have supplied an DLR callback URL within your API configuration.

When an DLR message is received for an MT message sent by your application, a GET request is made to the DLR callback URL. When you set the DLR callback URL your URL should not contain a query string as that is automatically appended.

We recommend using https:// for your callback URLs.

infoImportant: If your callback URL includes authentication credentials, ensure all special characters are correctly URL encoded. For more information please visit https://www.w3schools.com/tags/ref_urlencode.asp
warningNOTE: The security certificate must match the domain name being used, self signed certificates will not verify and will generate errors.

Your server will then receive a GET request like this:

GET https://yourserver.com/receiveStatus?id=54321&status=received

The will contain the following GET parameters:

Parameter Description
id The gateway message ID.
status The status text of the message
infoAll messages IDs will be returned as 64bit Signed Integers.

When an SMS MT message is successfully submitted via SOAP the gateway message ID is returned.

In order to track the status of a message you will need to store that ID, as status callback will use the ID to reference the message.

Possible statuses vary between carriers, for instance some carriers will mark a message as ‘rejected’ when the mobile number is invalid, the phone has insufficient credit or the message has been expired. Other carriers will differentiate between each of these events.

You will need to cater for the following statuses:

Status Description
failed Message delivery has failed due to carrier connectivity issue
sent Message has been sent by the carrier transport
frozen A transient error has frozen this message
dead Killed by administrator
received Message has been received by the handset
submitted Message successfully submitted to the carrier for delivery
rejected The carrier rejected the message
expired The carrier  was unable to deliver the message in a specified amount of time. For instance when the phone was turned off.

Example

https://yourserver.com/receiveStatus?id=54321&status=received

When an SMS MT message is successfully submitted via SOAP the gateway message ID is returned.

In order to track the status of a message you will need to store that ID, as status callback will use the ID to reference the message.

Possible statuses vary between carriers, for instance some carriers will mark a message as ‘rejected’ when the mobile number is invalid, the phone has insufficient credit or the message has been expired. Other carriers will differentiate between each of these events.

<?php
define('WSDL_URL','https://api.sms.optus.com.au/ModicaSoap.wsdl');
define('APPLICATION', 'your_application_name');
define('PASSWORD', 'password');
define('SEND_TO_MOBILE','+6421xxxxxxx'); // Mobile # Intl Format
define('MESSAGE_CLASS','mt_message');
define('MESSAGE_REFERENCE','');

try {
    $client = new SoapClient(
        WSDL_URL,
        array(
            'trace' => true,
            'exceptions' => true
        )
    );
    $return = $client->sendMessage(
        array('application' => APPLICATION,
              'password'    => PASSWORD,
              'destination' => SEND_TO_MOBILE,
              'content'     => 'This is a test message.',
              'reference'   => MESSAGE_REFERENCE,
              'class'       => MESSAGE_CLASS)
    );
} catch (SoapFault $fault) {
    // log error here
}
?>

Error Codes

The response that the gateway returns on errors will depend on the API version you request.   The following errors can occur:

Code Message Description Response code
Modica.authenticationInvalid Invalid application authentication. The Application and password parameters are missing or incorrect 400
Modica.invalidDestination Destination mobile number [destination] rejected Destination does not match this regex /^+{0,1}[1-9]{1}[0-9]{7,15}$/) 400
Modica.queueFailed Could not queue message The gateway was unable to create the message. The most likely cause for this is that the destination number was not valid or the mobile network for that number hasn’t been setup on your account. 400
Modica.serviceFailed An unexpected error has occurred while creating this message. 400
infoWe have identified a possible HTTP compatibility issue which affects .NET SOAP clients connecting to an Apache webserver. Our fix for this is adding the following parameter to your config before making the SOAP call: System.Net.ServicePointManager.Expect100Continue = False. This should allow the request and response to be sent and parsed correctly.

Help

Having trouble integrating with any of our services? Visit our helpdesk at https://sms.optus.com.au/docs/ or contact optussd@modicagroup.com and we’ll help you sort it out.