Skip to content

Commit 22496b1

Browse files
committed
docs: new documentation
1 parent 29e55b3 commit 22496b1

File tree

17 files changed

+10940
-2
lines changed

17 files changed

+10940
-2
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ phpunit.xml
1111
phpstan.neon
1212
testbench.yaml
1313
vendor
14-
node_modules
1514
.php-cs-fixer.cache
1615
ray.php
16+
/docs/v3/node_modules/

docs/v2/client/authentication.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Authentication
2+
3+
You may specify basic authentication credentials using the `withBasicAuth` method, respectively:
4+
5+
// Basic authentication...
6+
$response = Soap::baseWsdl('http://test.com'/v1?wsdl)->withBasicAuth('[email protected]', 'secret')->call(...);
7+
8+
#### Web Service Security (WSS / WSSE)
9+
10+
Internally it is using the [wse-php package of robrichards](https://github.com/robrichards/wse-php) which is a well known library that is used by many developers.
11+
It also supports not secured Wsse but with token:
12+
13+
//Not secure
14+
$response = Soap::baseWsdl('http://test.com'/v1?wsdl)->withWsse([
15+
'userTokenName' => 'username',
16+
'userTokenPassword' => 'password',
17+
])->call(...);
18+
//Secure
19+
$response = Soap::baseWsdl('http://test.com'/v1?wsdl)->withWsse([
20+
'privateKeyFile' => 'path/to/privatekey.pem',
21+
'publicKeyFile' => 'path/to/publickey.pyb',
22+
])->call(...);
23+
24+
You have following Wsse Options:
25+
26+
'userTokenName' : string
27+
'userTokenPassword' : string
28+
'privateKeyFile' : string
29+
'publicKeyFile' : string
30+
'serverCertificateFile' : string
31+
'serverCertificateHasSubjectKeyIdentifier' : boolean
32+
'userTokenDigest' : boolean
33+
'digitalSignMethod' : string
34+
'timestamp' : integer
35+
'signAllHeaders' => : boolean
36+
37+
#### Web Service Addressing (WSA)
38+
39+
Like Wss/Wsse it uses the same package:
40+
41+
$response = Soap::baseWsdl(...)
42+
->withWsa()
43+
->call(...)
44+
45+
### DHL Cis Authentication
46+
47+
DHL uses his own authentication header
48+
49+
$client = Soap::withCisDHLAuth('user', 'signature')
File renamed without changes.
File renamed without changes.

docs/v2/client/response.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Response
2+
3+
## Object
4+
5+
The `call` method returns an instance of `CodeDredd\Soap\Client\Response`, which provides a variety of methods that may be used to inspect the response:
6+
7+
$response->body() : string;
8+
$response->json() : array;
9+
$response->status() : int;
10+
$response->ok() : bool;
11+
$response->successful() : bool;
12+
$response->serverError() : bool;
13+
$response->clientError() : bool;
14+
$response->onError(callable $callback): \CodeDredd\Soap\Client\Response;
15+
$response->collect(): \Illuminate\Support\Collection;
16+
17+
The `CodeDredd\Soap\Client\Response` object also implements the PHP `ArrayAccess` interface, allowing you to access your response data directly on the response:
18+
19+
return Soap::baseWsdl('http://test.com'/v1?wsdl)->call('Get_Users')['name'];
20+
21+
## Error Handling
22+
23+
Unlike Guzzle's default behavior, this SOAP client wrapper does not throw exceptions on client or server errors (`400` and `500` level responses from servers). You may determine if one of these errors was returned using the `successful`, `clientError`, or `serverError` methods:
24+
25+
// Determine if the status code was >= 200 and < 300...
26+
$response->successful();
27+
28+
// Determine if the response has a 400 level status code...
29+
$response->clientError();
30+
31+
// Determine if the response has a 500 level status code...
32+
$response->serverError();
33+
34+
### Throwing Exceptions
35+
36+
If you have a response instance and would like to throw an instance of `CodeDredd\Soap\Exceptions\RequestException` if the response is a client or server error, you may use the `throw` method:
37+
38+
$response = Soap::baseWsdl(...)->call(...);
39+
40+
// Throw an exception if a client or server error occurred...
41+
$response->throw();
42+
43+
return $response['user']['id'];
44+
45+
The `CodeDredd\Soap\Exceptions\RequestException` instance has a public `$response` property which will allow you to inspect the returned response.
46+
47+
The `throw` method returns the response instance if no error occurred, allowing you to chain other operations onto the `throw` method:
48+
49+
return Soap::baseWsdl(...)
50+
->call(...)
51+
->throw()
52+
->json();
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)