如何在机器人框架工具中发送SOAP请求?

问题描述 投票:0回答:1

我试图在机器人工具中自动发送一个SOAP请求,我已经尝试了各种组合,但徒劳无功。以下是我试图自动发送的请求。我已将其保存在XML文件中,以便在测试用例中调用.有人能帮助我如何读取soap请求并将内容发送到端点吗?

SOAP请求。

<?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>

测试用例(我已经试过了

   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}
soap automation automated-tests robotframework
1个回答
0
投票

* 设置

Library  RequestsLibrary
Library  Collections
Library  SeleniumLibrary
Library  String
Library  SoapLibrary
Library  OperatingSystem
Library  XML

* 变量 *

${base_url}=  https://example.com
${channel_url}=  /cream11/cream11/deleteemailaddress

* 测试案例 *

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}
© www.soinside.com 2019 - 2024. All rights reserved.