Current internet connection and execution of available services.

Version :
23.05.2023, 08:34 Uhr

Current internet connection and execution of available services. The call requires the installation of the CoreService or CoreService-Internet plugins.

Usage of soap calls requires the installation of the CoreService or CoreService[Internet] plug-ins. Information about the Configuration of the data connection can be found here.

Connections to internet services are done by SOAP. We are using gSOAP by Robert A. van Engelen for our implemtation. See here for the gSOAP User Guide.

[since v4.0.5 R17778] Plugins and comet_pdf can log the traffic the traffic from and to the service. The following file are written to your desktop:

Please note : Logfiles may become very huge! Do not use SOAP logs only for test cases with a small amount of tasks!

How to activate SOAP logs:

This is a feature! We implement it in the hope, that it helps you to check your SOAP connections. We do not see ourselves obliged to evaluate this data!

static SOAP connection()

Get the current internet connection. The connection should never be deleted using a script command.

Name Type Default Description
Return SOAP   Current internet connection of InDesign® or 0


priint:comet InDesign® Plug-Ins, comet_pdf

static SOAP login(
  char* service = 0,
  char* user = 0,
  char* passwd = 0,
  char* lang = 0,
  char* mandant = 0)

Create a connection to a Soap service. If one of the arguments is 0 (not ""!), the login dialog will be opened. The result should be checked for 0 in any case. The pointer returned must be deleted again using soap::logout.

Name Type Default Description
Return SOAP   Pointer to the internet connection with successful connection or 0. The pointer must be deleted again using soap::logout!
service String or char* 0 Service name
user String or char* 0 User name
passwd String or char* 0 Password
lan String or char* 0 Language
mandant String or char* 0 Client

After the set up of the internet connection the current XML files will be uploaded to the service.

int main ()
{
    SOAP      	soap 	= soap::login (
     					"http://212.100.45.45:8080/cats-comet/cats/comet",
     					"admin",
     					0,
     					0,
     					"Erich Mühsam");
    char					xmlpath[4096];
    int 		res;
if (!soap) return 0; xmlquery::app_path (xmlpath);
res = soap::upload_metadata (soap, xmlpath); if (res) showmessage (   "Uploading metadata failed : %s.",   serror (res));
soap::upload_pageitems (soap, xmlpath); if (res) showmessage (   "Uploading pageitems failed : %s.",   serror (res));
soap::logout (soap);
return 0; }

Version 1.2 (15 June 2005)

priint:comet InDesign® Plug-Ins, comet_pdf

logout

static int logout(SOAP dbc)

End the connection to an internet service.

Name Type Default Description
Return int   0 or ErrorCode
dbc SOAP - Pointer to an internet connection created with login. The command may not delete the internet connection of InDesign® (soap::connection)!


priint:comet InDesign® Plug-Ins, comet_pdf

static char* server(SOAP dbc, char* str)

Ascertain the server name of an internet connection.

Name Type Default Description
Return String or char*   (Depends on parameter str) Name of the server using the specified internet connection. The return value is identical with the call parameter str.
dbc SOAP - Internet connection
str String or char* - Reserved memory for the server name. When using char*, the memory should be at least 256 bytes in size.
char		s[256];
showmessage ("%s", soap::server (soap::connection (), s));

Version 1.1.9 (2 May 2005)

priint:comet InDesign® Plug-Ins, comet_pdf

comet.CSOAP.getServer

static char* user(SOAP dbc, char* str)

Acertain the user name with which an internet connection is to be created.

Name Type Default Description
Return String or char*   (Depends on parameter str) User name for the specified internet connection. The return value is identical with the call parameter str.
dbc SOAP - Internet connection
str String or char* - Reserved memory for the user name. When using char*, the memory should be at least 256 bytes in size.
char		s[256];
showmessage ("%s", soap::user (soap::connection (), s));

Version 1.1.9 (2 May 2005)

priint:comet InDesign® Plug-Ins, comet_pdf

comet.CSOAP.getUser

static char* language(SOAP dbc, char* str)

Name Type Default Description
Return String or char*   (Depends on parameter str) Database name/schema for the specified internet connection. The return value is identical with the call parameter str.
dbc SOAP - Internet connection
str String or char* - Reserved memory for the server name. When using char*, the memory should be at least 256 bytes in size.
char		s[256];
showmessage ("%s", soap::language (soap::connection (), s));

Version 1.1.9 (2. Mai 2005)

priint:comet InDesign® Plug-Ins, comet_pdf

comet.CSOAP.getLanguage

static char* client(SOAP dbc, char* str)

Ascertain the name of the database to which an internet connection is set up.

Name Type Default Description
Return String or char*   (Depends on parameter str) Client for the specified internet connection. The return value is identical with the call parameter str.
dbc SOAP - Internet connection
str String or char* - Reserved memory for the client name. When using char*, the memory should be at least 256 bytes in size.
char		s[256];
showmessage ("%s", soap::client (soap::connection (), s));

VVersion 1.1.9 (2. Mai 2005)

priint:comet InDesign® Plug-Ins, comet_pdf

comet.CSOAP.getClient

static int charset(SOAP dbc)

Characterset of database connection.

Name Type Default Description
Return int   -1 : Error
0 : System characterset
1 : UTF8
2 : Unicode 16 Bit
3 : Unicode 32 Bit
dbc SOAP - database connection

v4.0.5 R14333, 4. Jan. 2017

priint:comet InDesign® Plug-Ins, comet_pdf

comet.CSOAP.getCharset

static int upload(
  SOAP soap,
  char* data,
  int datalen,
  char* id,
  char* fname = "",
  char* mimetype = "",
  char* description = "")

Send a file or a text to an internet service

Name Type Default Description
Return int   0 or ErrorCode
soap SOAP - Datalink in the internet
data String or char* - Data to be uploaded. The data needs to be text or a complete file path.
datalen int - Length of the data
-1 : data is a file path
0 : data contains text data the length of which is to be automatically calculated
otherwise : data contains text data of this length
id String or char* - Identifier under which the data is to be stored. Identifiers must be unique. If an upload exists with the specified ID, the data here will be changed. The ID will be used in download in order to retrieve the data.
fname String or char* "" Data name for the internet service. For files this parameter will be ignored, for data this must have a value.
mimetype String or char* "" Type description of the data e.g. text/plain. If this specification is empty, text data will be stored with the text/plain Mime type. For files an attempt will be made to ascertain the Mimetype from the file extension or from the file type (only Macintosh).
description String or char* "" user-defined description of the data

Load the file colors.html of the curent XML files folder (Menu; Plug Ins -> Data folder ...) on the server. The file will be stored with the Id colors.xml.

SOAP		gSoap		= soap::connection ();
int doUpload (char * path, char * name) { char src[4096]; int err;
strcpy (src, path); strcat (src, "/"); strcat (src, name);
err = soap::upload (gSoap, src, -1, name); return err; }
int main () { char xmlpath[4069];
xmlquery::app_path (xmlpath);
gSoap = soap::connection (); if (!gSoap) { showmessage ("No connection to the internet service"); return 0; }
doUpload (xmlpath, "colors.xml"); }

Store a text on the server. The difference to the above example is that soap::upload has a value in the third parameter >= 0.

SOAP		gSoap		= soap::connection ();
int doUpload (char * id, char * content) { int err;
err = soap::upload (gSoap, content, 0, id, id); return err; }
int main () { char xmlpath[4069];
xmlquery::app_path (xmlpath);
gSoap = soap::connection (); if (!gSoap) { showmessage ("No connection to the internet service"); return 0; }
doUpload ("test_1.txt", "That is a test text.");
return 0; }


priint:comet InDesign® Plug-Ins, comet_pdf

comet.CSOAP.uploadFile

static char* download(
  SOAP soap,
  char* id,
  int* len,
  int* si_string)

Get the data of the internet service. The data is identified using the ID under which it is recorded using upload. The call automatically reserves the required memory for the result. This memory must be deleted with release.

    #include "internal/types.h"
    :
    data_ptr = soap::download (gSoap, id, &result_len, &is_string);
    release (data_ptr);

Name Type Default Description
Return char*   Pointer to received data. The data must be deleted again using release.
soap SOAP - Valid connection to server
id String or char* - Data key under which the data is stored with the upload.
len int* - Output : Length of the data in bytes.
is_string int* - Output : Did we get binary data or a string?

0 : binary data. Do not use binary data in string functions like strcpy!

1 : char* data. The string a null terminated already.

Get the text stored above again from the server. Do not forget to test the fetched contents, to see if it is a string. And do not forget to delete the fetched contents again from the memory using release.

#include "internal/types.h"
SOAP gSoap = soap::connection ();
int doDownload (char * id, char ** content) { char * result; int result_len; int is_string;
*content = 0; result = soap::download (gSoap, id, &result_len, &is_string); if (result) { if (is_string) *content = result; else release (result); }
return 1; }
int main () { char * string_content;
gSoap = soap::connection (); if (!gSoap) { showmessage ("No connection to server."); return 0; }
doDownload ("test_1.txt", &string_content); if (!string_content) { showmessage ("No data found"); return 0; }
showmessage ("<%s>", string_content); release (string_content);
return 0; }


priint:comet InDesign® Plug-Ins, comet_pdf

comet.CSOAP.download

static int download_tofile(
  SOAP soap,
  char* id,
  char* path,
  char* name = 0,
  char* type = 0,
  char* creator = 0)

Get data from the internet service. The data are identified by means of the ID under which they were booked with upload, and stored as files.

Name Type Default Description
Return int   0 or ErrorCode
soap SOAP - Datalink in the internet
id String or char* - Data key under which the data was stored with upload.
path String or char* - Target path for the file. If the folder does not exist, it will be automatically created.
name String or char* 0 Name of the file. If the specification is absent, the data name stored in the internet data will be used.
type String or char* 0 File type (Macintosh). If a string is specified, it must be exactly 4 characters long. If the specifications for type and creator are missing, they will be ascertained from the suffix of the file.
creator String or char* 0 File Creator (Macintosh). If a string is specified, it must be exactly 4 characters long. If the specifications for type and creator are missing, they will be ascertained from the suffix of the file.

Get the file stored under ID colors.xml from the server

SOAP		gSoap		= soap::connection ();
int doDownload (char * id, char * path) { int err; err = soap::download_tofile (gSoap, id, path); return err; }
int main () { gSoap = soap::connection (); if (!gSoap) { showmessage ("No connection to the internet service"); return 0; }
doDownload ("colors.xml", "/Users/paul/Desktop/aaaa/bbb");
return 0; }


priint:comet InDesign® Plug-Ins, comet_pdf

static int upload_metadata(SOAP soap, char* path)

Filing of all the description data for placeholders, scripts , ... .for the Werk II plugins

Name Type Default Description
Return int   0 or ErrorCode
soap SOAP - Data link to the internet
path String or char* - Path of the description data

The example uploads all required files of the current data folder (Menu Plug Ins -> Data folder ...) to the server. Pageitems are not stored (for more see upload_pageitems).

#include "internal/types.h"
SOAP gSoap = soap::connection ();
int main () { char xmlpath [4096]; int res;
gSoap = soap::connection (); if (!gSoap) { showmessage ("No connection to the internet service"); return 0; }
xmlquery::app_path (xmlpath); res = soap::upload_metadata (gSoap, xmlpath); if (res) showmessage (serror (res));
return 0; }


priint:comet InDesign® Plug-Ins, comet_pdf

upload_pageitems
comet.CSOAP.uploadData
comet.CSOAP.uploadFile

static int upload_pageitems(SOAP soap, char* path)

Upload all pageitems to the server.

Name Type Default Description
Return int   0 or ErrorCode
soap SOAP - data link to the internet
path String or char* - Path of the description data

The example uploads all required files of the current data folder (Menu Plug Ins -> data folder ...) to the server.

#include "internal/types.h"
SOAP gSoap = soap::connection ();
int main () { char xmlpath [4096]; int res;
gSoap = soap::connection (); if (!gSoap) { showmessage ("No connection to the internet"); return 0; }
xmlquery::app_path (xmlpath); res = soap::upload_pageitems (gSoap, xmlpath); if (res) showmessage (serror (res));
return 0; }


priint:comet InDesign® Plug-Ins, comet_pdf

upload_metadata
comet.CSOAP.uploadData
comet.CSOAP.uploadFile

static int upload_folder(
  SOAP soap,
  char* path,
  char* idbase)

All files of the specified folder and all its sub-folders are uploaded to the server.

Name Type Default Description
Return int   0 or ErrorCode
soap SOAP - Data link to the internet
basepath String or char* - Complete system path to the folder
idbase String or char* "" Base for the ID of the SOAP record. If the string is not empty, a "/" will be automatically appended.


priint:comet InDesign® Plug-Ins, comet_pdf

comet.CSOAP.uploadFolder

static Query call(SOAP soap, char* method)

Create a new transaction query for calls to the generic SOAP operation "call".

The result consists of exactly one char* row.

Name Type Default Description
Return Query   new query
soap SOAP - current SOAP connection
method String or char* - method/statement to execute

See getlist


priint:comet InDesign® Plug-Ins, comet_pdf

static Query getlist(SOAP soap, char* method)

Create a transaction for the SOAP operation getList.

Calling soap::getlist is the same like sql::new_query followed by query::send (qu, "getlist Methodenname");
On other connection types it compares to a call to soap::call sql::new_query.
See examples below. Take care of the following :

The methods returns exactly the rows needed to load the product pool panel. For more information see here..

Name Type Default Description
Return Query   new query Check the result against 0 in all cases!
soap SOAP - Valid database connection
method String or char* - SOAP method to execute

Example 1: soap::call and soap::getlist with SOAP as SQL Proxy

  Query qu;
//  a)
  qu = sql::new_query ();
  query::send (qu, "DELETE FROM actions WHERE id = ?");
//  ... conform to
  qu = soap::call ("sql.dml");
  query::send (qu, "DELETE FROM actions WHERE id = ?");
//  ... or
  qu = sql::new_query ();
  query::send ("call sql.dml DELETE FROM actions WHERE id = ?");
// (Statements beginning with UPDATE, INSERT, COMMIT,
// EXECUTE,DROP or ALTER are too, of course

// b)   qu = sql::new_query ();   query::send (qu, "SELECT COUNT(id) FROM actions"); // ... conform to   qu = soap::getlist ("sql");   query::send ("SELECT COUNT (id) FROM actions"); // ... or   qu = sql::new_query ();   query::send ("getlist sql SELECT COUNT (id) FROM actions");

Beispiel 2: soap::call and soap::getlist on generic calls

//  a)				
  qu = sql::new_query ();
  query::send ("call MyMethod some arguments");
//  ... conform to
  qu = soap::call ("MyMethod");
  query::send (qu, "some arguments");
// b)
  qu = sql::new_query ();
  query::send ("getlist MyMethod some arguments");
//  is the same like:
  qu = soap::getlist ("MyMethod");
  query::send (qu, "some arguments");

Beispiel 3: Calling of other SOAP methods

//  Calling getProductList				
  qu = sql::new_query ();
  query::send ("getProductList i = ? AND j = ? etc.");
// This conforms to the following calls too : 
//   getSubProductList, getElementList, autoCometGetNextJob,
//   autocometSetStart, autocometSetDone, autocometSetStatus and
//   autocometGetNextHotfolder
// Take care to bind the appropriate result columns against the calls!


priint:comet InDesign® Plug-Ins, comet_pdf

static int setlanguage(SOAP soap, char* language)

Set the connection language.

Name Type Default Description
Return int   Errorcode oder 0
soap SOAP - internet connection
language String or char* - the language

set the connection language

#include "internal/types.h"
SOAP gSoap = soap::connection ();
int main () { int res; gSoap = soap::connection (); if (!gSoap) { showmessage ("No connection to internet service"); return 0; }
res = soap::setlanguage (gSoap, "enEN"); return res; }

Plugin Version 3.1 R2212

priint:comet InDesign® Plug-Ins, comet_pdf

static char* getmessage(SOAP soap, int resultCode)

Get description for a result or errorcode.

Name Type Default Description
Return char*   pointer to result string

The return value is read only, do NOT CHANGE. The result will be overridden on following calls to the function. See here to learn more about functions returning r/o char* values.

soap SOAP - internet connection
resultcode int - error or result code

get description of result code "17"

#include "internal/types.h"
SOAP gSoap = soap::connection ();
int main () { int res = 0; char* msg;
gSoap = soap::connection (); if (!gSoap) { showmessage ("no connection to internet"); return 0; }
msg = soap::getmessage (gSoap, 17); if (msg != 0) showmessage ("description for result code 17: '%s'", msg);
return res; }

Plugin Version 3.1 R2212

priint:comet InDesign® Plug-Ins, comet_pdf

Author
Paul Seidel
Version
23.05.2023, 08:34 Uhr
Since
Plugin Version 1.1.9 (2 May 2005)

Alphabetic index HTML hierarchy of classes or Java