[Spce-user] help with XML-RPC an php
Alejandro Rodriguez
alejandro at beeztel.com
Mon Jun 18 07:25:05 EDT 2012
Hi
This is the code completed.
Only one advise, VOIP ACCOUNT SUBSCRIBER return null if all is ok, else
return the error.
<?php
require_once('lib/nusoap.php');
$phone = "123123123";
$external_id = "4444444";
$password = "333333";
$user = $external_id; // for my test
// get wsdl
$client = new nusoap_client("https://xx.xx.xx.xx:2443/SOAP/Provisioning.wsdl",
true, "", "", "user", "password");
$client ->setCredentials("user","password");
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(),
ENT_QUOTES) . '</pre>';
exit();
}
$client->setUseCurl('0');
$client->useHTTPPersistentConnection();
// authentication string
$authentication = '
<authentication>
<type xsi:type="xsd:string">admin</type>
<username xsi:type="xsd:string">user</username>
<password xsi:type="xsd:string">password</password>
</authentication>';
// **************************************
// CREATE VOIP ACCOUNT
$params = $authentication.'
<parameters>
<data>
<billing_profile
xsi:type="xsd:string">default</billing_profile>
<status xsi:type="xsd:string">active</status>
<external_id
xsi:type="xsd:string">'.$external_id.'</external_id>
<subscribers
SOAP-ENC:arrayType="xsd:SubscriberWriteArray[]">
</subscribers>
</data>
</parameters>
';
// get the id of the new account
$id_voip = $client->call('create_voip_account', $params, '
https://xx.xx.xx.xx:2443/SOAP', 'https://xx.xx.xx.xx:2443/SOAP');
echo 'voip account id = '.$id_voip.'<br/>';
// END VOIP ACCOUNT
// **************************************
// **************************************
// ADD SUBSCRIBER to VOIP ACCOUNT
$params = $authentication.'
<parameters>
<id xsi:type="xsd:int">'.$id_voip.'</id>
<subscriber>
<username
xsi:type="xsd:string">'.$user.'</username>
<domain
xsi:type="xsd:string">domain</domain>
<password
xsi:type="xsd:string">'.$password.'</password>
</subscriber>
</parameters>
';
$result = $client->call('add_voip_account_subscriber', $params, '
https://xx.xx.xx.xx:2443/SOAP', 'https://xx.xx.xx.xx:2443/SOAP');
echo '<h2>result</h2><pre>'; print_r($result); echo '</pre>';
// END ADD VOIIP ACCOUNT SUBSCRIBER
// **************************************
// END PHP
?>
2012/6/18 Skyler <skchopperguy at gmail.com>
> Hi,
>
> On Tue, Jun 12, 2012 at 4:31 AM, Alejandro Rodriguez <
> alejandro at beeztel.com> wrote:
>
>> Hi,
>>
>> This is fixed :).
>>
>>
> Would you mind sharing your final working PHP code used to the community?
> Any special instructions?
>
> Skyler
>
>
>> I cant create all the information in one step. I use two calls:
>> create_voip_account
>> add_voip_account_subscriber
>>
>> This is not the correct solution. Because on create_voip_account, it's
>> possible to create the account subscriber... but I don't know how.
>>
>> $aut =' <authentication>
>>
>> <type xsi:type="xsd:string">admin</type>
>> <username xsi:type="xsd:string">user</username>
>> <password xsi:type="xsd:string">password</password>
>> </authentication>';
>>
>>
>> $params = $aut.'
>>
>> <parameters>
>> <data>
>> <billing_profile
>> xsi:type="xsd:string">default</billing_profile>
>> <status xsi:type="xsd:string">active</status>
>> <external_id xsi:type="xsd:string">5555555</external_id>
>>
>> <subscribers
>> SOAP-ENC:arrayType="xsd:SubscriberWriteArray[]">
>> </subscribers>
>> </data>
>> </parameters>
>> ';
>>
>>
>> $id_voip = $client->call('create_voip_account', $params, '
>> https://xx.yy.zz.aa:2443/SOAP', 'https://xx.yy.zz.aa:2443/SOAP');
>>
>> echo 'voip account='.$id_voip.'<br/>';
>>
>> $params =$aut.'
>> <parameters>
>> <id xsi:type="xsd:int">'.$id_voip.'</id>
>> <subscriber>
>>
>> <username
>> xsi:type="xsd:string">444444</username>
>>
>> <domain
>> xsi:type="xsd:string">xx.yy.zz.aa</domain>
>> <password
>> xsi:type="xsd:string">11111111</password>
>> </subscriber>
>>
>> </parameters>
>> ';
>> $result = $client->call('add_voip_account_subscriber', $params, '
>> https://xx.yy.zz.aa:2443/SOAP', 'https://xx.yy.zz.aa:2443/SOAP');
>>
>>
>>
>>
>>
>> 2012/6/12 Skyler <skchopperguy at gmail.com>
>>
>>> Hi,
>>>
>>> I think your problem is because you are trying to submit xml using
>>> soap. XML-RPC is different than SOAP. The example I sent is using SOAP not
>>> XML-RPC. You need to choose one and try again.
>>>
>>> If you read the documentation at https://<ce-ip>:2443/SOAP/Provisioning.wsdl
>>> you will see there are 2 different capabilities. SOAP or XML-RPC. Each have
>>> different URL also.
>>>
>>> Does the example I proposed work? .. when using 'default' as
>>> billing_profile?
>>>
>>> Skyler
>>>
>>>
>>> On Mon, Jun 11, 2012 at 4:27 PM, Alejandro Rodriguez <
>>> alejandro at beeztel.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> Not, this don't work. I try with the code attached.
>>>> I use the xml soap instead of the arrays.
>>>> I think all is correct, but I have this error, and I don't have idea
>>>> why.
>>>>
>>>> Array
>>>> (
>>>> [faultcode] => soap:Server
>>>> [faultstring] => Can't use string ("666666666") as a HASH ref while "strict refs" in use at /usr/share/perl5/Sipwise/Provisioning/Billing.pm line 1009.
>>>>
>>>> )
>>>>
>>>> This is the code using nusoap
>>>>
>>>> <?php
>>>>
>>>> require_once('lib/nusoap.php');
>>>>
>>>> $useCURL = '0';
>>>>
>>>> $client = new nusoap_client("https://xx.yy.zz.aa:nnnn/SOAP/Provisioning.wsdl",
>>>> true, "", "", "USER", "PASSWORD");
>>>> $client ->setCredentials("USER","PASSWORD");
>>>>
>>>> $err = $client->getError();
>>>> if ($err) {
>>>> echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
>>>> echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(),
>>>> ENT_QUOTES) . '</pre>';
>>>> exit();
>>>> }
>>>>
>>>> $client->setUseCurl($useCURL);
>>>> $client->useHTTPPersistentConnection();
>>>>
>>>>
>>>> // CREATE ACCOUNT
>>>> $params = '
>>>> <authentication>
>>>> <type xsi:type="xsd:string">admin</type>
>>>> <username xsi:type="xsd:string">user</username>
>>>> <password xsi:type="xsd:string">password</password>
>>>> </authentication>
>>>> <parameters>
>>>> <data>
>>>> <billing_profile
>>>> xsi:type="xsd:string">default</billing_profile>
>>>> <status xsi:type="xsd:string">active</status>
>>>> <external_id
>>>> xsi:type="xsd:string">44444444</external_id>
>>>> <subscribers
>>>> SOAP-ENC:arrayType="xsd:SubscriberWriteArray[]">
>>>> <username
>>>> xsi:type="xsd:string">666666666</username>
>>>> <domain
>>>> xsi:type="xsd:string">xx.yy.zz.aa</domain>
>>>> <password
>>>> xsi:type="xsd:string">2222222</password>
>>>> </subscribers>
>>>> </data>
>>>> </parameters>
>>>> ';
>>>>
>>>> $result = $client->call('create_voip_account', $params,
>>>> 'https://xx.yy.zz.aa:nnnn/SOAP', 'https://xx.yy.zz.aa:nnnn/SOAP');
>>>> echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>';
>>>>
>>>> if ($client->fault) {
>>>> echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>';
>>>> } else {
>>>> $err = $client->getError();
>>>> if ($err) {
>>>> echo '<h2>Error</h2><pre>' . $err . '</pre>';
>>>> } else {
>>>> echo '<h2>Result</h2><pre>'; print_r($result); echo '</pre>';
>>>> }
>>>> }
>>>>
>>>> echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request,
>>>> ENT_QUOTES) . '</pre>';
>>>> echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response,
>>>> ENT_QUOTES) . '</pre>';
>>>> echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(),
>>>> ENT_QUOTES) . '</pre>';
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> 2012/6/12 Skyler <skchopperguy at gmail.com>
>>>>
>>>>> Hi,
>>>>>
>>>>> Did this work for you?
>>>>>
>>>>> Skyler
>>>>>
>>>>>
>>>>> On Thu, Jun 7, 2012 at 1:52 PM, Alejandro Rodriguez <
>>>>> alejandro at beeztel.com> wrote:
>>>>>
>>>>>> Perfect.
>>>>>>
>>>>>> I will try.
>>>>>>
>>>>>> Regards
>>>>>> El 07/06/2012 21:50, "Skyler" <skchopperguy at gmail.com> escribió:
>>>>>>
>>>>>> Hi,
>>>>>>>
>>>>>>> Don't forget to reply-all so everyone can help or know solutions ;)
>>>>>>>
>>>>>>> On Thu, Jun 7, 2012 at 1:22 PM, Alejandro Rodriguez <
>>>>>>> alejandro at beeztel.com> wrote:
>>>>>>>
>>>>>>>> Hi Skyler,
>>>>>>>>
>>>>>>>> With nusoap, all is correct and easy. (I don't think on use this
>>>>>>>> instead of php soap)
>>>>>>>>
>>>>>>>> I'm not sure if you can help me with a new question. Create the
>>>>>>>> structure for create_voip_account. I can't create the correct structure.
>>>>>>>> I receive this message "need a billing profile for the new account"
>>>>>>>>
>>>>>>>>
>>>>>>> I have this same trouble but not had time to further investigate. I
>>>>>>> suspect that the 'billing_profile' may require the ID number assigned in
>>>>>>> the database to be passed where if 'Default Billing Profile' has ID of '3'
>>>>>>> then pass the '3'.
>>>>>>>
>>>>>>> ...just guessing, maybe you can help to confirm this for everyone? :)
>>>>>>>
>>>>>>> Skyler
>>>>>>>
>>>>>>>
>>>>>>>> Thanks.
>>>>>>>>
>>>>>>>> $params = array(
>>>>>>>> 'authentication' => array('type' => 'admin', 'username' =>
>>>>>>>> 'username', 'password' => 'password'),
>>>>>>>> 'parameters' => array( 'data' => array (
>>>>>>>> 'billing_profile' => 'Default Billing Profile',
>>>>>>>> 'status' => 'active',
>>>>>>>> 'external_id' => '44444444',
>>>>>>>> 'subscribers' => array(
>>>>>>>> 'username' => '44444444',
>>>>>>>> 'domain' => '94.23.232.121',
>>>>>>>> 'password' => '2222222'
>>>>>>>> )
>>>>>>>> )
>>>>>>>> )
>>>>>>>> );
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> 2012/6/7 Alejandro Rodriguez <alejandro at beeztel.com>
>>>>>>>>
>>>>>>>>> Thanks a lot nusoap :)
>>>>>>>>> El 07/06/2012 19:45, "Skyler" <skchopperguy at gmail.com> escribió:
>>>>>>>>>
>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> See attached php/soap connection example. This is from a very
>>>>>>>>>> helpful person on the list some months ago. Maybe it will assist your
>>>>>>>>>> problem ;)
>>>>>>>>>>
>>>>>>>>>> Skyler
>>>>>>>>>>
>>>>>>>>>> On Thu, Jun 7, 2012 at 6:47 AM, Alejandro Rodriguez <
>>>>>>>>>> alejandro at beeztel.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> Hello,
>>>>>>>>>>>
>>>>>>>>>>> I'm trying to use XML-RPC and SOAP with sipwise. But I cant
>>>>>>>>>>> connect with the server with XML-RPC and with SOAP versión everytime I get
>>>>>>>>>>> the message "SOAP-ERROR: Parsing Schema: unexpected in complexType"
>>>>>>>>>>>
>>>>>>>>>>> Please have you some example in php to usu XML-RPC or with SOAP.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> This is my php for load the wsdl in SOAP.
>>>>>>>>>>>
>>>>>>>>>>> try
>>>>>>>>>>> {
>>>>>>>>>>> $client = new SoapClient("
>>>>>>>>>>> https://ipserver:2443/SOAP/Provisioning.wsdl",array('login' =>
>>>>>>>>>>> "login", 'password' => "password"));
>>>>>>>>>>>
>>>>>>>>>>> } catch ( SoapFault $fault ) {
>>>>>>>>>>> echo '<pre>';
>>>>>>>>>>> echo var_dump($fault) ;
>>>>>>>>>>> echo '</pre>';
>>>>>>>>>>> exit ;
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Regards
>>>>>>>>>>> Alejandro
>>>>>>>>>>>
>>>>>>>>>>> _______________________________________________
>>>>>>>>>>> Spce-user mailing list
>>>>>>>>>>> Spce-user at lists.sipwise.com
>>>>>>>>>>> http://lists.sipwise.com/listinfo/spce-user
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sipwise.com/pipermail/spce-user_lists.sipwise.com/attachments/20120618/ba7c4578/attachment-0001.html>
More information about the Spce-user
mailing list