<?php
require_once("lib/nusoap.php");
require_once("config.php");
require_once("apiFunction.php");
$server = new soap_server();
$server->configureWSDL("soapIndex", "urn:soapIndex");

//--- BEGIN Balance SOAP Declare ---//
$server->wsdl->addComplexType(
    'userData',
    'complexType',
    'struct',
    'all',
    '',
    array('username' => array('name'=>'username','type'=>'xsd:string'), 'password' => array('name'=>'password','type'=>'xsd:string')));
	
$server->register("balance",array("accountData" => "tns:userData"),array("return" => "xsd:string"),"urn:soapIndex","urn:soapIndex#balance","rpc", "encoded", "Get your current balance");	
//--- END Balance SOAP Declare ---//

//--- BEGIN send SOAP Declare ---//
$server->wsdl->addComplexType(
	'oneMsg',
	'complexType',
	'struct',
	'sequence',
	'',
    array(
		'username' => array('name'=>'username','type'=>'xsd:string'),
		'password' => array('name'=>'password','type'=>'xsd:string'),
		'sender' => array('name'=>'sender','type'=>'xsd:string'),
		'numbers' => array('name'=>'numbers','type'=>'xsd:string'),
		'msg' => array('name'=>'msg','type'=>'xsd:string')
	)
);



$server->wsdl->addComplexType(
	'smsMessages',
	'complexType',
	'array',
	'sequence',
	'',
	array(
		'allMessages' => array('name'=>'allMessages', 'type'=>'tns:oneMsg', 'minOccurs'=>0, 'maxOccurs'=>'unbounded')
	)
);



$server->register("sendMsg",array("sendMsgData" => "tns:smsMessages"),array("return" => "xsd:string"),"urn:soapIndex","urn:soapIndex#sendMsg","rpc", "literal", "send msg data");	
//--- END send SOAP Declare ---//
if (empty($HTTP_RAW_POST_DATA))
	$HTTP_RAW_POST_DATA = file_get_contents('php://input');
$server -> service($HTTP_RAW_POST_DATA);

$data = "data : ".$HTTP_RAW_POST_DATA. PHP_EOL;
$fp = fopen('log2.txt', 'a+');
fwrite($fp, $data);
?>