Professional Documents
Culture Documents
For the next steps we assume the web service we want to test is deployed and the
external services are not.
This article extends the basic example described in "Web service testing with so
apUI". It describes how to test and simulate exceptions.
Imagine we want to know the price of a trip from Berlin to Paris. But instead of
typing "Berlin", we enter "Beriln". The FlightPriceService does not know any lo
cation named "Beriln" and throws an exception. In this case, we expect the TripP
riceService to catch this exception and throw his own exception. That is what we
are going to test.
1. Add a test case
Right click on the test suite and select "New TestCase"
Specify a name for the test case, for example "LocationNotFoundException TestCas
e"
Click "OK"
Set a timeout for the test case
2. Add a test request
Right click in the test case editor and select "Append Step" -> "Test Request"
Specify a name for the test request, for example "getTripPrice Test Request"
Click "OK"
Select the operation to invoke for the request "TripPriceServiceFacadeServiceSoa
pBinding -> getTripPrice"
Click "OK"
Select "Add SOAP Response Assertion", "Add Schema Assertion" and "Create optiona
l elements"
Make sure "Add not SOAP Fault Assertion" is not selected, because the exception
we expect is a SOAP fault
Click "OK"
Edit the request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmln
s:trip="http://trip.price.service">
<soapenv:Header/>
<soapenv:Body>
<trip:getTripPrice>
<trip>
<adults>2</adults>
<duration>3</duration>
<from>Beriln</from>
<rooms>1</rooms>
<to>Paris</to>
</trip>
</trip:getTripPrice>
</soapenv:Body>
</soapenv:Envelope>
Add a "SOAP Fault" assertion
Add a "XPath Match" assertion, to check the faultstring
XPath Expression
declare namespace soap='http://schemas.xmlsoap.org/soap/envelope/';
declare namespace ns1='http://trip.price.service';
//soap:Fault/faultstring
Expected Result
Location Beriln not found