[Spce-user] Soap create voip account
Derrick Bradbury
derrickb at halex.com
Fri Mar 28 10:11:55 EDT 2014
I got it working using the Basic PHP SOAP interface.. here is some code, variables missing but you'll get the idea:
The key to using the PHP built in soap (which I've found faster than nusoap) is the "?plain" at the end of the soap wsdl url.
$un/$pw are the username/password for the HTTP
$client = new SoapClient("https://192.168.1.85:2443/SOAP/Provisioning.wsdl?plain",array("login"=>$un,"password"=>$pw));
class Authentication {
function Authentication($un, $pw, $type) {
$this->username = $un;
$this->password = $pw;
$this->type = $type;
}
}
$auth = new Authentication('xxx_admin','xxxxx','admin');
$domain_name = 'sipce.xxxxx.com';
$bill_profile = 'bflydefault';
$sub = array(
'username'=>$subscriber_name,
'domain'=>$domain_name,
'password'=>$subscriber_password,
'cc'=>$cc,
'ac'=>$ac,
'sn'=>$sn,
'webusername'=>$webuser,
'webpassword'=>$webpass,
'external_id'=>$obj->name);
if (count($alias) > 0)
$sub = array_merge((array)$sub,(array)array("alias_numbers" => $alias));
$param = array( 'billing_profile' => $bill_profile, 'subscribers'=>array($sub));
try {
$res = $client->create_voip_account($auth,array('data' => $param));
var_dump($sub);
echo "\n$obj->name\n";
}
catch (Exception $e) {
echo "SKIPPING: $obj->DisplayName\n";
var_dump($e);
echo "\n";
continue;
}
________________________________
From: spce-user-bounces at lists.sipwise.com [spce-user-bounces at lists.sipwise.com] on behalf of jchism2 [jchism2 at gmail.com]
Sent: Friday, March 28, 2014 9:55 AM
To: spce-user at lists.sipwise.com
Subject: [Spce-user] Soap create voip account
Here is the code we are using. It is replying with a missing billing profile error. Can you see anything in this code that would cause the problem. We are using the default profile for billing.
require_once($_SERVER['DOCUMENT_ROOT'].'/sites/all/data/nusoap/lib/nusoap.php'); // I had to get the SOAP library in place on SERVER A for NUSOAP //--not the yum install php-soap
// Create the client instance
$client = new nusoap_client($_SERVER['DOCUMENT_ROOT'].'/sites/all/data/Provisioning.wsdl', true);
//$client->soap_defencoding = 'UTF-8'; // We had noticed the client defaults to something else. Doesn't seem to effect either way?
$client->setCredentials("xxxx","xxxxxxx","basic"); // The Login and Pass for the SOAP connection - Username and pass on PORT 2443
// Call the SOAP method
$job = array('authentication' => array('type' => 'admin', 'username' => 'xxxxxxx', 'password' => 'xxxxxx'),'parameters' => array('billing_profile' => 'default', 'status' => 'active', 'external_id' => $trunkname));
$result = $client->call('create_voip_account',$job); // This is just a test pull of information for proof of concept, nothing really for production use.
//print_r($job);
// Check for a fault
if ($client->fault) {
echo '<h2>Fault</h2><pre>';
print_r($result);
echo '</pre>';
}
else
{
// Check for errors
$err = $client->getError();
if ($err)
{
// Display the error
echo '<h2>Error</h2><pre>' . $err . '</pre>';
}
else
{
// Display the result
echo '<h2>Result</h2><pre>';
print_r($result);
echo '</pre>';
}
}
exit(0);
Sent via the Samsung Galaxy Note® 3, an AT&T 4G LTE smartphone
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sipwise.com/pipermail/spce-user_lists.sipwise.com/attachments/20140328/1456332c/attachment-0001.html>
More information about the Spce-user
mailing list