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

From version 15.5
edited by Robert Jan Daams
on 2025/03/05 18:02
Change comment: There is no comment for this version
To version 5.1
edited by Robin Huisman
on 2022/04/01 15:12
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.RobinHuisman
Content
... ... @@ -16,36 +16,6 @@
16 16  (((
17 17  (% class="col-xs-12 col-sm-8" %)
18 18  (((
19 -== Changelog ==
20 -
21 -=== Update 2022-08-23 ===
22 -
23 -As part of on-going efforts to improve performance and scalability, we have introduced a dedicated version of DataWS named DataWSExternals.  This new service should be used for external API consumers.
24 -
25 -| |**URL**|
26 -|**Old**|{{code language="none"}}https://web.terraindex.com/DataWS/{{/code}}|(((
27 -[[https:~~/~~/web.terraindex.com/DataWS/ITWDataRestService_V1_0/GetProjectsJSON>>https://web.terraindex.com/DataWS/ITWDataRestService_V1_0/GetProjectsJSON]]
28 -
29 -[[https:~~/~~/web.terraindex.com/DataWS/ITWImportExportServiceASMX_V1_0.asmx>>https://web.terraindex.com/DataWSExternals/ITWImportExportServiceASMX_V1_0.asmx]]
30 -)))
31 -|**New**|​{{code language="none"}}https://web.terraindex.com/DataWSExternals/{{/code}}|(((
32 -[[https:~~/~~/web.terraindex.com/DataWSExternals/ITWDataRestService_V1_0/GetProjectsJSON>>https://web.terraindex.com/DataWSExternals/ITWDataRestService_V1_0/GetProjectsJSON]]
33 -
34 -[[https:~~/~~/web.terraindex.com/DataWSExternals/ITWImportExportServiceASMX_V1_0.asmx>>https://web.terraindex.com/DataWSExternals/ITWImportExportServiceASMX_V1_0.asmx?wsdl]]
35 -)))
36 -
37 -== ==
38 -
39 -{{info}}
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
47 -{{/info}}
48 -
49 49  == 1. Retreive all changed project from TerraIndex ==
50 50  
51 51  To retreive all changed project from the TerraIndex database since a specific timestamp, there is a webservice call you can do. This will return all project rows that have changes since the timestamp you send within the request.
... ... @@ -52,7 +52,7 @@
52 52  This way you only download projects that have changes, and it will not request project that are not needed, so it won’t keep our servers busy with exports that are not necessary.
53 53  
54 54  To start connecting this webservice, you should use this URL:
55 -[[https:~~/~~/web.terraindex.com/DataWSExternals/ITWDataRestService_V1_0/GetProjectsJSON>>https://web.terraindex.com/DataWSExternals/ITWDataRestService_V1_0/GetProjectsJSON]]
25 +[[https:~~/~~/web.terraindex.com/DataWS/ITWDataRestService_V1_0/GetProjectsJSON>>url:https://web.terraindex.com/DataWS/ITWDataRestService_V1_0/GetProjectsJSON]]
56 56  
57 57  Fill the **Body **of a **POST **HTTP call with:
58 58  
... ... @@ -268,12 +268,11 @@
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]]
241 +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 -To start connecting this webservice, you should use this URL of the Import Export Webservice:
243 +To start connecting this webservice, you should use this URL of the Import Export Webservice:
244 +[[https:~~/~~/web.terraindex.com/DataWS/ITWImportExportServiceASMX_V1_0.asmx>>url:https://web.terraindex.com/DataWS/ITWImportExportServiceASMX_V1_0.asmx]]
274 274  
275 -[[https:~~/~~/web.terraindex.com/DataWSExternals/ITWImportExportService_V1_0.svc>>https://web.terraindex.com/DataWSExternals/ITWImportExportService_V1_0.svc]]
276 -
277 277  With this URL many IDE’s can create a proxy for you, just by providing the URL. Once this proxy is created, you will have a few classes looking like the call in the image below.
278 278  
279 279  [[image:image-20200108-123431.png]]
... ... @@ -287,7 +287,6 @@
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 291  6; Fill the parameter with the FileName.
292 292  7; Fill the parameter with **projectID**. Instead of ‘ProjectID' it’s also possible to fill the parameter ‘ProjectCode'.
293 293  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.
... ... @@ -408,7 +408,137 @@
408 408  </soap:Envelope>
409 409  {{/code}}
410 410  
411 -
379 +
380 +== Zip Stream class ==
381 +
382 +If needed, this is the Zip Stream class you can use to extract the zipstream as used above:
383 +
384 +{{code language="Csharp" layout="LINENUMBERS"}}
385 +/// <summary>
386 +/// Helper class for compress en decompress of file data
387 +/// </summary>
388 +public static class ZipStreamHelper {
389 + #region Compress and encode
390 + /// <summary>
391 + /// Comprimeer een string en geeft deze terug in Base64 string.
392 + /// </summary>
393 + /// <param name="content">filecontent</param>
394 + /// <returns>gecomprimeerde string</returns>
395 + public static string CompressToBase64String(string content) {
396 + //string to byte[]
397 + byte[] contentArray = stringToByteArray(content);
398 + // Compress
399 + byte[] compressed = Compress(contentArray);
400 + return base64_encode(compressed);
401 + }
402 +
403 + /// <summary>
404 + /// Zet een string om naar een ByteArray
405 + /// </summary>
406 + /// <param name="content">filecontent</param>
407 + /// <returns>ByteArray</returns>
408 + public static byte[] stringToByteArray(string content) {
409 + System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
410 + return encoding.GetBytes(content);
411 + }
412 +
413 + /// <summary>
414 + /// comprimeer een ByteArray
415 + /// </summary>
416 + /// <param name="data">filedata als ByteArray</param>
417 + /// <returns>gecomprimeerde ByteArray</returns>
418 + public static byte[] Compress(byte[] data) {
419 + using(var compressedStream = new MemoryStream())
420 + using(var zipStream = new GZipStream(compressedStream, CompressionMode.Compress)) {
421 + zipStream.Write(data, 0, data.Length);
422 + zipStream.Close();
423 + return compressedStream.ToArray();
424 + }
425 + }
426 +
427 + /// <summary>
428 + /// Zet een ByteArray om naar een Base64 string
429 + /// </summary>
430 + /// <param name="data">gecomprimeerde ByteArray</param>
431 + /// <returns>Base 64 string</returns>
432 + public static string base64_encode(byte[] data) {
433 + if (data == null)
434 + return string.Empty;
435 + return Convert.ToBase64String(data);
436 + }
437 +
438 + /// <summary>
439 + /// Zet een string om naar een Base64 string
440 + /// </summary>
441 + /// <param name="data">string</param>
442 + /// <returns>Base 64 string</returns>
443 + public static string string_base64_encode(string data) {
444 + if (string.IsNullOrEmpty(data))
445 + return string.Empty;
446 +
447 + //string to byte[]
448 + byte[] contentArray = stringToByteArray(data);
449 + return base64_encode(contentArray);
450 + }
451 + #endregion
452 +
453 + #region Decompress and decode
454 + // Decode and decompress
455 + /// <summary>
456 + /// Decomprimeer een Base64 string naar een string
457 + /// </summary>
458 + /// <param name="contentBase64">GZIP Base64 string</param>
459 + /// <returns>string</returns>
460 + public static string DecompressBase64StringToString(string contentBase64) {
461 + // Decompress
462 + byte[] decoded = base64_decode(contentBase64);
463 + byte[] decompressed = Decompress(decoded);
464 +
465 + return byteArrayTostring(decompressed);
466 + }
467 +
468 + /// <summary>
469 + /// Zet een ByteArray om in een normale string
470 + /// </summary>
471 + /// <param name="data">ByteArray</param>
472 + /// <returns>string</returns>
473 + public static string byteArrayTostring(byte[] data) {
474 + System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
475 + return enc.GetString(data);
476 + }
477 +
478 + /// <summary>
479 + /// Zet een Base64 string om naar een ByteArray
480 + /// </summary>
481 + /// <param name="encodedData">Base64 string</param>
482 + /// <returns>gecomprimeerde ByteArray</returns>
483 + public static byte[] base64_decode(string encodedData) {
484 + byte[] encodedDataAsBytes = Convert.FromBase64String(encodedData);
485 + return encodedDataAsBytes;
486 + }
487 +
488 + /// <summary>
489 + /// Zet een gecomprimeerde ByteArray om in een ByteArray
490 + /// </summary>
491 + /// <param name="data">gecomprimeerde ByteArray</param>
492 + /// <returns>ByteArray (gedecomprimeerd)</returns>
493 + public static byte[] Decompress(byte[] data) {
494 + using(var compressedStream = new MemoryStream(data))
495 + using(var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress))
496 + using(var resultStream = new MemoryStream()) {
497 + var buffer = new byte[4096];
498 + int read;
499 +
500 + while ((read = zipStream.Read(buffer, 0, buffer.Length)) > 0) {
501 + resultStream.Write(buffer, 0, read);
502 + }
503 +
504 + return resultStream.ToArray();
505 + }
506 + }
507 + #endregion
508 +}
509 +{{/code}}
412 412  )))
413 413  
414 414