SOAP API
PHP
<?php
define('WSDL_URL','https://api.sms.optus.com.au/ModicaSoap.wsdl');
define('APPLICATION', 'your_application_name');
define('PASSWORD', 'password');
define('CUSTOMER', 'your_customer_name');
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,
'customer' => CUSTOMER,
'class' => MESSAGE_CLASS)
);
} catch (SoapFault $fault) {
// log error here
}
?>
Perl
#!/usr/bin/perl
use strict;
use warnings;
# Utilise the following when developing to enable debugging:
# use SOAP::Lite +trace => 'all';
use SOAP::Lite;
my $BASE_URI = 'api.sms.optus.com.au/ModicaSoap';
my $WSDL_URL = 'https://' . $BASE_URI . '.wsdl';
my $PROXY_URL = 'https://' . $BASE_URI;
my $NAMESPACE = 'http://' . $BASE_URI;
my $service = SOAP::Lite->service($WSDL_URL);
$service->proxy($PROXY_URL);
$service->default_ns('ns1');
my $method = SOAP::Data->name('sendMessage')->attr({xmlns => $NAMESPACE});
my $application = SOAP::Data->name('application' => 'your_application_name');
my $password = SOAP::Data->name('password' => 'password');
my $customer = SOAP::Data->name('customer' => 'your_customer_name');
my $destination = SOAP::Data->name('destination' => '+6421xxxxxx'); # Mobile number, International Format
my $content = SOAP::Data->name('content' => 'This is a test message');
my $reference = SOAP::Data->name('reference' => '');
my $class = SOAP::Data->name('class' => 'mt_message');
my $response = $service->call($method,
$application,
$password,
$destination,
$content,
$reference,
$customer,
$class);
Note for .net clients. Please consider the below option if you have trouble parsing the response. This was an issue with previous versions of the gateway and may not be necessary now, so please only implement it if you are having issues.
We 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.