|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (C) 2013-2016 |
|
4
|
|
|
* Piotr Olaszewski <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
7
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
|
8
|
|
|
* in the Software without restriction, including without limitation the rights |
|
9
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
10
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
|
11
|
|
|
* furnished to do so, subject to the following conditions: |
|
12
|
|
|
* |
|
13
|
|
|
* The above copyright notice and this permission notice shall be included in |
|
14
|
|
|
* all copies or substantial portions of the Software. |
|
15
|
|
|
* |
|
16
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
17
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
18
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
19
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
20
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
21
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
22
|
|
|
* SOFTWARE. |
|
23
|
|
|
*/ |
|
24
|
|
|
namespace Fixtures; |
|
25
|
|
|
|
|
26
|
|
|
use Ouzo\Utilities\Arrays; |
|
27
|
|
|
use Ouzo\Utilities\Functions; |
|
28
|
|
|
use stdClass; |
|
29
|
|
|
use WSDL\Annotation\BindingType; |
|
30
|
|
|
use WSDL\Annotation\SoapBinding; |
|
31
|
|
|
use WSDL\Annotation\WebMethod; |
|
32
|
|
|
use WSDL\Annotation\WebParam; |
|
33
|
|
|
use WSDL\Annotation\WebResult; |
|
34
|
|
|
use WSDL\Annotation\WebService; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* WebServiceAnnotations |
|
38
|
|
|
* |
|
39
|
|
|
* @author Piotr Olaszewski <[email protected]> |
|
40
|
|
|
* |
|
41
|
|
|
* @WebService( |
|
42
|
|
|
* name="WebServiceAnnotations", |
|
43
|
|
|
* targetNamespace="http://foo.bar/webserviceannotations", |
|
44
|
|
|
* location="http://localhost/wsdl-creator/service.php", |
|
45
|
|
|
* ns="http://foo.bar/webserviceannotations/types" |
|
46
|
|
|
* ) |
|
47
|
|
|
* @BindingType(value="SOAP_12") |
|
48
|
|
|
* @SoapBinding(style="DOCUMENT", use="ENCODED", parameterStyle="WRAPPED") |
|
49
|
|
|
*/ |
|
50
|
|
|
class WebServiceAllAnnotations |
|
51
|
|
|
{ |
|
52
|
|
|
/** |
|
53
|
|
|
* @WebMethod() |
|
54
|
|
|
* @WebParam(param="string $userName") |
|
55
|
|
|
* @WebResult(param="string $uppercasedUserName") |
|
56
|
|
|
*/ |
|
57
|
|
|
public function uppercaseUserName($userName) |
|
58
|
|
|
{ |
|
59
|
|
|
return strtoupper($userName); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @WebMethod() |
|
64
|
|
|
* @WebParam(param="int[] $numbers") |
|
65
|
|
|
* @WebParam(param="string $prefix") |
|
66
|
|
|
* @WebResult(param="string[] $numbersWithPrefix") |
|
67
|
|
|
*/ |
|
68
|
|
|
public function appendPrefixToNumbers($numbers, $prefix) |
|
69
|
|
|
{ |
|
70
|
|
|
return Arrays::map($numbers, Functions::prepend($prefix)); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @WebMethod() |
|
75
|
|
|
* @WebParam(param="string $token", header=true) |
|
76
|
|
|
* @WebParam(param="object $user { string $name int $age }") |
|
77
|
|
|
* @WebResult(param="object $userContext { string $token int $id object $userInfo { string $name int $age } }") |
|
78
|
|
|
*/ |
|
79
|
|
|
public function getUserContext($token, $user) |
|
80
|
|
|
{ |
|
81
|
|
|
$userContext = new stdClass(); |
|
82
|
|
|
$userContext->token = $token; |
|
83
|
|
|
$userContext->id = time(); |
|
84
|
|
|
$userContext->UserInfo = new stdClass(); |
|
85
|
|
|
$userContext->UserInfo->name = $user->name; |
|
86
|
|
|
$userContext->UserInfo->age = $user->age; |
|
87
|
|
|
return $userContext; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|