-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwsdldefinition.class
More file actions
240 lines (186 loc) · 7.69 KB
/
Copy pathwsdldefinition.class
File metadata and controls
240 lines (186 loc) · 7.69 KB
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<?php
class WSDLDefinition extends XMLement {
public $Messages;
public $Types;
public $PortTypes;
public $Bindings;
public $Services;
public function __construct($name, $uri, $documentation=NULL) {
parent::__construct('definitions', NULL, 'wsdl');
// XXX: URI defaults to NULL, pull from defaults like elsewhere
$this->AddDocumentation($this, $documentation);
$this->SetAttribute('name', $name);
$this->SetAttribute('targetNamespace', $uri);
$this->SetAttribute('xmlns:tns', $uri);
global $_CONF;
$this->SetAttribute('xmlns:xsd', $_CONF['namespaces']['xsd']);
$this->SetAttribute('xmlns:soap-enc', $_CONF['namespaces']['soap-enc']);
$this->Messages = array();
$this->Types = NULL;
$this->PortTypes = array();
$this->Bindings = array();
$this->Services = array();
}
public function NewMessage($name, $documentation=NULL) {
$message = $this->ForkChild('message');
$this->AddDocumentation($message, $documentation);
$message->SetAttribute('name', $name);
$this->Messages[$name] = $message;
}
public function AddMessagePart($m_name, $name, $type) {
$part = $this->Messages[$m_name]->ForkChild('part');
$part->SetAttribute('name', $name);
$part->SetAttribute('type', $type);
$this->Messages[$m_name]->AddChild($part);
}
public function NewPortType($name, $documentation=NULL) {
$porttype = $this->ForkChild('portType');
$this->AddDocumentation($porttype, $documentation);
$porttype->SetAttribute('name', $name);
$this->PortTypes[$name] = $porttype;
}
public function AddPortOperation($pt_name, $name, $input=NULL, $output=NULL, $fault=NULL,
$documentation=NULL) {
// XXX: Better input checking (strings, exception throwing)
$operation = $this->PortTypes[$pt_name]->ForkChild('operation');
$this->AddDocumentation($operation, $documentation);
$operation->SetAttribute('name', $name);
if ($input != NULL) {
$inode = $operation->ForkChild('input');
$inode->SetAttribute('message', $input);
$operation->AddChild($inode);
}
if ($output != NULL) {
$onode = $operation->ForkChild('output');
$onode->SetAttribute('message', $output);
$operation->AddChild($onode);
}
if ($fault != NULL) {
$fnode = $operation->ForkChild('fault');
$fnode->SetAttribute('message', $fault);
$operation->AddChild($fnode);
}
$this->PortTypes[$pt_name]->AddChild($operation);
}
public function AddSoapOperation($pt_name, $soap_action, $documentation=NULL) {
$soperation = new XMLement('operation', NULL, 'soap');
$this->AddDocumentation($soperation, $documentation);
$soperation->SetAttribute('soapAction', $soap_action);
$this->PortTypes[$pt_name]->AddChild($soperation);
}
public function NewBinding($name, $pt_name, $documentation=NULL) {
$binding = $this->ForkChild('binding');
$this->AddDocumentation($binding, $documentation);
$binding->SetAttribute('name', $name);
$binding->SetAttribute('type', $pt_name);
$this->Bindings[$name] = $binding;
}
/**
*
* @param array $input (keys: 'use', 'namespace', 'encodingStyle')
* @param array $output (keys: 'use', 'namespace', 'encodingStyle')
* @param array $fault (keys: 'name', 'use', 'namespace', 'encodingStyle')
* @param string $documentation
*/
public function AddBindingOperation($b_name, $name, $input=NULL, $output=NULL, $fault=NULL,
$documentation=NULL) {
$operation = $this->Bindings[$b_name]->ForkChild('operation');
$this->AddDocumentation($operation, $documentation);
$operation->SetAttribute('name', $name);
$nodes = array();
if ($input != NULL)
$nodes['input'] = $input;
if ($output != NULL)
$nodes['output'] = $output;
if ($fault != NULL)
$nodes['fault'] = $fault;
foreach ($nodes as $node_name => $node_attrs) {
$node = $operation->ForkChild($node_name);
$sbody = new XMLement('body', NULL, 'soap');
foreach ($node_attrs as $key => $value)
$sbody->SetAttribute($key, $value);
$node->AddChild($sbody);
$operation->AddChild($node);
}
$this->Bindings[$b_name]->AddChild($operation);
}
/* XXX: Hardcoded URL */
public function AddSoapBinding($b_name, $style='document',
$transport='http://schemas.xmlsoap.org/soap/http',
$documentation=NULL) {
$sbinding = new XMLement('binding', NULL, 'soap');
$this->AddDocumentation($sbinding, $documentation);
$sbinding->SetAttribute('style', $style);
$sbinding->SetAttribute('transport', $transport);
$this->Bindings[$b_name]->AddChild($sbinding);
}
public function AddService($name, $port_name, $binding, $location, $documentation=NULL) {
$service = $this->ForkChild('service');
$this->AddDocumentation($service, $documentation);
$service->SetAttribute('name', $name);
$port = $service->ForkChild('port');
$port->SetAttribute('name', $port_name);
$port->SetAttribute('binding', $binding);
$address = new XMLement('address', NULL, 'soap');
$address->SetAttribute('location', $location);
$port->AddChild($address);
$service->AddChild($port);
$this->Services[$name] = $service;
}
public function AddTypes($types) {
if ($this->Types = NULL)
$this->Types = $this->ForkChild('types');
// XXX: Implement me, XML Schema types
}
private function AddDocumentation(&$node, $documentation) {
if ($documentation == NULL)
return;
$docnode = $this->ForkChild('documentation', $documentation);
$node->AddChild($docnode);
}
public function GetType($type) {
switch ($type) {
/* Built-in Schema Types */
case 'str':
case 'string':
return 'xsd:string';
break;
case 'int':
case 'integer':
return 'xsd:integer';
break;
case 'float':
return 'xsd:float';
break;
case 'bool':
case 'boolean':
return 'xsd:boolean';
break;
case 'object':
return 'xsd:struct';
break;
/* Complex Types */
case 'array':
return 'soap-enc:Array';
break;
/* Ignore */
case 'void':
return NULL;
default:
return 'xsd:anyType';
}
}
public function Build() {
foreach ($this->Messages as $message)
$this->AddChild($message);
if ($this->Types != NULL)
$this->AddChild($this->Types);
foreach ($this->PortTypes as $porttype)
$this->AddChild($porttype);
foreach ($this->Bindings as $binding)
$this->AddChild($binding);
foreach ($this->Services as $service)
$this->AddChild($service);
}
}
?>