<
From version < 15.5
edited by Robert Jan Daams
on 2025/03/05 18:02
To version < 9.2 >
edited by Roelof Zwaan
on 2023/03/08 14:22
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.RjDaams
1 +XWiki.RoelofZwaan
Content
... ... @@ -38,12 +38,7 @@
38 38  
39 39  {{info}}
40 40  We also have new REST Calls, with the same Input Output formats:
41 -\\[[https:~~/~~/web.terraindex.com/datawsExternals/ITWImportExportRestService_V1_0/export>>https://web.terraindex.com/datawsExternals/ITWImportExportRestService_V1_0/export]]
42 -
43 -input as json: ExportRequest
44 -output as json: ExportResult
45 -
46 -as  POST  or  GET
41 +\\[[https:~~/~~/web.terraindex.com/datawsExternals/ITWImportExportRestService_V1_0/>>https://web.terraindex.com/datawsExternals/ITWImportExportRestService_V1_0/]]
47 47  {{/info}}
48 48  
49 49  == 1. Retreive all changed project from TerraIndex ==
... ... @@ -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]]
266 +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  
... ... @@ -408,7 +408,137 @@
408 408  </soap:Envelope>
409 409  {{/code}}
410 410  
411 -
406 +
407 +== Zip Stream class ==
408 +
409 +If needed, this is the Zip Stream class you can use to extract the zipstream as used above:
410 +
411 +{{code language="Csharp" layout="LINENUMBERS"}}
412 +/// <summary>
413 +/// Helper class for compress en decompress of file data
414 +/// </summary>
415 +public static class ZipStreamHelper {
416 + #region Compress and encode
417 + /// <summary>
418 + /// Comprimeer een string en geeft deze terug in Base64 string.
419 + /// </summary>
420 + /// <param name="content">filecontent</param>
421 + /// <returns>gecomprimeerde string</returns>
422 + public static string CompressToBase64String(string content) {
423 + //string to byte[]
424 + byte[] contentArray = stringToByteArray(content);
425 + // Compress
426 + byte[] compressed = Compress(contentArray);
427 + return base64_encode(compressed);
428 + }
429 +
430 + /// <summary>
431 + /// Zet een string om naar een ByteArray
432 + /// </summary>
433 + /// <param name="content">filecontent</param>
434 + /// <returns>ByteArray</returns>
435 + public static byte[] stringToByteArray(string content) {
436 + System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
437 + return encoding.GetBytes(content);
438 + }
439 +
440 + /// <summary>
441 + /// comprimeer een ByteArray
442 + /// </summary>
443 + /// <param name="data">filedata als ByteArray</param>
444 + /// <returns>gecomprimeerde ByteArray</returns>
445 + public static byte[] Compress(byte[] data) {
446 + using(var compressedStream = new MemoryStream())
447 + using(var zipStream = new GZipStream(compressedStream, CompressionMode.Compress)) {
448 + zipStream.Write(data, 0, data.Length);
449 + zipStream.Close();
450 + return compressedStream.ToArray();
451 + }
452 + }
453 +
454 + /// <summary>
455 + /// Zet een ByteArray om naar een Base64 string
456 + /// </summary>
457 + /// <param name="data">gecomprimeerde ByteArray</param>
458 + /// <returns>Base 64 string</returns>
459 + public static string base64_encode(byte[] data) {
460 + if (data == null)
461 + return string.Empty;
462 + return Convert.ToBase64String(data);
463 + }
464 +
465 + /// <summary>
466 + /// Zet een string om naar een Base64 string
467 + /// </summary>
468 + /// <param name="data">string</param>
469 + /// <returns>Base 64 string</returns>
470 + public static string string_base64_encode(string data) {
471 + if (string.IsNullOrEmpty(data))
472 + return string.Empty;
473 +
474 + //string to byte[]
475 + byte[] contentArray = stringToByteArray(data);
476 + return base64_encode(contentArray);
477 + }
478 + #endregion
479 +
480 + #region Decompress and decode
481 + // Decode and decompress
482 + /// <summary>
483 + /// Decomprimeer een Base64 string naar een string
484 + /// </summary>
485 + /// <param name="contentBase64">GZIP Base64 string</param>
486 + /// <returns>string</returns>
487 + public static string DecompressBase64StringToString(string contentBase64) {
488 + // Decompress
489 + byte[] decoded = base64_decode(contentBase64);
490 + byte[] decompressed = Decompress(decoded);
491 +
492 + return byteArrayTostring(decompressed);
493 + }
494 +
495 + /// <summary>
496 + /// Zet een ByteArray om in een normale string
497 + /// </summary>
498 + /// <param name="data">ByteArray</param>
499 + /// <returns>string</returns>
500 + public static string byteArrayTostring(byte[] data) {
501 + System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
502 + return enc.GetString(data);
503 + }
504 +
505 + /// <summary>
506 + /// Zet een Base64 string om naar een ByteArray
507 + /// </summary>
508 + /// <param name="encodedData">Base64 string</param>
509 + /// <returns>gecomprimeerde ByteArray</returns>
510 + public static byte[] base64_decode(string encodedData) {
511 + byte[] encodedDataAsBytes = Convert.FromBase64String(encodedData);
512 + return encodedDataAsBytes;
513 + }
514 +
515 + /// <summary>
516 + /// Zet een gecomprimeerde ByteArray om in een ByteArray
517 + /// </summary>
518 + /// <param name="data">gecomprimeerde ByteArray</param>
519 + /// <returns>ByteArray (gedecomprimeerd)</returns>
520 + public static byte[] Decompress(byte[] data) {
521 + using(var compressedStream = new MemoryStream(data))
522 + using(var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress))
523 + using(var resultStream = new MemoryStream()) {
524 + var buffer = new byte[4096];
525 + int read;
526 +
527 + while ((read = zipStream.Read(buffer, 0, buffer.Length)) > 0) {
528 + resultStream.Write(buffer, 0, read);
529 + }
530 +
531 + return resultStream.ToArray();
532 + }
533 + }
534 + #endregion
535 +}
536 +{{/code}}
412 412  )))
413 413  
414 414  
TerraIndex
asd