6. What is SOAP webservice
6
request response
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" >
<soap:Body>
<GetWeather xmlns="http://www.webserviceX.NET">
<CityName>gdansk</CityName>
<CountryName>poland</CountryName>
</GetWeather>
</soap:Body>
</soap:Envelope>
<soap:Envelope ...>
<CurrentWeather>
<Location>Gdansk-Rebiechowo, Poland (EPGD)
54-23N 018-28E 138M</Location>
<Time>Jun 08, 2015 - 06:00 AM EDT</Time>
<Wind>from the NW</Wind>
<Visibility>greater than 7 mile(s):0</Visibility>
<SkyConditions>partly cloudy</SkyConditions>
<Temperature>60 F (16 C)</Temperature>
<RelativeHumidity>51%</RelativeHumidity>
<Pressure>30.30 in. Hg (1026 hPa)</Pressure>
<Status>Success</Status>
</CurrentWeather>
p
a
y
l
o
a
d
7. Manual approach – when is sufficient
Valid payloads provided
One time test
The same version of contract
Artifacts (WSDL or client stub classes) not available
8
8. Manual approach – live scenarios
Requests with frequently changes data e.g. Date
Test flow requires dependent webservise calls
Big responses like 5MB to validate
9TESTING WEB SERVICES (SOAP) - PIOTR BOHO
9. Manual approach - tests maintanance
problem
Application under development changes !
Refactoring:
◦ Namespaces
◦ Tag names
Functional change:
◦ Move element
◦ Add element
◦ change schema constraint :
optional/required, order of elements, number of elements, change type or pattern
10TESTING WEB SERVICES (SOAP) - PIOTR BOHO
10. Programming approaches
1.Xml as text – string builders, parametrization, parsers
regex,
2.Xml as DOM – DOM builders and xPath etc
3.Xml as serialized object – OOP and JAXB
11
11. Payload as serialized object
Request validation using schema from WSDL
Get rid of XML as text – lets use OOP
◦ Early and strict change detection - Compiler
Preparing client stub:
◦ java org.apache.axis.wsdl.WSDL2Java
◦ wsimport from JDK
◦ Maven cxf-codegen-plugin
13