Skip to content

Commit

Permalink
docs(soap): improves scripted examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
outofcoffee authored Oct 26, 2024
1 parent e553dc1 commit ae29129
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions docs/soap_plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,35 +285,35 @@ response:

Now, `example.groovy` can control the responses, such as:

1. **the content of a file to return**

```groovy
respond().withFile('some-file.xml')
```

2. **a literal string to return**

```groovy
respond().withContent('''<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
<env:Header/>
<env:Body>
<getPetByIdResponse xmlns="urn:com:example:petstore">
<id>3</id>
<name>Custom pet name</name>
</getPetByIdResponse>
</env:Body>
</env:Envelope>
''')
```

3. **a specific HTTP status code**

Setting the status code to 500 will trigger a fault message to be returned if one is defined within the WSDL document.
```groovy
respond().withStatusCode(500)
```
#### Return the content of a file

```groovy
respond().withFile('some-file.xml')
```

#### Return a literal string

```groovy
respond().withContent('''<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
<env:Header/>
<env:Body>
<getPetByIdResponse xmlns="urn:com:example:petstore">
<id>3</id>
<name>Custom pet name</name>
</getPetByIdResponse>
</env:Body>
</env:Envelope>
''')
```

#### Return a specific HTTP status code

Setting the status code to 500 will trigger a fault message to be returned if one is defined within the WSDL document.

```groovy
respond().withStatusCode(500)
```

#### Scripting examples

Expand Down

0 comments on commit ae29129

Please sign in to comment.