-
Notifications
You must be signed in to change notification settings - Fork 0
/
class.soapdemo.php
77 lines (70 loc) · 1.82 KB
/
class.soapdemo.php
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
<?php
if(basename($_SERVER['SCRIPT_FILENAME'])==basename(__FILE__))
exit;
/**
* This demo webservice shows you how to work with PhpWsdl
*
* @service SoapDemo
*/
class SoapDemo{
/**
* Get a complex type object
*
* @return ComplexTypeDemoB The object
*/
public function GetComplexType(){
return new ComplexTypeDemoB();
}
/**
* Print an object
*
* @param ComplexTypeDemoB $obj The object
* @return string The result of print_r
*/
public function PrintComplexType($obj){
return utf8_encode($this->PrintVariable($obj));
}
/**
* Print an array of objects
*
* @param ComplexTypeDemoBArray $arr A ComplexTypeDemoB array
* @return stringArray The results of print_r
*/
public function ComplexTypeArrayDemo($arr){
$res=Array();
$i=-1;
$len=sizeof($arr);
while(++$i<$len)
$res[]=$this->PrintVariable($arr[$i]);
return $res;
}
/**
* Say hello demo
*
* @param string $name Some name (or an empty string)
* @return string Response string
*/
public function SayHello($name=null){
$name=utf8_decode($name);// Because a string parameter may be UTF-8 encoded...
if($name=='')
$name='unknown';
return utf8_encode('Hello '.$name.'!');// Because a string return value should by UTF-8 encoded...
}
/**
* This method has no parameters and no return value, but it is visible in WSDL, too
*/
public function DemoMethod(){
throw(new SoapFault('DemoFault','This method will only throw an exception'));
}
/**
* This method should not be visible in WSDL - but notice:
* If the PHP SoapServer doesn't know the WSDL, this method is still accessable for SOAP requests!
*
* @ignore
* @param unknown_type $var
* @return string
*/
public function PrintVariable($var){
return print_r($var,true);
}
}