KiDocExchange en

From services.krediidiinfo.ee
Jump to navigation Jump to search
Flag of Estonia.svg eesti keeles

KiDocExchange Web Service

Introduction

KiDocExchange is a web service for uploading files into Creditinfo server. Web Service description can be found on http://services.krediidiinfo.ee/KiDocExchange.wsdl.

Sequence Diagram

Next squence diagram illustrates how to use KiDocExchange to upload files.

KiDocExchange Upload Sequence Diagram.jpg

and to download

Download diagram.png


List of available files for download can be requested using getDownloadQueue() function. Once downloaded successfully the file is removed from the list. It is still possible to download the file later on if you keep the file id.

Methods

startUpload

Starts and initializes file upload.

Name Type Description
Input Parameter: fileName xs:string The name of file
Output Parameter: docID xs:integer Unique file identification number in Creditinfo server.

uploadChunk

Uploads and appends next chunk of data. Servers can send data in one chunk. Several chunks are needed when upload process is slow and there are a progress feedback needed (desktop application).

Name Type Description
Input Parameters: docID xs:integer File identification number
chunk xs:base64Binary Next chunk of data
Output Parameters: None

finishUpload

Finishes file upload.

Name Type Description
Input Parameters: docID xs:integer File identification number
md5 xs:string MD5 checksum of uploaded file
Output Parameters: errorCode xs:integer If 0 then file upload succeeded. If negative then there was an error. See Error Codes for more information.

getDownloadQueue

The list of files waiting for client to download them from Creditinfo server.

Name Type Description
Output parameter: queue DownloadQueueArray array of DownloadQueueType type


DownloadQueueType is an associative array with following elements:

Name Type Description
docID xs:integer file id
fileName xs:string file name


getStatusCode

Returns the status code of uploaded file

Name Type Description
Input Parameters: docID xs:integer File identification number
Output Parameters: status_code xs:integer File status code:
0 File has been processed
2 Uploading in progress
3 File is in processing
4 File was successfully uploaded and is waiting for processing
-1 Unknown error. Contact Creditinfo for more information. You might get usefull information with getStatusMsg method.
-10003 MD5 check failed
-xxxxx File processing failed. Contact Creditinfo for more information. You might get usefull information with getStatusMsg method.

getStatusMsg

Returns the status message of uploaded file.

Name Type Description
Input Parameters: docID xs:integer File identification number
Output Parameters: statusMsg xs:string Status message of the file

Error Codes

Code Description
0 Success
Request was processed successfully.
-10001 Access denied
You are trying to access file owned by somebody else.
-10002 File does not exists
You are using file identification that does not exist
-10003 MD5 failure
Your sent MD5 does not match MD5 calculated by server


Debugging

Developers can use a test server for file uploading. For that they should add a parameter debug to the server url. The url would be 'https://services.krediidiinfo.ee/soap.php?name=KiDocExchange&debug'.


Example in PHP

<?php
/**
 * Example of uploading and downloading files using KiDocExchange interface.
 * @author Rait Kapp <rait@creditinfo.ee>
 * @created 27.04.2007
 */
$wsdl_url = 'http://services.krediidiinfo.ee/KiDocExchange.wsdl';
$params = array('location'      => 'https://services.krediidiinfo.ee/soap.php?name=KiDocExchange&debug'
              , 'login'       => 'username' // <-- username. Make sure username is string type (PHP bug?).
              , 'password'    => 'password'   // <-- password
	        );
    	
$client = new SoapClient($wsdl_url, $params);

// Uploading file.
$content = 'I am a little test file!';
$docID = $client->startUpload('test.txt');
$client->uploadChunk($docID, $content);		

$md5 = md5($content);
$result = $client->finishUpload($docID, $md5);
if ($result != 0) {
    die("upload failed.! Error code: {$result}\n");
}

// Downloading file
$start = 0;
$count = 512; // can be a big number if you do not have to display download progress.
$data = '';
while ($chunk = $client->downloadChunk($docID, $start, $count)) {
    $start += $count;
    $data .= $chunk;
}

if ($content != $data) {
    echo "Something is not right!\n";
} else {
    echo "We got back: {$data}\n";
}

?>