|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace LaFourchette\AdobeCampaignClientBundle\Client; |
|
4
|
|
|
|
|
5
|
|
|
use BeSimple\SoapClient\SoapClient; |
|
6
|
|
|
use BeSimple\SoapClient\SoapRequest; |
|
7
|
|
|
use LaFourchette\AdobeCampaignClientBundle\Client\Configuration; |
|
8
|
|
|
use LaFourchette\AdobeCampaignClientBundle\Util\AdobeCampaignXmlLoader; |
|
9
|
|
|
|
|
10
|
|
|
class Client extends SoapClient |
|
11
|
|
|
{ |
|
12
|
|
|
const SOAP_ROUTER_PATH = '/nl/jsp/soaprouter.jsp'; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @var Configuration |
|
16
|
|
|
*/ |
|
17
|
|
|
private $configuration; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @var array |
|
21
|
|
|
*/ |
|
22
|
|
|
private $headers = array(); |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var string |
|
26
|
|
|
*/ |
|
27
|
|
|
private $schema; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @return Configuration |
|
31
|
|
|
*/ |
|
32
|
2 |
|
public function getConfiguration() |
|
33
|
|
|
{ |
|
34
|
2 |
|
return $this->configuration; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param Configuration |
|
39
|
|
|
* |
|
40
|
|
|
* @return Client |
|
41
|
|
|
*/ |
|
42
|
2 |
|
public function setConfiguration(Configuration $configuration) |
|
43
|
|
|
{ |
|
44
|
2 |
|
$this->configuration = $configuration; |
|
45
|
|
|
|
|
46
|
2 |
|
return $this; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param array $headers |
|
51
|
|
|
*/ |
|
52
|
1 |
|
public function setHttpHeaders(array $headers = array()) |
|
53
|
|
|
{ |
|
54
|
1 |
|
$this->headers = $headers; |
|
55
|
1 |
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param string $schema |
|
59
|
|
|
*/ |
|
60
|
2 |
|
public function setSchema($schema) |
|
61
|
|
|
{ |
|
62
|
2 |
|
$this->schema = $schema; |
|
63
|
2 |
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @return string |
|
67
|
|
|
*/ |
|
68
|
2 |
|
public function getSchema() |
|
69
|
|
|
{ |
|
70
|
2 |
|
return $this->schema; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* {@inheritdoc} |
|
75
|
|
|
*/ |
|
76
|
|
|
protected function filterRequestHeaders(SoapRequest $soapRequest, array $headers) |
|
77
|
|
|
{ |
|
78
|
|
|
$moreHeaders = array(); |
|
79
|
|
|
|
|
80
|
|
|
foreach ($this->headers as $key => $header) { |
|
81
|
|
|
$moreHeaders[] = $key . ':' . $header; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
return array_merge($headers, $moreHeaders); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Send a custom soap message |
|
89
|
|
|
* |
|
90
|
|
|
* @param $envelope |
|
91
|
|
|
* |
|
92
|
|
|
* @return \SimpleXMLElement |
|
93
|
|
|
*/ |
|
94
|
1 |
|
public function doCustomSoapRequest($envelope, $action) |
|
95
|
|
|
{ |
|
96
|
1 |
|
$response = $this->__doRequest( |
|
97
|
1 |
|
$envelope, |
|
98
|
1 |
|
$this->getConfiguration()->getBaseUri().self::SOAP_ROUTER_PATH, |
|
99
|
1 |
|
sprintf('%s#%s', $this->getSchema(), $action), |
|
100
|
|
|
1 |
|
101
|
1 |
|
); |
|
102
|
|
|
|
|
103
|
1 |
|
return AdobeCampaignXmlLoader::loadXml($response); |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|