Example #1
0
function create_protocol($subject, $sender, $usage_code, $files = null, $return_full_result = false)
{
    $client = new SoapClient(PROTOCOL_URL, array('trace' => 1, 'exceptions' => 1, 'cache_wsdl' => 0));
    // set trace = 1 for debugging
    $client->__setLocation(PROTOCOL_URL);
    try {
        $protocol_args = array('userName' => PROTOCOL_USER, 'password' => PROTOCOL_PASS, 'document' => array('createdBy' => PROTOCOL_USER, 'docReceiveType' => '', 'documentPK' => array('protNo' => 0, 'usage' => $usage_code, 'year' => 0), 'inDescription' => $subject, 'inPerson' => $sender), 'sessionId' => 1);
        $result = $client->createProtocol($protocol_args);
        if ($files != null and count($files) > 0) {
            attach_file_protocol($subject, $sender, $usage_code, $files, $result, $return_full_result);
        }
        if ($return_full_result) {
            return $result->return;
        } else {
            $documentPK = $result->return->documentPK;
            return array('protNo' => $documentPK->protNo);
        }
    } catch (SoapFault $fault) {
        if (DEBUG) {
            return array('lastest_request' => $client->__getLastRequest(), 'fault' => $fault->getMessage());
        }
    }
}