Class SoapServiceGSpec
- java.lang.Object
-
- com.privalia.qa.specs.BaseGSpec
-
- com.privalia.qa.specs.SoapServiceGSpec
-
public class SoapServiceGSpec extends BaseGSpec
Steps definitions for working with SOAP web services- Author:
- Jose Fernandez
-
-
Field Summary
-
Fields inherited from class com.privalia.qa.specs.BaseGSpec
commonspec
-
-
Constructor Summary
Constructors Constructor Description SoapServiceGSpec(CommonG spec)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
evaluateWebserviceResponse(io.cucumber.datatable.DataTable results)
Verifies response of webservice.void
executeWebserviceMethod(String actionName, String requestFile, String foo, io.cucumber.datatable.DataTable modifications)
Executes remote webservice method with parametersvoid
setRemoteWSDL(String remoteWsdlAddress)
Set URL of remote WSDL-
Methods inherited from class com.privalia.qa.specs.BaseGSpec
getCommonSpec
-
-
-
-
Constructor Detail
-
SoapServiceGSpec
public SoapServiceGSpec(CommonG spec)
-
-
Method Detail
-
setRemoteWSDL
@Given("^The webservice WSDL is located in \'(.+?)\'$") public void setRemoteWSDL(String remoteWsdlAddress) throws Throwable
Set URL of remote WSDLThis step parses the remote WSDL (web service description language) webservice descriptor and obtains the basic parameters to execute future requests (like targetNamespace, Service name, methods available, etc). This is a initialization steps and must be used before trying to execute any remote method
Example: consider the webservice running at http://www.dneonline.com/calculator.asmx, with a WSDL located at http://www.dneonline.com/calculator.asmx?WSDL. The first step before executing any other webservice related step should be:
Given The webservice WSDL is located in 'http://www.dneonline.com/calculator.asmx?WSDL'
- Parameters:
remoteWsdlAddress
- Remote URL of the WSDL document- Throws:
Throwable
- Throwable
-
executeWebserviceMethod
@When("^I execute the method \'(.+?)\' based on \'([^:]+?)\'( with:)?$") public void executeWebserviceMethod(String actionName, String requestFile, String foo, io.cucumber.datatable.DataTable modifications) throws Throwable
Executes remote webservice method with parametersExecutes the remote method in the webservice. A request body must be provided for this operation. There is also the possibility of altering values of the request body before sending providing a datatable. Since the library is capable of using any webservice, it does not know in advance the format of the XML messages that are interchanged between the server and the clients. This is why is necessary to provide the XML request that should be sent when executing a particular method.
Following the example of the webservice located at http://www.dneonline.com/calculator.asmx, the webservice exposes 4 methods: Add, Divide, Multiply and Subtract. To execute the "Add" method, the following XML message should be sent to the server:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <Add xmlns="http://tempuri.org/"> <intA>int</intA> <intB>int</intB> </Add> </soap:Body> </soap:Envelope>
This request XML message format should be stored in a separate file (for this example, lets save it to schemas/AddRequest.xml) To execute the "Add" method with intA = 1 and intB = 1:
Given The webservice WSDL is located in 'http://www.dneonline.com/calculator.asmx?WSDL' When I execute the method 'Add' based on 'schemas/AddRequest.xml' with: | intA | 1 | | intB | 1 |
When I execute the method 'Add' based on 'schemas/AddRequest.xml'
- Parameters:
actionName
- Remote method to execute. The method name will be translated to the corresponding SOAPActionrequestFile
- File containing the request (XML)foo
- parameter generated by cucumber because of the optional expressionmodifications
- (Optional) a datatable with modifications to perform on the request before sending Example: Assuming the request XML body contains the following tags:<intA>int<intA/> <intB>int<intB/>
To alter the value of intA and intB, a datatable like the following should be provided:| intA | 1 | | intB | 1 |
And the corresponding values for the given tags in the body will be<intA>1<intA/> <intB>1<intB/>
- Throws:
Throwable
- Throwable- See Also:
setRemoteWSDL(String)
-
evaluateWebserviceResponse
@Then("^The response matches the following cases:$") public void evaluateWebserviceResponse(io.cucumber.datatable.DataTable results) throws Throwable
Verifies response of webservice.Evaluates the response of the remote webservice against a set of conditions provided by a datatable. Following the previous example, the XML response for the "Add" have the format below:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <AddResponse xmlns="http://tempuri.org/"> <AddResult>int</AddResult> </AddResponse> </soap:Body> </soap:Envelope>
Scenario: Execute "Add" operation Given The webservice WSDL is located in 'http://www.dneonline.com/calculator.asmx?WSDL' When I execute the method 'Add' based on 'schemas/AddRequest.xml' with: | intA | 1 | | intB | 1 | Then The response matches the following cases: | AddResult | equal | 2 |
- Parameters:
results
- Expected results in a datatable Example: Assuming the response from the webservice (XML response), contains the following XML tag:<AddResult>2<AddResult/>
To verify that AddResult tag equals "2", a datatable like the following should be provided: | AddResult | equal | 2 | Suported operations: - equal - not equal - contains - does not contain - length- Throws:
Throwable
- Throwable- See Also:
setRemoteWSDL(String)
,executeWebserviceMethod(String, String, String, DataTable)
-
-