The library uses SOAP to pass data between applications. The C++ code is generated by gSoap.
| Function | Parameter Type | Remark |
| soap(log]) | string | Returns a SOAP object. The optional log parameter may be set to a file name to log access and errors. |
| :serve([port]) | integer | Starts service with the optional port number (default to 80). The server may return a string, an integer, a real, or an array of two items with the first being the pointer to binary data and the second being the number of bytes. |
| :request(http, service, p1[, p2, ...]) | string, string, string|integer|real|array | Sends server (http) with the service name and variable number of parameters. If an array parameter is used, it is expected to have two items with the first being the pointer to binary data and the second being the number of bytes. The service name is the function name on the server side. |
| :proxy(name, port) | string, integer | Uses the proxy to access server. |
/********************** Server *************************************/
load("soap.dll");
sp = soap();
// use while to keep server alive in case of SOAP error.
while (1) {
// use try to keep server alive in case of Z-Script error.
try {
sp:serve();
}
catch(error) {
csv(error);
}
}
// function names corresponding to service names
function p1_func(p)
{
csv(p);
return "Response: " + p;
}
function p3_func(p1, p2, p3)
{
csv(p1, p2, p3);
return "Response: p1=" + p1 + " p2=" + p2 + " p3=" + p3;
}
function b_func(p)
{
csv(p);
if (!isarray(p)) {
csv("Client parameter is not an array.");
return;
}
// return whatever binary from the client
return p;
}
/********************** Client *************************************/
load("soap.dll", "matrix.dll");
sp = soap();
a = sp:request("localhost", "p1_func", "Hi!");
csv(a);
a = sp:request("localhost", "p1_func", 100);
csv(a);
a = sp:request("localhost", "p1_func", 100.5);
csv(a);
a = sp:request("localhost", "p3_func", "Hi!", 100, 100.5);
csv(a);
D = matrix("double", 10);
D:fill(0, 1);
[ptr, m, e] = D:ptr();
a = sp:request("localhost", "b_func", [ptr, m*e]);
M = matrix("double");
M:import(a[0], a[1]);
M:print();