-
Notifications
You must be signed in to change notification settings - Fork 0
/
soapProxy.cpp
205 lines (179 loc) · 5.53 KB
/
soapProxy.cpp
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/* soapProxy.cpp
Generated by gSOAP 2.8.60 for hello.h
gSOAP XML Web services tools
Copyright (C) 2000-2018, Robert van Engelen, Genivia Inc. All Rights Reserved.
The soapcpp2 tool and its generated software are released under the GPL.
This program is released under the GPL with the additional exemption that
compiling, linking, and/or using OpenSSL is allowed.
--------------------------------------------------------------------------------
A commercial use license is available from Genivia Inc., [email protected]
--------------------------------------------------------------------------------
*/
#include "soapProxy.h"
Proxy::Proxy()
{ this->soap = soap_new();
this->soap_own = true;
Proxy_init(SOAP_IO_DEFAULT, SOAP_IO_DEFAULT);
}
Proxy::Proxy(const Proxy& rhs)
{ this->soap = rhs.soap;
this->soap_own = false;
this->soap_endpoint = rhs.soap_endpoint;
}
Proxy::Proxy(struct soap *_soap)
{ this->soap = _soap;
this->soap_own = false;
Proxy_init(_soap->imode, _soap->omode);
}
Proxy::Proxy(const char *endpoint)
{ this->soap = soap_new();
this->soap_own = true;
Proxy_init(SOAP_IO_DEFAULT, SOAP_IO_DEFAULT);
soap_endpoint = endpoint;
}
Proxy::Proxy(soap_mode iomode)
{ this->soap = soap_new();
this->soap_own = true;
Proxy_init(iomode, iomode);
}
Proxy::Proxy(const char *endpoint, soap_mode iomode)
{ this->soap = soap_new();
this->soap_own = true;
Proxy_init(iomode, iomode);
soap_endpoint = endpoint;
}
Proxy::Proxy(soap_mode imode, soap_mode omode)
{ this->soap = soap_new();
this->soap_own = true;
Proxy_init(imode, omode);
}
Proxy::~Proxy()
{ if (this->soap_own)
soap_free(this->soap);
}
void Proxy::Proxy_init(soap_mode imode, soap_mode omode)
{ soap_imode(this->soap, imode);
soap_omode(this->soap, omode);
soap_endpoint = NULL;
static const struct Namespace namespaces[] = {
{"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", "http://www.w3.org/*/soap-envelope", NULL},
{"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/", "http://www.w3.org/*/soap-encoding", NULL},
{"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance", NULL},
{"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema", NULL},
{"ns", "http://tempuri.org/ns.xsd", NULL, NULL},
{NULL, NULL, NULL, NULL}
};
soap_set_namespaces(this->soap, namespaces);
}
Proxy *Proxy::copy()
{ Proxy *dup = SOAP_NEW_UNMANAGED(Proxy);
if (dup)
soap_copy_context(dup->soap, this->soap);
return dup;
}
Proxy& Proxy::operator=(const Proxy& rhs)
{ if (this->soap != rhs.soap)
{ if (this->soap_own)
soap_free(this->soap);
this->soap = rhs.soap;
this->soap_own = false;
this->soap_endpoint = rhs.soap_endpoint;
}
return *this;
}
void Proxy::destroy()
{ soap_destroy(this->soap);
soap_end(this->soap);
}
void Proxy::reset()
{ this->destroy();
soap_done(this->soap);
soap_initialize(this->soap);
Proxy_init(SOAP_IO_DEFAULT, SOAP_IO_DEFAULT);
}
void Proxy::soap_noheader()
{ this->soap->header = NULL;
}
::SOAP_ENV__Header *Proxy::soap_header()
{ return this->soap->header;
}
::SOAP_ENV__Fault *Proxy::soap_fault()
{ return this->soap->fault;
}
const char *Proxy::soap_fault_string()
{ return *soap_faultstring(this->soap);
}
const char *Proxy::soap_fault_detail()
{ return *soap_faultdetail(this->soap);
}
int Proxy::soap_close_socket()
{ return soap_closesock(this->soap);
}
int Proxy::soap_force_close_socket()
{ return soap_force_closesock(this->soap);
}
void Proxy::soap_print_fault(FILE *fd)
{ ::soap_print_fault(this->soap, fd);
}
#ifndef WITH_LEAN
#ifndef WITH_COMPAT
void Proxy::soap_stream_fault(std::ostream& os)
{ ::soap_stream_fault(this->soap, os);
}
#endif
char *Proxy::soap_sprint_fault(char *buf, size_t len)
{ return ::soap_sprint_fault(this->soap, buf, len);
}
#endif
int Proxy::hello(const char *endpoint, const char *soap_action, double input, double &output)
{ struct soap *soap = this->soap;
struct ns__hello soap_tmp_ns__hello;
struct ns__helloResponse *soap_tmp_ns__helloResponse;
if (endpoint)
soap_endpoint = endpoint;
soap_tmp_ns__hello.input = input;
soap_begin(soap);
soap->encodingStyle = NULL;
soap_serializeheader(soap);
soap_serialize_ns__hello(soap, &soap_tmp_ns__hello);
if (soap_begin_count(soap))
return soap->error;
if (soap->mode & SOAP_IO_LENGTH)
{ if (soap_envelope_begin_out(soap)
|| soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_put_ns__hello(soap, &soap_tmp_ns__hello, "ns:hello", "")
|| soap_body_end_out(soap)
|| soap_envelope_end_out(soap))
return soap->error;
}
if (soap_end_count(soap))
return soap->error;
if (soap_connect(soap, soap_endpoint, soap_action)
|| soap_envelope_begin_out(soap)
|| soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_put_ns__hello(soap, &soap_tmp_ns__hello, "ns:hello", "")
|| soap_body_end_out(soap)
|| soap_envelope_end_out(soap)
|| soap_end_send(soap))
return soap_closesock(soap);
if (!static_cast<double*>(&output)) // NULL ref?
return soap_closesock(soap);
soap_default_double(soap, &output);
if (soap_begin_recv(soap)
|| soap_envelope_begin_in(soap)
|| soap_recv_header(soap)
|| soap_body_begin_in(soap))
return soap_closesock(soap);
soap_tmp_ns__helloResponse = soap_get_ns__helloResponse(soap, NULL, "ns:helloResponse", NULL);
if (!soap_tmp_ns__helloResponse || soap->error)
return soap_recv_fault(soap, 0);
if (soap_body_end_in(soap)
|| soap_envelope_end_in(soap)
|| soap_end_recv(soap))
return soap_closesock(soap);
output = soap_tmp_ns__helloResponse->output;
return soap_closesock(soap);
}
/* End of client proxy code */