3
3
4
4
# WSDL Reader
5
5
6
- This package provides tools for reading WSDL files and to converting them to usable metadata.
6
+ This package provides tools for reading WSDL files and to converting them to metadata that will be used in other parts of the php-soap packages .
7
7
8
8
# Want to help out? 💚
9
9
@@ -17,11 +17,11 @@ Want more information about the future of this project? Check out this list of t
17
17
# Installation
18
18
19
19
``` bash
20
- composer config repositories.wsdlreader git https://github.com/php-soap/wsdl.git
21
- composer require php-soap/wsdl-reader
20
+ composer config repositories.wsdlreader git https://github.com/php-soap/wsdl-reader .git
21
+ composer require php-soap/wsdl-reader@dev-master
22
22
```
23
23
24
- ## Usage
24
+ ## Example usage
25
25
26
26
``` php
27
27
use Soap\Engine\Metadata\Model\Method;
@@ -34,7 +34,8 @@ use Soap\WsdlReader\Metadata\Wsdl1MetadataProvider;
34
34
use Soap\WsdlReader\Wsdl1Reader;
35
35
36
36
echo "Reading WSDL $wsdlLocation".PHP_EOL;
37
- $wsdl = (new Wsdl1Reader(new FlatteningLoader(new StreamWrapperLoader())))($wsdlLocation);
37
+ $loader = new FlatteningLoader(new StreamWrapperLoader());
38
+ $wsdl = (new Wsdl1Reader($loader))($wsdlLocation);
38
39
39
40
echo "Parsing metadata".PHP_EOL;
40
41
$metadataProvider = new Wsdl1MetadataProvider($wsdl);
@@ -50,3 +51,97 @@ echo implode(PHP_EOL, $metadata->getTypes()->map(fn (Type $type) => ' > '.(new
50
51
echo PHP_EOL.PHP_EOL;
51
52
```
52
53
54
+ As shown above, parsing the WSDL is done in phases:
55
+
56
+ * Loading
57
+ * Reading raw WSDL XML into value objects
58
+ * Converting this WSDL to usable metadata
59
+
60
+ This gives you the flexibility in all different layers:
61
+
62
+ * You can specify how a WSDL will be loaded.
63
+ * You can use the WSDL classes of this package to run your own data lookups/manipulations.
64
+ * You can use the provided metadata to run your own data lookups/manipulations.
65
+ * ...
66
+
67
+
68
+ ## Readers
69
+
70
+ This package provides some configurable WSDL readers.
71
+ This gives you some flexibility in what version of WSDL is being parsed, what SOAP version you want to use, ...
72
+
73
+ ### WSDL1 and 1.1
74
+
75
+ ``` php
76
+ use Soap\WsdlReader\Metadata\Wsdl1MetadataProvider;
77
+ use Soap\WsdlReader\Model\Definitions\SoapVersion;
78
+ use Soap\WsdlReader\Wsdl1Reader;
79
+
80
+ $wsdl = (new Wsdl1Reader($loader))($wsdlLocation);
81
+ $metadataProvider = new Wsdl1MetadataProvider($wsdl, SoapVersion::SOAP_12);
82
+ ```
83
+
84
+ This will read the WSDL1 file and parse the SOAP 1.2 information into metadata.
85
+ If no SOAP version is specified, it will automatically detect the first SOAP version it encounters.
86
+
87
+ ### WSDL2
88
+
89
+ Not implemented yet!
90
+
91
+ ## Console
92
+
93
+ This package provides some console commands that can be used to debug what is inside your WSDL.
94
+
95
+ ``` shell
96
+ $ ./bin/wsdl-reader
97
+
98
+ Available commands:
99
+ completion Dump the shell completion script
100
+ help Display help for a command
101
+ list List commands
102
+ inspect
103
+ inspect Inspects WSDL file.
104
+ inspect:method Inspects a method of a WSDL file.
105
+ inspect:types Inspects types from WSDL file.
106
+ ```
107
+
108
+ ### Listing all contents
109
+
110
+ ``` shell
111
+ ./bin/wsdl-reader inspect your.wsdl
112
+ ```
113
+
114
+ ### Method details
115
+
116
+ ``` shell
117
+ ./bin/wsdl-reader inspect:method your.wsdl SomeMethodName
118
+ ```
119
+
120
+ ### Type details
121
+
122
+ ``` shell
123
+ ./bin/wsdl-reader inspect:type your.wsdl SomeType
124
+ ```
125
+
126
+ ### Custom WSDL Loader
127
+ By default, all CLI tools use the StreamWrapperLoader.
128
+ All CLI tools have a ` --loader=file.php ` option that can be used to apply a custom WSDL loader.
129
+ This can be handy if your WSDL is located behind authentication or if you want to get control over the HTTP level.
130
+
131
+ Example custom PHP loader:
132
+
133
+ ``` php
134
+ <?php
135
+
136
+ use Soap\Wsdl\Loader\StreamWrapperLoader;
137
+
138
+ return new StreamWrapperLoader(
139
+ stream_context_create([
140
+ 'http' => [
141
+ 'method' => 'GET',
142
+ 'header'=> sprintf('Authorization: Basic %s', base64_encode('username:password')),
143
+ ],
144
+ ])
145
+ );
146
+ ```
147
+
0 commit comments