I am trying to automate a soap request in robot tool I have tried various combinations but in vain. Below is the request that I am trying to automate. I have saved the same in an XML file for calling in the test case. Could someone help me with how to read a soap request and send the content to the endpoint?
SOAP Request:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns="http://www.example.com/XMLHeader/10"
xmlns:req="http://www.example.com/cream1/cream11I/deleteemailAddress/xyz/Req">
<soapenv:Header>
<ns:vendortool>
<ns:HeaderVersion>11</ns:HeaderVersion>
<ns:MessageId>1234556667</ns:MessageId>
<ns:ServiceRequestorDomain>ABCCCC</ns:ServiceRequestorDomain>
<ns:ServiceRequestorId>health</ns:ServiceRequestorId>
<ns:ServiceProviderDomain>zxcvvbb</ns:ServiceProviderDomain>
<ns:ServiceId>deleteemail</ns:ServiceId>
<ns:ServiceVersion>000</ns:ServiceVersion>
<ns:FaultIndication>True</ns:FaultIndication>
<ns:MessageTimestamp>2020-03-27T11:12:49.418</ns:MessageTimestamp>
</ns:vendortool>
</soapenv:Header>
<soapenv:Body>
<req:deleteemailAddress_Req>
<req:EmailAddress>[email protected]</req:EmailAddress>
</req:deleteemailAddress_Req>
</soapenv:Body>
</soapenv:Envelope>
Test Case (I have tried)
create session deleteemail ${base_url} disable_warnings=1
#Create Request Headers
&{request_header}= create dictionary Content-Type=text/xml; charset=utf-8 User-Agent=Apache-
HttpClient/4.1.1
${Test_Response}= post request deleteemail ${channel_url} ${CURDIR}/deleteemail.xml
headers=${request_header}
* Settings *
Library RequestsLibrary
Library Collections
Library SeleniumLibrary
Library String
Library SoapLibrary
Library OperatingSystem
Library XML
* Variables *
${base_url}= https://example.com
${channel_url}= /cream11/cream11/deleteemailaddress
* Test Cases *
TC_000000_DELETE_EMAIL_ADDRESS
create session deleteemail ${base_url} disable_warnings=1
#Create a dynamic messageId
${rand_MessageID}= generate random string 5 [NUMBERS]
#Set a request variable
${SOAP_XML}= set variable <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.example.com/XMLHeader/10" xmlns:req=" http://www.example.com/cream1/cream11I/deleteemailAddress/xyz/Req"> <soapenv:Header> <ns:vendortool> <ns:HeaderVersion>11</ns:HeaderVersion> <ns:MessageId>${rand_MessageID}</ns:MessageId> <ns:ServiceRequestorDomain>ABCCCC</ns:ServiceRequestorDomain> <ns:ServiceRequestorId>health</ns:ServiceRequestorId> <ns:ServiceProviderDomain>zxcvvbb</ns:ServiceProviderDomain> <ns:ServiceId>deleteemail</ns:ServiceId> <ns:ServiceVersion>000</ns:ServiceVersion> <ns:FaultIndication>True</ns:FaultIndication> <ns:MessageTimestamp>2020-03-27T11:12:49.418</ns:MessageTimestamp> </ns:vendortool> </soapenv:Header> <soapenv:Body> <req:deleteemailAddress_Req> <req:EmailAddress>[email protected]</req:EmailAddress> </req:deleteemailAddress_Req> </soapenv:Body> </soapenv:Envelope>
#Create Request Headers
${request_header}= create dictionary Content-Type=text/xml; charset=utf-8 User-Agent=Apache-HttpClient/4.1.1
#Send the XML request body
${SAVE_Response}= Post Request deleteemail ${channel_url} headers=${request_header} data=${SOAP_XML}
#Log Response and Status Code Details
log to console ${SAVE_Response.status_code}
log ${SAVE_Response.headers}
log ${SAVE_Response.content}
log ${SOAP_XML}