-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55c6f5a
commit e43468e
Showing
3 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Return a SOAP fault | ||
|
||
This example returns a SOAP fault for a particular operation. | ||
|
||
Start mock server: | ||
|
||
```bash | ||
imposter up | ||
``` | ||
|
||
Send request: | ||
|
||
```bash | ||
curl --data '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> | ||
<env:Header/> | ||
<env:Body> | ||
<getPetByIdRequest xmlns="urn:com:example:petstore"> | ||
<id>10</id> | ||
</getPetByIdRequest> | ||
</env:Body> | ||
</env:Envelope>' http://localhost:8080/pets/ | ||
``` | ||
|
||
Response: | ||
|
||
```xml | ||
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> | ||
<env:Header/> | ||
<env:Body> | ||
<urn:getPetFault xmlns:urn="urn:com:example:petstore"> | ||
<code>3</code> | ||
<description>string</description> | ||
</urn:getPetFault> | ||
</env:Body> | ||
</env:Envelope> | ||
``` | ||
|
||
## Notes | ||
|
||
This example can be extended to use conditional matching with resources to only return a fault under specific conditions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
plugin: soap | ||
wsdlFile: service.wsdl | ||
|
||
resources: | ||
- binding: SoapBinding | ||
operation: getPetById | ||
response: | ||
statusCode: 500 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<definitions name="PetService" xmlns="http://schemas.xmlsoap.org/wsdl/" | ||
xmlns:tns="urn:com:example:petstore" | ||
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" | ||
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" | ||
targetNamespace="urn:com:example:petstore"> | ||
|
||
<documentation> | ||
A pet store service with a single operation and SOAP binding. | ||
</documentation> | ||
|
||
<types> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
xmlns="urn:com:example:petstore" | ||
targetNamespace="urn:com:example:petstore"> | ||
|
||
<xs:complexType name="petType"> | ||
<xs:all> | ||
<xs:element name="id" type="xs:int"/> | ||
<xs:element name="name" type="xs:string"/> | ||
</xs:all> | ||
</xs:complexType> | ||
|
||
<xs:complexType name="getPetByIdRequest"> | ||
<xs:all> | ||
<xs:element name="id" type="xs:int"/> | ||
</xs:all> | ||
</xs:complexType> | ||
|
||
<xs:complexType name="fault"> | ||
<xs:all> | ||
<xs:element name="code" type="xs:int" /> | ||
<xs:element name="description" type="xs:string" /> | ||
</xs:all> | ||
</xs:complexType> | ||
|
||
<xs:element name="getPetByIdRequest" type="getPetByIdRequest"/> | ||
<xs:element name="getPetByIdResponse" type="petType"/> | ||
<xs:element name="getPetFault" type="fault"/> | ||
</xs:schema> | ||
</types> | ||
|
||
<message name="getPetByIdRequest"> | ||
<part element="tns:getPetByIdRequest" name="parameters"/> | ||
</message> | ||
<message name="getPetByIdResponse"> | ||
<part element="tns:getPetByIdResponse" name="parameters"/> | ||
</message> | ||
<message name="getPetFault"> | ||
<part element="tns:getPetFault" name="parameters"/> | ||
</message> | ||
|
||
<portType name="PetPortType"> | ||
<operation name="getPetById"> | ||
<input message="tns:getPetByIdRequest" name="getPetByIdRequest"/> | ||
<output message="tns:getPetByIdResponse" name="getPetByIdResponse"/> | ||
<fault message="tns:getPetFault" name="getPetFault" /> | ||
</operation> | ||
</portType> | ||
|
||
<binding name="SoapBinding" type="tns:PetPortType"> | ||
<soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/soap"/> | ||
|
||
<operation name="getPetById"> | ||
<soap12:operation soapAction="getPetById" style="document"/> | ||
<input name="getPetByIdRequest"> | ||
<soap12:body use="literal"/> | ||
</input> | ||
<output name="getPetByIdResponse"> | ||
<soap12:body use="literal"/> | ||
</output> | ||
<fault name="getPetFault"> | ||
<soap12:body use="literal"/> | ||
</fault> | ||
</operation> | ||
</binding> | ||
|
||
<service name="PetService"> | ||
<port name="SoapEndpoint" binding="tns:SoapBinding"> | ||
<soap12:address location="http://www.example.com/pets/"/> | ||
</port> | ||
</service> | ||
</definitions> |