1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
/* XML-RPC Test Client for Rendering Server
Sends the teapot to XML-RPC server and saves resulting STL file. */
#include <string>
#include <iostream>
using namespace std;
#include <stdlib.h>
#include <stdio.h>
#include <xmlrpc-c/base.h>
#include <xmlrpc-c/client.h>
#include "config.h" /* information about this build environment */
#define NAME "Xmlrpc-c Test Client"
#define VERSION "1.0"
static void
die_if_fault_occurred (xmlrpc_env *env) {
if (env->fault_occurred) {
fprintf(stderr, "XML-RPC Fault: %s (%d)\n",
env->fault_string, env->fault_code);
exit(1);
}
}
int
main(int const argc,
const char ** const argv ATTR_UNUSED) {
xmlrpc_env env;
xmlrpc_value *result;
xmlrpc_int32 sum;
char * const serverUrl = "http://localhost:8080/RPC2";
char * const methodName = "render.stl";
if (argc-1 > 0) {
fprintf(stderr, "This program has no arguments\n");
exit(1);
}
/* Initialize our error-handling environment. */
xmlrpc_env_init(&env);
/* Start up our XML-RPC client library. */
xmlrpc_client_init2(&env, XMLRPC_CLIENT_NO_FLAGS, NAME, VERSION, NULL, 0);
die_if_fault_occurred(&env);
//
xmlrpc_limit_set(XMLRPC_XML_SIZE_LIMIT_ID, (unsigned int)50e6);
// Set up args
string math_string = "X**2 + Y**2 + Z**2 < 0.5";
xmlrpc_double min_feature = 0.1;
xmlrpc_double xmin = -1.0;
xmlrpc_double xmax = 1.0;
xmlrpc_double ymin = -1.0;
xmlrpc_double ymax = 1.0;
xmlrpc_double zmin = -1.0;
xmlrpc_double zmax = 1.0;
cout << "Making XMLRPC call to server " << serverUrl << "\n";
cout << "Method " << methodName << "\n";
cout << "Math String: " << math_string << "\n";
cout << "Minimum Feature: " << min_feature << "\n";
cout << "xmin: << " << xmin << " xmax: " << xmax << "\n";
cout << "ymin: << " << ymin << " ymax: " << ymax << "\n";
cout << "zmin: << " << zmin << " zmax: " << zmax << "\n";
/* Make the remote procedure call */
result = xmlrpc_client_call(&env, serverUrl, methodName,
"(sddddddd)", math_string.c_str(), min_feature, xmin, xmax, ymin, ymax, zmin, zmax);
die_if_fault_occurred(&env);
char *status_message;
int status_code;
double user_time;
char *stl;
int stl_length;
xmlrpc_decompose_value(&env, result, "(sid6)", &status_message, &status_code,
&user_time, &stl, &stl_length);
cout << "STL: " << stl[0] << stl[1] << "\n";
// Print status information
cout << "Status Message: " << status_message << "\n";
cout << "Status Code: " << status_code << "\n";
cout << "User Time: " << user_time << "\n";
cout << "STL Length: " << stl_length << "\n";
/* Dispose of our result value. */
xmlrpc_DECREF(result);
/* Clean up our error-handling environment. */
xmlrpc_env_clean(&env);
/* Shutdown our XML-RPC client library. */
xmlrpc_client_cleanup();
return 0;
}
|