Package com.privalia.qa.utils
Class SoapServiceUtils
- java.lang.Object
-
- com.privalia.qa.utils.SoapServiceUtils
-
public class SoapServiceUtils extends Object
Class to execute methods on any remote WebService. Verify the test class SoapServiceUtilsTest for instructions on how to use it- Author:
- José Fernández
-
-
Constructor Summary
Constructors Constructor Description SoapServiceUtils()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
evaluateXml(String xmlString, String variable)
Given an String representing an XML object, returns the value of the given variableString
executeMethod(String ActionName, String request)
Executes the given method in the remote webserviceString
executeMethodWithParams(String ActionName, String request, Map<String,String> variables)
Alter the given XML request with the given values in the Map before executing the given methodMap<String,String>
getAvailableSoapActions()
Returns a Map with all the posible SOAP operations for the the first service found in the WSDL fileString
getPortName()
Returns the Port name for the first service found in the WSDL fileString
getServiceName()
Returns name of the first service found in the WSDL descriptionString
getTargetNameSpace()
Returns Target NamespaceString
getWsdlAddress()
Gets the address of the remote wsdlvoid
parseWsdl(String url)
Parses the remote WSDL file and store its variables internally for easier accessString
transformXml(String request, Map<String,String> variables)
Alter the given XML request with the given values in the Map
-
-
-
Method Detail
-
getPortName
public String getPortName()
Returns the Port name for the first service found in the WSDL file- Returns:
- port name
-
getWsdlAddress
public String getWsdlAddress()
Gets the address of the remote wsdl- Returns:
- wsdl address
-
getServiceName
public String getServiceName()
Returns name of the first service found in the WSDL description- Returns:
- service name
-
getTargetNameSpace
public String getTargetNameSpace()
Returns Target Namespace- Returns:
- target name space
-
parseWsdl
public void parseWsdl(String url)
Parses the remote WSDL file and store its variables internally for easier access- Parameters:
url
- Remote WSDL address
-
getAvailableSoapActions
public Map<String,String> getAvailableSoapActions()
Returns a Map with all the posible SOAP operations for the the first service found in the WSDL file- Returns:
- Map containing action name/corresponding soap action
-
transformXml
public String transformXml(String request, Map<String,String> variables) throws IOException, SAXException, ParserConfigurationException, TransformerException
Alter the given XML request with the given values in the Map- Parameters:
request
- Request in XML formatvariables
- Map describing the list of variables and the corresponding value- Returns:
- XML String with the changes
- Throws:
IOException
- IOExceptionSAXException
- SAXExceptionParserConfigurationException
- ParserConfigurationExceptionTransformerException
- TransformerException
-
evaluateXml
public String evaluateXml(String xmlString, String variable) throws ParserConfigurationException, IOException, SAXException
Given an String representing an XML object, returns the value of the given variable- Parameters:
xmlString
- XML Stringvariable
- Variable to look for in the body- Returns:
- The value of the variable, or null if not found
- Throws:
ParserConfigurationException
- ParserConfigurationExceptionIOException
- IOExceptionSAXException
- SAXException
-
executeMethodWithParams
public String executeMethodWithParams(String ActionName, String request, Map<String,String> variables) throws Exception
Alter the given XML request with the given values in the Map before executing the given method- Parameters:
ActionName
- Action name. This name with be mapped to the corresponding SOAPActionrequest
- XML message to send as stringvariables
- Map describing the list of variables and the corresponding value- Returns:
- a
SOAPMessage
object - Throws:
Exception
- the exception
-
executeMethod
public String executeMethod(String ActionName, String request) throws Exception
Executes the given method in the remote webservice- Parameters:
ActionName
- Action name. This name with be mapped to the corresponding SOAPActionrequest
- XML message to send as string- Returns:
- a
SOAPMessage
object - Throws:
Exception
- the exception
-
-