KiDocExchange en
Jump to navigation
Jump to search
eesti keeles |
KiDocExchange Web Service
Introduction
KiDocExchange is a web service for uploading files into Krediidiinfo 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.
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 Krediidiinfo 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. |
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 Krediidiinfo for more information. You might get usefull information with getStatusMsg method. | |||
-10003 | MD5 check failed | |||
-xxxxx | File processing failed. Contact Krediidiinfo 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 |
Example in PHP
NB! The example program is in debug mode (at the end of url is debug). All tests should be done in debug mode.
<?php /** * Example of uploading and downloading files using KiDocExchange interface. * @author Rait Kapp <rait@krediidiinfo.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"; } ?>