MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
class.phpwsdlmethod.php
Ir para a documentação deste ficheiro.
1
<?php
2
3
/*
4
PhpWsdl - Generate WSDL from PHP
5
Copyright (C) 2011 Andreas Zimmermann, wan24.de
6
7
This program is free software; you can redistribute it and/or modify it under
8
the terms of the GNU General Public License as published by the Free Software
9
Foundation; either version 3 of the License, or (at your option) any later
10
version.
11
12
This program is distributed in the hope that it will be useful, but WITHOUT
13
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15
16
You should have received a copy of the GNU General Public License along with
17
this program; if not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
if
(basename($_SERVER[
'SCRIPT_FILENAME'
])==basename(__FILE__))
21
exit;
22
23
PhpWsdl::RegisterHook
(
'InterpretKeywordpw_omitfncHook'
,
'internal'
,
'PhpWsdlMethod::InterpretOmit'
);
24
PhpWsdl::RegisterHook
(
'InterpretKeywordignoreHook'
,
'internal'
,
'PhpWsdlMethod::InterpretOmit'
);
25
PhpWsdl::RegisterHook
(
'InterpretKeywordpw_setHook'
,
'internal'
,
'PhpWsdlMethod::InterpretSetting'
);
26
PhpWsdl::RegisterHook
(
'CreateObjectHook'
,
'internalmethod'
,
'PhpWsdlMethod::CreateMethodObject'
);
27
33
class
PhpWsdlMethod
extends
PhpWsdlObject
{
39
public
$Param
=Array();
45
public
$Return
=
null
;
51
public
$IsGlobal
=
false
;
57
public
static
$IsGlobalDefault
=
false
;
58
67
public
function
PhpWsdlMethod
($name,$param=
null
,$return=
null
,$settings=
null
){
68
self::__construct
($name, $param, $return, $settings);
69
}
70
71
public
function
__construct
($name,$param=
null
,$return=
null
,$settings=
null
){
72
PhpWsdl::Debug
(
'New method '
.$name);
73
parent::__construct($name,$settings);
74
if
(!is_null($param))
75
$this->Param=$param;
76
$this->Return=$return;
77
$this->IsGlobal=
self::$IsGlobalDefault
;
78
if
(!is_null($settings))
79
if
(isset($settings[
'global'
]))
80
$this->IsGlobal=$settings[
'global'
]==
'true'
||$settings[
'global'
]==
'1'
;
81
}
82
89
public
function
CreatePortType
($pw){
90
PhpWsdl::Debug
(
'Create WSDL port type for method '
.$this->Name);
91
$res=Array();
92
$res[]=
'<wsdl:operation name="'
.$this->Name.
'"'
;
93
$o=
sizeof
($res)-1;
94
$pLen=
sizeof
(
$this->Param
);
95
if
($pLen>1){
96
$temp=Array();
97
$i=-1;
98
while
(++$i<$pLen)
99
$temp[]=$this->Param[$i]->Name;
100
$res[$o].=
' parameterOrder="'
.implode(
' '
,$temp).
'"'
;
101
}
102
$res[$o].=
'>'
;
103
if
($pw->IncludeDocs&&!$pw->Optimize&&!is_null($this->Docs))
104
$res[]=
'<wsdl:documentation><![CDATA['
.$this->Docs.
']]></wsdl:documentation>'
;
105
$res[]=
'<wsdl:input message="tns:'
.$this->Name.
'SoapIn" />'
;
106
$res[]=
'<wsdl:output message="tns:'
.$this->Name.
'SoapOut" />'
;
107
$res[]=
'</wsdl:operation>'
;
108
return
implode(
''
,$res);
109
}
110
117
public
function
CreateBinding
($pw){
118
PhpWsdl::Debug
(
'Create WSDL binding for method '
.$this->Name);
119
$res=Array();
120
$res[]=
'<wsdl:operation name="'
.$this->Name.
'">'
;
121
$res[]=
'<soap:operation soapAction="'
.$pw->NameSpace.$this->Name.
'" />'
;
122
$res[]=
'<wsdl:input>'
;
123
$res[]=
'<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="'
.$pw->NameSpace.
'"'
;
124
$pLen=
sizeof
(
$this->Param
);
125
if
($pLen>0){
126
$temp=Array();
127
$i=-1;
128
while
(++$i<$pLen)
129
$temp[]=$this->Param[$i]->Name;
130
$res[
sizeof
($res)-1].=
' parts="'
.implode(
' '
,$temp).
'"'
;
131
}
132
$res[
sizeof
($res)-1].=
' />'
;
133
$res[]=
'</wsdl:input>'
;
134
$res[]=
'<wsdl:output>'
;
135
$res[]=
'<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="'
.$pw->NameSpace.
'"'
;
136
if
(!is_null($this->Return))
137
$res[
sizeof
($res)-1].=
' parts="'
.$this->Return->Name.
'"'
;
138
$res[
sizeof
($res)-1].=
' />'
;
139
$res[]=
'</wsdl:output>'
;
140
$res[]=
'</wsdl:operation>'
;
141
return
implode(
''
,$res);
142
}
143
150
public
function
CreateMessages
($pw){
151
PhpWsdl::Debug
(
'Create WSDL message for method '
.$this->Name);
152
$pLen=
sizeof
(
$this->Param
);
153
$res=Array();
154
// Request
155
if
($pLen<1){
156
$res[]=
'<wsdl:message name="'
.$this->Name.
'SoapIn" />'
;
157
}
else
{
158
$res[]=
'<wsdl:message name="'
.$this->Name.
'SoapIn">'
;
159
$i=-1;
160
while
(++$i<$pLen)
161
$res[]=$this->Param[$i]->CreatePart($pw);
162
$res[]=
'</wsdl:message>'
;
163
}
164
// Response
165
if
(is_null($this->Return)){
166
$res[]=
'<wsdl:message name="'
.$this->Name.
'SoapOut" />'
;
167
}
else
{
168
$res[]=
'<wsdl:message name="'
.$this->Name.
'SoapOut">'
;
169
$res[]=$this->Return->CreatePart($pw);
170
$res[]=
'</wsdl:message>'
;
171
}
172
return
implode(
''
,$res);
173
}
174
181
public
function
GetParam
($name){
182
PhpWsdl::Debug
(
'Find parameter '
.$name);
183
$i=-1;
184
$len=
sizeof
(
$this->Param
);
185
while
(++$i<$len)
186
if
($this->Param[$i]->Name==$name){
187
PhpWsdl::Debug
(
'Found parameter at index '
.$i);
188
return
$this->Param[$i];
189
}
190
return
null
;
191
}
192
198
public
function
CreateMethodHtml
($data){
199
PhpWsdl::Debug
(
'CreateMethodHtml for '
.$data[
'method'
]->Name);
200
$res=&$data[
'res'
];
201
$m=&$data[
'method'
];
202
$res[]=
'<h3>'
.$m->Name.
'</h3>'
;
203
$res[]=
'<a name="'
.$m->Name.
'"></a>'
;
204
$res[]=
'<p class="pre">'
;
205
$o=
sizeof
($res)-1;
206
if
(!is_null($m->Return)){
207
$type=$m->Return->Type;
208
if
(in_array($type,
PhpWsdl::$BasicTypes
)){
209
$res[$o].=
'<span class="blue">'
.$type.
'</span>'
;
210
}
else
{
211
$res[$o].=
'<a href="#'
.$type.
'"><span class="lightBlue">'
.$type.
'</span></a>'
;
212
}
213
}
else
{
214
$res[$o].=
'void'
;
215
}
216
$res[$o].=
' <span class="bold">'
.$m->Name.
'</span> ('
;
217
$pLen=
sizeof
($m->Param);
218
$spacer=
''
;
219
if
($pLen>1){
220
$res[$o].=
'<br>'
;
221
$spacer=
' '
;
222
}
223
$hasDocs=
false
;
224
if
($pLen>0){
225
$j=-1;
226
while
(++$j<$pLen){
227
$p=$m->Param[$j];
228
if
(in_array($p->Type,
PhpWsdl::$BasicTypes
)){
229
$res[]=$spacer.
'<span class="blue">'
.$p->Type.
'</span> <span class="bold">'
.$p->Name.
'</span>'
;
230
}
else
{
231
$res[]=$spacer.
'<a href="#'
.$p->Type.
'"><span class="lightBlue">'
.$p->Type.
'</span></a> <span class="bold">'
.$p->Name.
'</span>'
;
232
}
233
$o=
sizeof
($res)-1;
234
if
($j<$pLen-1)
235
$res[$o].=
', '
;
236
if
($pLen>1)
237
$res[$o].=
'<br>'
;
238
if
(!$hasDocs)
239
if
(!is_null($p->Docs))
240
$hasDocs=
true
;
241
}
242
}
243
$res[].=
')</p>'
;
244
// Method documentation
245
if
(!is_null($m->Docs))
246
$res[]=
'<p>'
.nl2br(htmlentities($m->Docs)).
'</p>'
;
247
// Parameters documentation
248
if
($hasDocs){
249
$res[]=
'<ul>'
;
250
$j=-1;
251
while
(++$j<$pLen)
252
$m->Param[$j]->CreateParamHtml(array_merge(
253
$data,
254
Array(
255
'param'
=> $m->Param[$j]
256
)
257
)
258
);
259
$res[]=
'</ul>'
;
260
}
261
// Return value documentation
262
if
(!is_null($m->Return)&&!is_null($m->Return->Docs))
263
$m->Return->CreateReturnHtml($data);
264
PhpWsdl::CallHook
(
265
'CreateMethodHtmlHook'
,
266
$data
267
);
268
}
269
275
public
function
CreateMethodPhp
($data){
276
$server=$data[
'server'
];
277
$res=&$data[
'res'
];
278
$res[]=
"\t/**"
;
279
if
(!is_null($this->Docs)){
280
$res[]=
"\t * "
.implode(
"\n\t * "
,explode(
"\n"
,$this->Docs));
281
$res[]=
"\t *"
;
282
}
283
$param=Array();
284
$i=-1;
285
$pLen=
sizeof
(
$this->Param
);
286
while
(++$i<$pLen){
287
$p=$this->Param[$i];
288
$param[]=
'$'
.$p->Name;
289
$res[]=
"\t * @param "
.$p->Type.
" \$"
.$p->Name.((!is_null($p->Docs))?
" "
.implode(
"\n\t * "
,explode(
"\n"
,$p->Docs)):
""
);
290
}
291
if
(!is_null($this->Return)){
292
$res[]=
"\t * @return "
.$this->Return->Type.((!is_null($this->Return->Docs))?
" "
.implode(
"\n\t * "
,explode(
"\n"
,$this->Return->Docs)):
""
);
293
}
294
$res[]=
"\t */"
;
295
$res[]=
"\tpublic function "
.$this->Name.
"("
.implode(
','
,$param).
"){"
;
296
if
(
PhpWsdl::CallHook
(
297
'CreateMethodPhpHook'
,
298
array_merge(
299
$data,
300
Array(
301
'method'
=> $this
302
)
303
)
304
)
305
){
306
$res[]=
"\t\treturn self::_Call('"
.$this->Name.
"',Array("
;
307
if
($pLen>0)
308
$res[]=
"\t\t\t"
.implode(
",\n\t\t\t"
,$param);
309
$res[]=
"\t\t));"
;
310
}
311
$res[]=
"\t}"
;
312
}
313
320
public
static
function
InterpretSetting
($data){
321
$info=explode(
' '
,$data[
'keyword'
][1],2);
322
if
(
sizeof
($info)<1)
323
return
true
;
324
PhpWsdl::Debug
(
'Interpret setting '
.$info[0]);
325
$info=explode(
'='
,$info[0],2);
326
if
(
sizeof
($info)>1){
327
$data[
'settings'
][$info[0]]=$info[1];
328
}
else
if
(isset($data[
'settings'
][$info[0]])){
329
unset($data[
'settings'
][$info[0]]);
330
}
331
return
false
;
332
}
333
340
public
static
function
InterpretOmit
($data){
341
PhpWsdl::Debug
(
'Interpret omitfnc/ignore'
);
342
$data[
'omit'
]=
true
;
343
return
true
;
344
}
345
352
public
static
function
CreateMethodObject
($data){
353
if
(!is_null($data[
'obj'
]))
354
return
true
;
355
if
($data[
'method'
]==
''
)
356
return
true
;
357
if
(!is_null($data[
'type'
]))
358
return
true
;
359
PhpWsdl::Debug
(
'Add method '
.$data[
'method'
]);
360
$server=$data[
'server'
];
361
if
(!is_null($server->GetMethod($data[
'method'
]))){
362
PhpWsdl::Debug
(
'WARNING: Double method detected!'
);
363
return
true
;
364
}
365
if
($server->ParseDocs)
366
if
(!is_null($data[
'docs'
]))
367
$data[
'settings'
][
'docs'
]=$data[
'docs'
];
368
$data[
'obj'
]=
new
PhpWsdlMethod
($data[
'method'
],$data[
'param'
],$data[
'return'
],$data[
'settings'
]);
369
$data[
'settings'
]=Array();
370
$server->Methods[]=$data[
'obj'
];
371
return
true
;
372
}
373
}
PhpWsdlMethod
Definição
class.phpwsdlmethod.php:33
PhpWsdlMethod\PhpWsdlMethod
PhpWsdlMethod($name, $param=null, $return=null, $settings=null)
Definição
class.phpwsdlmethod.php:67
PhpWsdlMethod\$IsGlobal
$IsGlobal
Definição
class.phpwsdlmethod.php:51
PhpWsdlMethod\InterpretOmit
static InterpretOmit($data)
Definição
class.phpwsdlmethod.php:340
PhpWsdlMethod\CreateMethodPhp
CreateMethodPhp($data)
Definição
class.phpwsdlmethod.php:275
PhpWsdlMethod\$Return
$Return
Definição
class.phpwsdlmethod.php:45
PhpWsdlMethod\CreateMethodHtml
CreateMethodHtml($data)
Definição
class.phpwsdlmethod.php:198
PhpWsdlMethod\$IsGlobalDefault
static $IsGlobalDefault
Definição
class.phpwsdlmethod.php:57
PhpWsdlMethod\CreateBinding
CreateBinding($pw)
Definição
class.phpwsdlmethod.php:117
PhpWsdlMethod\$Param
$Param
Definição
class.phpwsdlmethod.php:39
PhpWsdlMethod\CreatePortType
CreatePortType($pw)
Definição
class.phpwsdlmethod.php:89
PhpWsdlMethod\CreateMethodObject
static CreateMethodObject($data)
Definição
class.phpwsdlmethod.php:352
PhpWsdlMethod\__construct
__construct($name, $param=null, $return=null, $settings=null)
Definição
class.phpwsdlmethod.php:71
PhpWsdlMethod\InterpretSetting
static InterpretSetting($data)
Definição
class.phpwsdlmethod.php:320
PhpWsdlMethod\CreateMessages
CreateMessages($pw)
Definição
class.phpwsdlmethod.php:150
PhpWsdlMethod\GetParam
GetParam($name)
Definição
class.phpwsdlmethod.php:181
PhpWsdlObject
Definição
class.phpwsdlobject.php:28
PhpWsdl\Debug
static Debug($str)
Definição
class.phpwsdl.php:2399
PhpWsdl\RegisterHook
static RegisterHook($hook, $name, $data)
Definição
class.phpwsdl.php:2344
PhpWsdl\$BasicTypes
static $BasicTypes
Definição
class.phpwsdl.php:193
PhpWsdl\CallHook
static CallHook($name, $data=null)
Definição
class.phpwsdl.php:2320
classes
contrib
phpWsdl
class.phpwsdlmethod.php
Gerado por
1.10.0