-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwsdlclass.class
More file actions
97 lines (76 loc) · 3.48 KB
/
Copy pathwsdlclass.class
File metadata and controls
97 lines (76 loc) · 3.48 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
<?php
class WSDLClass extends GrokClass {
public $Patterns = array(
'var' => '/(\@var) ([\w_]+)(\[\])*[\ ]?(.*)/',
'param' => '/(\@param) ([\w_]+)(\[\])* (\$[\w_]*),*([.]{3})*[\ ]?(.*)/',
'return' => '/(\@return) ([\w_]+)(\[\])*[\ ]?(.*)/');
public $IgnoreMethods = array('__construct', '__destruct', '__get', '__set',
'__call', '__sleep', '__wakeup');
public $Methods = array();
private $WSDL;
private $CurrentPort;
private $CurrentBinding;
public function __construct($class) {
parent::__construct($class);
}
public function NewClass($name, $comment) {
$this->WSDL = new WSDLDefinition($name, 'XXX');
$this->CurrentPort = $name . 'Port';
$this->WSDL->NewPortType($this->CurrentPort);
$this->CurrentBinding = $name . 'Binding';
$this->WSDL->NewBinding($this->CurrentBinding, 'tns:' . $name . 'Port');
$this->WSDL->AddSoapBinding($this->CurrentBinding, 'rpc');
$this->WSDL->AddService($name . 'Service', 'tns:' . $name . 'Port',
'tns:' . $this->CurrentBinding, 'XXX');
}
public function NewMethod($name, $comment, $public, $parameters) {
if (in_array($name, $this->IgnoreMethods))
return;
if (!$public)
return;
$this->Methods[] = $name;
$c_lines = explode("\n", $comment);
array_shift($c_lines);
array_pop($c_lines);
/* XXX: Hardcoded URL */
$io_arr = array('use' => 'encoded',
'encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/');
$this->WSDL->AddBindingOperation($this->CurrentBinding, $name, $io_arr, $io_arr);
$this->WSDL->AddSoapOperation($this->CurrentPort, 'XXX/soap/' . $this->CurrentClassName .
'/' . $name);
$request_name = $name . 'Request';
$this->WSDL->NewMessage($request_name);
$part_count = 0;
foreach ($c_lines as $line) {
if (preg_match($this->Patterns['param'], $line, $param_match)) {
$part_name = ltrim($param_match[4], '$');
$part_type = $this->WSDL->GetType($param_match[2]);
/* XXX: BUILD COMPLEX TYPE
if ($parameters[$part_name]['optional'])
*/
$this->WSDL->AddMessagePart($request_name, $part_name, $part_type);
$part_count++;
}
else if (preg_match($this->Patterns['return'], $line, $return_match)) {
$return_type = $this->WSDL->GetType($return_match[2]);
if ($return_type != NULL) {
$response_name = $name . 'Response';
$this->WSDL->NewMessage($response_name);
$this->WSDL->AddMessagePart($response_name, $name . 'Return', $return_type);
$part_count = 0;
}
}
}
/* No message parts, pull it */
if ($part_count == 0)
unset($this->WSDL->Messages[$request_name]);
$this->WSDL->AddPortOperation($this->CurrentPort, $name,
($part_count) ? 'tns:' . $name . 'Request' : NULL,
($return_type) ? 'tns:' . $name . 'Response' : NULL);
}
public function Render() {
$this->WSDL->Build();
return $this->WSDL->Render();
}
}
?>