-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathHelper.php
221 lines (188 loc) · 5.64 KB
/
Helper.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?php
/*
* This file is part of BeSimpleSoapCommon.
*
* (c) Christian Kerl <[email protected]>
* (c) Francis Besset <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapCommon;
/**
* Soap helper class with static functions that are used in the client and
* server implementations. It also provides namespace and configuration
* constants.
*
* @author Andreas Schamberger <[email protected]>
*/
class Helper
{
/**
* Attachment type: xsd:base64Binary (native in ext/soap).
*/
const ATTACHMENTS_TYPE_BASE64 = 1;
/**
* Attachment type: MTOM (SOAP Message Transmission Optimization Mechanism).
*/
const ATTACHMENTS_TYPE_MTOM = 2;
/**
* Attachment type: SWA (SOAP Messages with Attachments).
*/
const ATTACHMENTS_TYPE_SWA = 4;
/**
* Web Services Security: SOAP Message Security 1.0 (WS-Security 2004)
*/
const NAME_WSS_SMS = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0';
/**
* Web Services Security: SOAP Message Security 1.1 (WS-Security 2004)
*/
const NAME_WSS_SMS_1_1 = 'http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1';
/**
* Web Services Security UsernameToken Profile 1.0
*/
const NAME_WSS_UTP = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0';
/**
* Web Services Security X.509 Certificate Token Profile
*/
const NAME_WSS_X509 = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0';
/**
* Soap 1.1 namespace.
*/
const NS_SOAP_1_1 = 'http://schemas.xmlsoap.org/soap/envelope/';
/**
* Soap 1.1 namespace.
*/
const NS_SOAP_1_2 = 'http://www.w3.org/2003/05/soap-envelope/';
/**
* Web Services Addressing 1.0 namespace.
*/
const NS_WSA = 'http://www.w3.org/2005/08/addressing';
/**
* WSDL 1.1 namespace.
*/
const NS_WSDL = 'http://schemas.xmlsoap.org/wsdl/';
/**
* WSDL MIME namespace.
*/
const NS_WSDL_MIME = 'http://schemas.xmlsoap.org/wsdl/mime/';
/**
* WSDL SOAP 1.1 namespace.
*/
const NS_WSDL_SOAP_1_1 = 'http://schemas.xmlsoap.org/wsdl/soap/';
/**
* WSDL SOAP 1.2 namespace.
*/
const NS_WSDL_SOAP_1_2 = 'http://schemas.xmlsoap.org/wsdl/soap12/';
/**
* Web Services Security Extension namespace.
*/
const NS_WSS = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
/**
* Web Services Security Utility namespace.
*/
const NS_WSU = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd';
/**
* Describing Media Content of Binary Data in XML namespace.
*/
const NS_XMLMIME = 'http://www.w3.org/2004/11/xmlmime';
/**
* XML Schema namespace.
*/
const NS_XML_SCHEMA = 'http://www.w3.org/2001/XMLSchema';
/**
* XML Schema instance namespace.
*/
const NS_XML_SCHEMA_INSTANCE = 'http://www.w3.org/2001/XMLSchema-instance';
/**
* XML-binary Optimized Packaging namespace.
*/
const NS_XOP = 'http://www.w3.org/2004/08/xop/include';
/**
* Web Services Addressing 1.0 prefix.
*/
const PFX_WSA = 'wsa';
/**
* WSDL 1.1 namespace. prefix.
*/
const PFX_WSDL = 'wsdl';
/**
* Web Services Security Extension namespace.
*/
const PFX_WSS = 'wsse';
/**
* Web Services Security Utility namespace prefix.
*/
const PFX_WSU = 'wsu';
/**
* Describing Media Content of Binary Data in XML namespace prefix.
*/
const PFX_XMLMIME = 'xmlmime';
/**
* XML Schema namespace prefix.
*/
const PFX_XML_SCHEMA = 'xsd';
/**
* XML Schema instance namespace prefix.
*/
const PFX_XML_SCHEMA_INSTANCE = 'xsi';
/**
* XML-binary Optimized Packaging namespace prefix.
*/
const PFX_XOP = 'xop';
/**
* Generate a pseudo-random version 4 UUID.
*
* @see http://de.php.net/manual/en/function.uniqid.php#94959
* @return string
*/
public static function generateUUID()
{
return sprintf(
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
// 16 bits for "time_mid"
mt_rand(0, 0xffff),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
mt_rand(0, 0x0fff) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
mt_rand(0, 0x3fff) | 0x8000,
// 48 bits for "node"
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
);
}
/**
* Get SOAP namespace for the given $version.
*
* @param int $version SOAP_1_1|SOAP_1_2
*
* @return string
*/
public static function getSoapNamespace($version)
{
if ($version === SOAP_1_2) {
return self::NS_SOAP_1_2;
} else {
return self::NS_SOAP_1_1;
}
}
/**
* Get SOAP version from namespace URI.
*
* @param string $namespace NS_SOAP_1_1|NS_SOAP_1_2
*
* @return int SOAP_1_1|SOAP_1_2
*/
public static function getSoapVersionFromNamespace($namespace)
{
if ($namespace === self::NS_SOAP_1_2) {
return SOAP_1_2;
} else {
return SOAP_1_1;
}
}
}