@@ -6,18 +6,129 @@ This package provides some tools on top of [veewee/xml](https://github.com/veewe
6
6
7
7
### SoapHeaders
8
8
9
+ Makes it possible to build the content of a ` soap:Header ` element.
10
+
11
+ ``` php
12
+ use Soap\Xml\Builder\SoapHeaders;
13
+ use Soap\Xml\Manipulator\PrependSoapHeaders;use VeeWee\Xml\Dom\Document;
14
+ use function VeeWee\Xml\Dom\Builder\children;
15
+ use function VeeWee\Xml\Dom\Builder\element;
16
+ use function VeeWee\Xml\Dom\Builder\value;
17
+
18
+ $doc = Document::fromXmlString($xml);
19
+ $builder = new SoapHeaders(
20
+ children(
21
+ element('user', value('josbos')),
22
+ element('password', value('topsecret'))
23
+ )
24
+ );
25
+
26
+ $header = $doc->build($builder)[0];
27
+
28
+ // You can prepend the soap:Header as first element of the soap:envelope
29
+ // Like this
30
+ $doc->manipulate(new PrependSoapHeaders($header));
31
+ ```
32
+
9
33
## Locator
10
34
11
35
### BodyNamespaceLocator
36
+
37
+ Locates the namespace of the first element inside the soap: Body .
38
+
39
+ ``` php
40
+ use Soap\Xml\Locator\BodyNamespaceLocator;
41
+ use VeeWee\Xml\Dom\Document;
42
+
43
+ $doc = Document::fromXmlString($xml);
44
+ $bodyNamespace = $doc->locate(new BodyNamespaceLocator());
45
+ ```
46
+
12
47
### SoapBodyLocator
48
+
49
+ Locates the ` soap:Body ` element inside a ` soap:Envelope `
50
+
51
+ ``` php
52
+ use Soap\Xml\Locator\SoapBodyLocator;
53
+ use VeeWee\Xml\Dom\Document;
54
+
55
+ $doc = Document::fromXmlString($xml);
56
+ $bodyElement = $doc->locate(new SoapBodyLocator());
57
+ ```
58
+
59
+
13
60
### SoapEnvelopeLocator
61
+
62
+ Locates the ` soap:Envelope ` inside XML.
63
+
64
+ ``` php
65
+ use Soap\Xml\Locator\SoapEnvelopeLocator;
66
+ use VeeWee\Xml\Dom\Document;
67
+
68
+ $doc = Document::fromXmlString($xml);
69
+ $bodyElement = $doc->locate(new SoapEnvelopeLocator());
70
+ ```
71
+
14
72
### SoapHeaderLocator
15
73
74
+ Locates the ` soap:Header ` element inside a ` soap:Envelope `
75
+
76
+ ``` php
77
+ use Soap\Xml\Locator\SoapHeaderLocator;
78
+ use VeeWee\Xml\Dom\Document;
79
+
80
+ $doc = Document::fromXmlString($xml);
81
+ $bodyElement = $doc->locate(new SoapHeaderLocator());
82
+ ```
83
+
16
84
## Manipulator
17
85
18
86
### PrependSoapHeaders
19
87
88
+ See SoapHeaders builder:
89
+
90
+ ``` php
91
+ $doc = Document::fromXmlString($xml);
92
+ $doc->manipulate(new PrependSoapHeaders($soapHeader));
93
+ ```
94
+
20
95
## XPath
21
96
22
97
### EnvelopePreset
98
+
99
+ This preset allows you to use following xpath prefixes:
100
+
101
+ - ` application ` : The namespace of the SOAP implementation.
102
+ - ` soap ` : The soap prefix allows you to fetch common elements like Body, header, Envelope, ...
103
+
104
+ ``` php
105
+ use Soap\Xml\Xpath\EnvelopePreset;
106
+ use VeeWee\Xml\Dom\Document;
107
+
108
+ $doc = Document::fromXmlString($xml);
109
+ $xpath = $doc->xpath(new EnvelopePreset($doc));
110
+
111
+ $xpath->querySingle('/soap:Envelope');
112
+ $xpath->querySingle('//soap:Body');
113
+ $xpath->querySingle('//soap:Header');
114
+ $xpath->querySingle('//soap:Body//application:Foo');
115
+ ```
116
+
117
+
23
118
### WsdlPreset
119
+
120
+ This preset allows you to use following xpath prefixes:
121
+
122
+ - ` wsdl ` : The wsdl prefix allows you to fetch common elements like definitions, types, services, operations, ...
123
+
124
+ ``` php
125
+ use Soap\Xml\Xpath\WsdlPreset;
126
+ use VeeWee\Xml\Dom\Document;
127
+
128
+ $doc = Document::fromXmlString($xml);
129
+ $xpath = $doc->xpath(new WsdlPreset($doc));
130
+
131
+ $xpath->querySingle('/wsdl:definitions');
132
+ $xpath->querySingle('//wsdl:types');
133
+ $xpath->querySingle('//wsdl:services');
134
+ ```
0 commit comments