-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo2.php
153 lines (148 loc) · 3.57 KB
/
demo2.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
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
<?php
// This is a demonstration how to work with PhpWsdl without WSDL definitions in comments.
// More code, less comments. For whoever needs it... You may also mix definitions in
// comments AND in this way together.
// Include the demonstration classes
require_once('class.soapdemo.php');
require_once('class.complextypedemo.php');
// Initialize the PhpWsdl class
require_once('class.phpwsdl.php');
PhpWsdlMethod::$DefaultException='SoapFault';// This will set SoapFault as exception type for all methods
$soap=PhpWsdl::CreateInstance(
null, // PhpWsdl will determine a good namespace
null, // Change this to your SOAP endpoint URI (or keep it NULL and PhpWsdl will determine it)
'./cache', // Change this to a folder with write access
null, // PhpWsdl should not parse PHP comments for this demonstration
'SoapDemo', // The name of the class that serves the webservice
Array( // Add methods
new PhpWsdlMethod( // SoapDemo->GetComplexType method
'GetComplexType',
null,
new PhpWsdlParam(
'GetComplexTypeResult',
'ComplexTypeDemoB'
)
),
new PhpWsdlMethod( // SoapDemo->PrintComplexType method
'PrintComplexType',
Array(
new PhpWsdlParam(
'obj',
'ComplexTypeDemoB'
)
),
new PhpWsdlParam(
'PrintComplexTypeResult',
'string'
)
),
new PhpWsdlMethod( // SoapDemo->ComplexTypeArrayDemo method
'ComplexTypeArrayDemo',
Array(
new PhpWsdlParam(
'arr',
'ComplexTypeDemoBArray'
)
),
new PhpWsdlParam(
'return',
'stringArray'
)
),
new PhpWsdlMethod( // SoapDemo->SayHello method
'SayHello',
Array(
new PhpWsdlParam(
'name',
'string'
)
),
new PhpWsdlParam(
'return',
'string'
)
),
new PhpWsdlMethod( // SoapDemo->DemoMethod method
'DemoMethod'
)
),
Array( // Add complex types
new PhpWsdlComplex( // ComplexTypeDemo class
'ComplexTypeDemo',
Array(
new PhpWsdlElement(
'StringA',
'string'
),
new PhpWsdlElement(
'StringB',
'string'
),
new PhpWsdlElement(
'Integer',
'int'
),
new PhpWsdlElement(
'Boolean',
'boolean'
)
)
),
new PhpWsdlComplex( // ComplexTypeDemoB class
'ComplexTypeDemoB',
Array(
new PhpWsdlElement(
'AdditionalString',
'string'
)
),
Array(
'inherit' => 'ComplexTypeDemo'
)
),
new PhpWsdlComplex( // string array
'stringArray'
),
new PhpWsdlComplex( // ComplexTypeDemo array
'ComplexTypeDemoArray'
),
new PhpWsdlEnum( // string enumeration
'DemoEnum',
'string',
Array(
'ValueA',
'ValueB',
'ValueC'
)
),
new PhpWsdlComplex( // SoapFault exception type
'SoapFault',
Array(
new PhpWsdlElement(
'message',
'string'
),
new PhpWsdlElement(
'code',
'int'
),
new PhpWsdlElement(
'file',
'string'
),
new PhpWsdlElement(
'line',
'int'
)
)
)
),
false, // Don't send WSDL right now
false); // Don't start the SOAP server right now
// Disable caching for demonstration
ini_set('soap.wsdl_cache_enabled',0); // Disable caching in PHP
PhpWsdl::$CacheTime=0; // Disable caching in PhpWsdl
// Run the SOAP server
if($soap->IsWsdlRequested())
$soap->Optimize=false; // Don't optimize WSDL to send it human readable to the browser
$soap->RunServer(); // Finally, run the server