1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
wsdlcreator.php
См. документацию.
1<?
2
4{
8
9 var $typens = array();
11
12 var $WSDL;
14
20
22
26 var $classes = array();
27
29 {
30 global $APPLICATION;
31
32 $serviceName = str_replace(" ", "_", $serviceName);
33 if (!$serviceUrl) $serviceUrl = ($APPLICATION->IsHTTPS() ? "https" : "http")."://".$_SERVER["HTTP_HOST"].$APPLICATION->GetCurPage();
34 if (!$targetNamespace) $targetNamespace = ($APPLICATION->IsHTTPS() ? "https" : "http")."://".$_SERVER["HTTP_HOST"]."/";
35
36 $this->WSDLXML = new CXMLCreator("wsdl:definitions");
37 $this->WSDLXML->setAttribute("name", $serviceName);
38 $this->WSDLXML->setAttribute("targetNamespace", $targetNamespace);
39 $this->WSDLXML->setAttribute("xmlns:tns",$targetNamespace);
40 $this->WSDLXML->setAttribute("xmlns:http","http://schemas.xmlsoap.org/wsdl/http/");
41 $this->WSDLXML->setAttribute("xmlns:mime","http://schemas.xmlsoap.org/wsdl/mime/");
42 $this->WSDLXML->setAttribute("xmlns:tm","http://microsoft.com/wsdl/mime/textMatching/");
43 $this->WSDLXML->setAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
44 $this->WSDLXML->setAttribute("xmlns:soap", "http://schemas.xmlsoap.org/wsdl/soap/");
45 $this->WSDLXML->setAttribute("xmlns:soap12", "http://schemas.xmlsoap.org/wsdl/soap12/");
46 $this->WSDLXML->setAttribute("xmlns:soapenc", "http://schemas.xmlsoap.org/soap/encoding/");
47 $this->WSDLXML->setAttribute("xmlns:wsdl", "http://schemas.xmlsoap.org/wsdl/");
48 //$this->WSDLXML->setAttribute("xmlns", "http://schemas.xmlsoap.org/wsdl/");
49 $this->serviceName = $serviceName;
50 $this->serviceUrl = $serviceUrl;
51 $this->targetNamespace = $targetNamespace;
52 }
53
55 {
56 $this->classes = $classes;
57 }
58
59 function AddComplexDataType($name, $vars)
60 {
61 global $xsd_simple_type;
62 if (isset($this->typensVars[$name]))
63 return true;
64
65 if (!count($vars)) return false;
66
67 $this->typensDefined[$name] = $name;
68 $this->typensXSDType[$name] = "type";
69
70 foreach ($vars as $pname => $param)
71 {
72 if (!is_array($param) or !isset($param["varType"])) continue;
73 $this->typensVars[$name][$pname] = $param;
74 if (!isset($xsd_simple_type[$param["varType"]]))
75 {
76 if (isset($param["arrType"]))
77 $this->AddArrayType($pname, $param);
78 else
79 $this->AddComplexDataType($pname, $param);
80 }
81 }
82
83 return true;
84 }
85
86 function AddArrayType($pname, $param)
87 {
88 if (isset($param["varType"])
89 and isset($this->typensVars[$param["varType"]]))
90 return true;
91
92 if (isset($param["arrType"]))
93 {
94 $arrType = $param["arrType"];
95
96 $maxOccurs = "unbounded";
97 if (isset($param["maxOccursA"])) $maxOccurs = $param["maxOccursA"];
98
99 $this->typensXSDType[$param["varType"]] = "type";
100 $this->typensDefined[$param["varType"]] = $param["varType"];
101 $this->typensVars[$param["varType"]] = array(
102 $param["varType"]."El" =>
103 array(
104 "varType" => $param["arrType"],
105 "maxOccurs" => $maxOccurs)
106 );
107
108 if (isset($param["nillableA"]))
109 $this->typensVars[$param["varType"]][$param["varType"]."El"]["nillable"] =
110 $param["nillableA"];
111
112 return true;
113 }
114
115 return false;
116 }
117
118 function __createMessage ($name, $returnType = false, $params = array())
119 {
120 global $xsd_simple_type;
121 $insoap = array();
122 $outsoap = array();
123 $message = new CXMLCreator("wsdl:message");
124 $message->setAttribute("name", $name."SoapIn");
125 $part = new CXMLCreator("wsdl:part");
126 $part->setAttribute("name", "parameters");
127 $part->setAttribute("element", "tns:".$name/*."Request"*/);
128 $message->addChild($part);
129
130 if (is_array($params)) {
131 foreach ($params as $pname=>$param) {
132 $type = isset($param["varType"]) ? $param["varType"]:"anyType";
133 if (isset($xsd_simple_type[$type])) {
134 $insoap[$pname] = $xsd_simple_type[$type];
135 $type = "xsd:".$xsd_simple_type[$type];
136 } else {
137 $this->AddArrayType($pname, $param);
138 $insoap[$pname] = $param["varType"];
139 $type = "tns".":".$param["varType"];
140 }
141 }
142 }
143 $this->messages[] = $message;
144 if ($returnType) {
145 //foreach ($returnType as $pname=>$param) break;
146 $message = new CXMLCreator("wsdl:message");
147 $message->setAttribute("name", $name."SoapOut");
148 $part = new CXMLCreator("wsdl:part");
149 $part->setAttribute("name", "parameters");
150 $part->setAttribute("element", "tns:".$name."Response");
151 $message->addChild($part);
152
153 //changed by Sigurd
154 if (is_array($params))
155 {
156 foreach ($returnType as $pname=>$param)
157 {
158 $type = isset($param["varType"]) ? $param["varType"]:"anyType";
159 if (isset($xsd_simple_type[$type])) {
160 $outsoap[$pname] = $xsd_simple_type[$type];
161 $type = "xsd:".$xsd_simple_type[$type];
162 } else {
163 if (isset($this->typeTypens[$type])) {
164 $type = $this->typeTypens[$type].":".$type;
165 } else {
166 $this->AddArrayType($pname, $param);
167 $outsoap[$pname] = $param["varType"];
168 $type = "tns".":".$param["varType"];
169 }
170 }
171 }
172 }
173
174 $this->messages[] = $message;
175 } else {
176 $message = new CXMLCreator("message");
177 $message->setAttribute("name", $name."Response");
178 $this->messages[] = $message;
179 }
180
181 $this->typensDefined[$name/*."Request"*/] = $name/*."Request"*/;
182 $this->typensDefined[$name."Response"] = $name."Response";
183 $this->typensVars[$name/*."Request"*/] = $insoap;
184 $this->typensVars[$name."Response"] = $outsoap;
185 }
186
188 {
189 if (is_array($portTypes)) {
190 foreach ($portTypes as $class=>$methods) {
191 $pt = new CXMLCreator("wsdl:portType");
192 $pt->setAttribute("name", $class."Interface");
193 foreach ($methods as $method=>$components) {
194 $op = new CXMLCreator("wsdl:operation");
195 $op->setAttribute("name", $method);
196
197 $input = new CXMLCreator("wsdl:input");
198 $input->setAttribute("message", "tns:".$method."SoapIn");
199 $op->addChild($input);
200
201 $output = new CXMLCreator("wsdl:output");
202 $output->setAttribute("message", "tns:".$method."SoapOut");
203 $op->addChild($output);
204
205 if ($components["documentation"]) {
206 $doc = new CXMLCreator("wsdl:documentation");
207 $doc->setData($components["documentation"]);
208 $op->addChild($doc);
209 }
210
211 $pt->addChild($op);
212 }
213 $this->portTypes[] = $pt;
214 }
215 }
216 }
217
219 {
220 if (is_array($bindings)) {
221 $b = new CXMLCreator("wsdl:binding");
222 foreach ($bindings as $class=>$methods) {
223 $b->setAttribute("name", $class."Binding");
224 $b->setAttribute("type", "tns:".$class."Interface");
225 $s = new CXMLCreator("soap:binding");
226 $s->setAttribute("transport", "http://schemas.xmlsoap.org/soap/http");
227 $b->addChild($s);
228 foreach ($methods as $method=>$components) {
229 $op = new CXMLCreator("wsdl:operation");
230 $op->setAttribute("name", $method);
231 $s = new CXMLCreator("soap:operation");
232 $s->setAttribute("soapAction", $this->targetNamespace.$method);
233 $s->setAttribute("style", "document");
234 $op->addChild($s);
235
236 $input = new CXMLCreator("wsdl:input");
237 $s = new CXMLCreator("soap:body");
238 $s->setAttribute("use", "literal");
239
240 $input->addChild($s);
241 $op->addChild($input);
242
243 $output = new CXMLCreator("wsdl:output");
244 $output->addChild($s);
245 $op->addChild($output);
246 $b->addChild($op);
247 }
248 $this->bindings[] = $b;
249 }
250 }
251 }
252
254 {
255 if (is_array($services)) {
256 foreach ($services as $class=>$methods) {
257 $port = new CXMLCreator("wsdl:port");
258 $port->setAttribute("name", $class."Soap");
259 $port->setAttribute("binding", "tns:".$class."Binding");
260 $soap = new CXMLCreator("soap:address");
261 $soap->setAttribute("location", $this->serviceUrl);
262 $port->addChild($soap);
263 $this->services[] = $port;
264 }
265 }
266 }
267
268 function createWSDL ()
269 {
270 global $xsd_simple_type;
271 if (!$this->classes or !count($this->classes)) return 0;
272
273 foreach ($this->classes as $class=>$methods) {
274 $pbs = array();
275 ksort($methods);
276 foreach ($methods as $method=>$components)
277 {
278 if ($components["type"] == "public") {
279 $this->__createMessage($method, $components["output"], $components["input"]);
280
281 $pbs[$class][$method]["documentation"] = $components["description"];
282 $pbs[$class][$method]["input"] = $components["input"];
283 $pbs[$class][$method]["output"] = $components["output"];
284 }
285 }
286 $this->__createPortType($pbs);
287 $this->__createBinding($pbs);
288 $this->__createService($pbs);
289 //AddMessage2Log(mydump($this->portTypes));
290 }
291
292 //echo '<pre>'; print_r($this); echo '</pre>';
293
294
295 // add types
296 if (is_array($this->typensDefined) && count($this->typensDefined) > 0) {
297 $types = new CXMLCreator("wsdl:types");
298 $xsdSchema = new CXMLCreator("xsd:schema");
299 $xsdSchema->setAttribute("elementFormDefault", "qualified");
300 $xsdSchema->setAttribute("targetNamespace", $this->targetNamespace);
301 foreach ($this->typensDefined as $typensDefined) {
302 $xsdtype = "element";
303 if (isset($this->typensXSDType[$typensDefined])) $xsdtype = "type";
304
305 if ($xsdtype == "element") {
306 $elroot = new CXMLCreator("xsd:element");
307 $elroot->setAttribute("name", $typensDefined);
308 }
309 $complexType = new CXMLCreator("xsd:complexType");
310 if ($xsdtype == "type")
311 $complexType->setAttribute("name", $typensDefined);
312
313 $all = new CXMLCreator("xsd:sequence");
314 if (isset($this->typensVars[$typensDefined])
315 and is_array($this->typensVars[$typensDefined])) {
316
317 //commented by Sigurd;
318
319 //ksort($this->typensVars[$typensDefined]);
320 foreach ($this->typensVars[$typensDefined] as $varName=>$varType) {
321
322 // check minOccurs|maxOccurs here!
323
324 $element = new CXMLCreator("xsd:element");
325 $element->setAttribute("minOccurs", 0);
326
327 if (is_array($varType) and isset($varType["maxOccurs"]))
328 $element->setAttribute("maxOccurs", $varType["maxOccurs"]);
329 else
330 $element->setAttribute("maxOccurs", 1);
331
332 if (is_array($varType) and isset($varType["nillable"]))
333 $element->setAttribute("nillable", $varType["nillable"]);
334
335 $element->setAttribute("name", $varName);
336
337 if (is_array($varType)) $varType = $varType["varType"];
338
339 if ($varType == 'any')
340 {
341 $any = new CXMLCreator('xsd:any');
342 $sequence = new CXMLCreator('xsd:sequence');
343 $sequence->addChild($any);
344 $element->addChild($sequence);
345 $complexType->setAttribute('mixed', "true");
346 }
347 else
348 {
349 $varType = isset($xsd_simple_type[$varType]) ? "xsd:".$xsd_simple_type[$varType] : "tns:".$varType;
350 $element->setAttribute("type", $varType);
351 }
352
353 $all->addChild($element);
354 }
355 }
356
357 $complexType->addChild($all);
358
359 if ($xsdtype == "element") {
360 $elroot->addChild($complexType);
361 $xsdSchema->addChild($elroot);
362 } else {
363 $xsdSchema->addChild($complexType);
364 }
365 }
366 $types->addChild($xsdSchema);
367 $this->WSDLXML->addChild($types);
368 }
369
370 // adding messages
371 foreach ($this->messages as $message) {
372 $this->WSDLXML->addChild($message);
373 }
374
375 // adding port types
376 foreach ($this->portTypes as $portType) {
377 $this->WSDLXML->addChild($portType);
378 }
379
380 // adding bindings
381 foreach ($this->bindings as $binding) {
382 $this->WSDLXML->addChild($binding);
383 }
384
385 // adding services
386 $s = new CXMLCreator("wsdl:service");
387 $s->setAttribute("name", $this->serviceName);
388 foreach ($this->services as $service) {
389 $s->addChild($service);
390 }
391 $this->WSDLXML->addChild($s);
392
393 $this->WSDL = "<?xml version='1.0' encoding='UTF-8'?>\n";
394 $this->WSDL .= $this->WSDLXML->getXML();
395
396 }
397
398 function getWSDL()
399 {
400 return $this->WSDL;
401 }
402
403 function printWSDL()
404 {
405 print $this->WSDL;
406 }
407
408 function saveWSDL ($targetFile, $overwrite = true)
409 {
410 if (file_exists($targetFile) && $overwrite == false) {
411 $this->downloadWSDL();
412 } elseif ($targetFile) {
413 $fh = fopen($targetFile, "w+");
414 fwrite($fh, $this->getWSDL());
415 fclose($fh);
416 }
417 }
418
419 function downloadWSDL ()
420 {
421 session_cache_limiter();
422 header("Content-Type: application/force-download");
423 header("Content-Disposition: attachment; filename=".$this->name.".wsdl");
424 header("Accept-Ranges: bytes");
425 header("Content-Length: " . strlen($this->WSDL));
426 $this->printWSDL();
427 die();
428 }
429}
430
431
432?>
$type
Определения options.php:106
global $APPLICATION
Определения include.php:80
Определения wsdlcreator.php:4
__createMessage($name, $returnType=false, $params=array())
Определения wsdlcreator.php:118
$paramsNames
Определения wsdlcreator.php:19
$messages
Определения wsdlcreator.php:15
$services
Определения wsdlcreator.php:18
$WSDLXML
Определения wsdlcreator.php:13
__createPortType($portTypes)
Определения wsdlcreator.php:187
AddComplexDataType($name, $vars)
Определения wsdlcreator.php:59
AddArrayType($pname, $param)
Определения wsdlcreator.php:86
getWSDL()
Определения wsdlcreator.php:398
$classes
Определения wsdlcreator.php:26
$typensXSDType
Определения wsdlcreator.php:5
printWSDL()
Определения wsdlcreator.php:403
__createService($services)
Определения wsdlcreator.php:253
$typensDefined
Определения wsdlcreator.php:7
$serviceUrl
Определения wsdlcreator.php:24
$serviceName
Определения wsdlcreator.php:23
$portTypes
Определения wsdlcreator.php:16
$typensVars
Определения wsdlcreator.php:6
$typens
Определения wsdlcreator.php:9
$targetNamespace
Определения wsdlcreator.php:25
$typeTypens
Определения wsdlcreator.php:10
$WSDL
Определения wsdlcreator.php:12
saveWSDL($targetFile, $overwrite=true)
Определения wsdlcreator.php:408
__construct($serviceName, $serviceUrl="", $targetNamespace="")
Определения wsdlcreator.php:28
$bindings
Определения wsdlcreator.php:17
__createBinding($bindings)
Определения wsdlcreator.php:218
setClasses($classes)
Определения wsdlcreator.php:54
downloadWSDL()
Определения wsdlcreator.php:419
$XMLCreator
Определения wsdlcreator.php:21
createWSDL()
Определения wsdlcreator.php:268
Определения xmlcreator.php:3
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$output
Определения options.php:436
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
$name
Определения menu_edit.php:35
$service
Определения payment.php:18
$message
Определения payment.php:8
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
die
Определения quickway.php:367
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$method
Определения index.php:27