Last modified by Nico Lemaire on 2025/09/01 13:36

From version 15.6
edited by Nico Lemaire
on 2025/09/01 13:36
Change comment: There is no comment for this version
To version 13.1
edited by Robin Huisman
on 2023/05/23 13:21
Change comment: There is no comment for this version

Summary

Details

Page properties
Title
... ... @@ -1,1 +1,1 @@
1 -Download a project (export)
1 +Setting up a Webservice connection for project exports
Parent
... ... @@ -1,1 +1,1 @@
1 -Implementation documentation.For customers.WebHome
1 +Implementation documentation.WebHome
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.NicoLemaire
1 +XWiki.RobinHuisman
Content
... ... @@ -268,7 +268,7 @@
268 268  == 2. Retreive the project export from TerraIndex ==
269 269  
270 270  To request the export from TerraIndex we have a SOAP webservice. This webservice is called the ExportService, and it will provide a full project in TerraIndex Format.
271 -The format of the projectfile is documentated here: [[Documentation TerraIndex Export format - dsFieldProject.xsd>>Implementation documentation.For customers.Documentation TerraIndex Export format - dsFieldProject\.xsd.WebHome]]
271 +The format of the projectfile is documentated here: [[Documentation TerraIndex Export format - dsFieldProject.xsd>>Implementation documentation.Documentation TerraIndex Export format - dsFieldProject\.xsd.WebHome]]
272 272  
273 273  To start connecting this webservice, you should use this URL of the Import Export Webservice:
274 274  
... ... @@ -287,8 +287,7 @@
287 287  Also fill the license and the applicationCode. //(These two fields can be requested at the TerraIndex Servicedesk.)//
288 288  5; Fill the **ExportType **'**Export_FIELD_XML_v1_0_0**’. This export corresponds with dsFieldProject.xsd and is the best XML to connect TI with.
289 289  Create at least create 2 parameters as in the image. Beacause 2 parameters are needed.
290 -//If JSON is prevered use: ExportType = 'Export_FIELD_JSON_v1_0_0'
291 -For other export types, see the end of this page//
290 +//If JSON is prevered use: ExportType = 'Export_FIELD_JSON_v1_0_0'//
292 292  6; Fill the parameter with the FileName.
293 293  7; Fill the parameter with **projectID**. Instead of ‘ProjectID' it’s also possible to fill the parameter ‘ProjectCode'.
294 294  8; Send the request and wait for the reponse. In response field ‘ResultCode’ should be 'SUCCES’ when it all went OK. If not it will tell what went wrong.
... ... @@ -410,31 +410,139 @@
410 410  {{/code}}
411 411  
412 412  
413 -**List of export types:**
412 +== Zip Stream class ==
414 414  
415 -* Export_TI_v1_0_0
416 -* Export_FIELD_XML_v1_0_0
417 -* Export_FIELD_JSON_v1_0_0
418 -* Export_Field_Codelist_XML
419 -* Export_Field_Codelist_JSON
420 -* Export_OVAM_MISTRAL2_v8_4_0
421 -* Export_DOV
422 -* Export_IMSIKB_v14_3_0
423 -* Export_IMSIKB_v13_5_0
424 -* Export_BRO_GMW
425 -* Export_BRO_BHR_GT
426 -* Export_BRO_GAR
427 -* Export_IMSIKB_v14_7_0
428 -* Export_IMSIKB_v14_8_0
429 -* Export_BRO_SAD_IMBROA_Registration
430 -* Export_BRO_SAD_IMBROA_Correction
431 -* Export_BRO_SAD_IMBRO_Registration
432 -* Export_BRO_SAD_IMBRO_Correction
433 -* Export_IMSIKB_v14_9_0
434 -)))
414 +If needed, this is the Zip Stream class you can use to extract the zipstream as used above:
435 435  
416 +{{code language="Csharp" layout="LINENUMBERS"}}
417 +/// <summary>
418 +/// Helper class for compress en decompress of file data
419 +/// </summary>
420 +public static class ZipStreamHelper {
421 + #region Compress and encode
422 + /// <summary>
423 + /// Comprimeer een string en geeft deze terug in Base64 string.
424 + /// </summary>
425 + /// <param name="content">filecontent</param>
426 + /// <returns>gecomprimeerde string</returns>
427 + public static string CompressToBase64String(string content) {
428 + //string to byte[]
429 + byte[] contentArray = stringToByteArray(content);
430 + // Compress
431 + byte[] compressed = Compress(contentArray);
432 + return base64_encode(compressed);
433 + }
436 436  
435 + /// <summary>
436 + /// Zet een string om naar een ByteArray
437 + /// </summary>
438 + /// <param name="content">filecontent</param>
439 + /// <returns>ByteArray</returns>
440 + public static byte[] stringToByteArray(string content) {
441 + System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
442 + return encoding.GetBytes(content);
443 + }
437 437  
445 + /// <summary>
446 + /// comprimeer een ByteArray
447 + /// </summary>
448 + /// <param name="data">filedata als ByteArray</param>
449 + /// <returns>gecomprimeerde ByteArray</returns>
450 + public static byte[] Compress(byte[] data) {
451 + using(var compressedStream = new MemoryStream())
452 + using(var zipStream = new GZipStream(compressedStream, CompressionMode.Compress)) {
453 + zipStream.Write(data, 0, data.Length);
454 + zipStream.Close();
455 + return compressedStream.ToArray();
456 + }
457 + }
458 +
459 + /// <summary>
460 + /// Zet een ByteArray om naar een Base64 string
461 + /// </summary>
462 + /// <param name="data">gecomprimeerde ByteArray</param>
463 + /// <returns>Base 64 string</returns>
464 + public static string base64_encode(byte[] data) {
465 + if (data == null)
466 + return string.Empty;
467 + return Convert.ToBase64String(data);
468 + }
469 +
470 + /// <summary>
471 + /// Zet een string om naar een Base64 string
472 + /// </summary>
473 + /// <param name="data">string</param>
474 + /// <returns>Base 64 string</returns>
475 + public static string string_base64_encode(string data) {
476 + if (string.IsNullOrEmpty(data))
477 + return string.Empty;
478 +
479 + //string to byte[]
480 + byte[] contentArray = stringToByteArray(data);
481 + return base64_encode(contentArray);
482 + }
483 + #endregion
484 +
485 + #region Decompress and decode
486 + // Decode and decompress
487 + /// <summary>
488 + /// Decomprimeer een Base64 string naar een string
489 + /// </summary>
490 + /// <param name="contentBase64">GZIP Base64 string</param>
491 + /// <returns>string</returns>
492 + public static string DecompressBase64StringToString(string contentBase64) {
493 + // Decompress
494 + byte[] decoded = base64_decode(contentBase64);
495 + byte[] decompressed = Decompress(decoded);
496 +
497 + return byteArrayTostring(decompressed);
498 + }
499 +
500 + /// <summary>
501 + /// Zet een ByteArray om in een normale string
502 + /// </summary>
503 + /// <param name="data">ByteArray</param>
504 + /// <returns>string</returns>
505 + public static string byteArrayTostring(byte[] data) {
506 + System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
507 + return enc.GetString(data);
508 + }
509 +
510 + /// <summary>
511 + /// Zet een Base64 string om naar een ByteArray
512 + /// </summary>
513 + /// <param name="encodedData">Base64 string</param>
514 + /// <returns>gecomprimeerde ByteArray</returns>
515 + public static byte[] base64_decode(string encodedData) {
516 + byte[] encodedDataAsBytes = Convert.FromBase64String(encodedData);
517 + return encodedDataAsBytes;
518 + }
519 +
520 + /// <summary>
521 + /// Zet een gecomprimeerde ByteArray om in een ByteArray
522 + /// </summary>
523 + /// <param name="data">gecomprimeerde ByteArray</param>
524 + /// <returns>ByteArray (gedecomprimeerd)</returns>
525 + public static byte[] Decompress(byte[] data) {
526 + using(var compressedStream = new MemoryStream(data))
527 + using(var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress))
528 + using(var resultStream = new MemoryStream()) {
529 + var buffer = new byte[4096];
530 + int read;
531 +
532 + while ((read = zipStream.Read(buffer, 0, buffer.Length)) > 0) {
533 + resultStream.Write(buffer, 0, read);
534 + }
535 +
536 + return resultStream.ToArray();
537 + }
538 + }
539 + #endregion
540 +}
541 +{{/code}}
542 +)))
543 +
544 +
438 438  (% class="col-xs-12 col-sm-4" %)
439 439  (((
440 440