Skip to content

Commit 521f3a3

Browse files
committed
Update docs
1 parent 77140ad commit 521f3a3

File tree

2 files changed

+101
-6
lines changed

2 files changed

+101
-6
lines changed

README.md

+100-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# WSDL Reader
55

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.
77

88
# Want to help out? 💚
99

@@ -17,11 +17,11 @@ Want more information about the future of this project? Check out this list of t
1717
# Installation
1818

1919
```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
2222
```
2323

24-
## Usage
24+
## Example usage
2525

2626
```php
2727
use Soap\Engine\Metadata\Model\Method;
@@ -34,7 +34,8 @@ use Soap\WsdlReader\Metadata\Wsdl1MetadataProvider;
3434
use Soap\WsdlReader\Wsdl1Reader;
3535

3636
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);
3839

3940
echo "Parsing metadata".PHP_EOL;
4041
$metadataProvider = new Wsdl1MetadataProvider($wsdl);
@@ -50,3 +51,97 @@ echo implode(PHP_EOL, $metadata->getTypes()->map(fn (Type $type) => ' > '.(new
5051
echo PHP_EOL.PHP_EOL;
5152
```
5253

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+

src/Console/Command/InspectTypeCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class InspectTypeCommand extends Command
2020
{
2121
public static function getDefaultName(): string
2222
{
23-
return 'inspect:types';
23+
return 'inspect:type';
2424
}
2525

2626
/**

0 commit comments

Comments
 (0)