解析xml soap响应时,邮递员测试失败

时间:2019-06-11 23:50:54

标签: soap postman

我正在使用POSTMAN发送SOAP请求,下面是我收到的soapenv响应。我想测试邮递员测试中收到的以下值,但是邮递员测试失败,有人可以建议在这里做什么?

LicStatus

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:schemas.general.com.au:api:other">
    <soapenv:Header xmlns:urn="urn:schemas.general.com.au:api:other" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
        <header xmlns:urn="urn:schemas.general.com.au:api:other" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas.cordys.com/General/1.0/">
            <msg-id>005056B9-3921-A1E9-A327-64509F7362DC</msg-id>
            <messageoptions noreply="true"/>
        </header>
    </soapenv:Header>
    <soapenv:Body>
        <getSupplierDataResponse xmlns:urn="urn:schemas.general.com.au:api:other" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:schemas.general.com.au:api:other" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns6="http://schemas.cordys.com/default_005056B9-5D92-A1E9-904D-128C719CE2DD" xmlns:ns5="http://schemas.cordys.com/casemanagement/1.0" xmlns:ns4="http://schemas.XXTGGHG.org/2004/07/STRD.Models" xmlns:ns3="urn:schemas.general.com.au:canonical:technical:v1" xmlns:ns2="urn:schemas.general.com.au:api:other" xmlns:bpm="http://schemas.cordys.com/default" xmlns:sm="http://www.w3.org/2005/07/scxml" xmlns:instance="http://schemas.cordys.com/bpm/instance/1.0">
            <CustomerData>
                <DateLicenceExpires>28/01/2020</DateLicenceExpires>
                <Demonstration_Method>Certification</Demonstration_Method>
                <AuditLastAuditDate>05/03/2018</AuditLastAuditDate>
                <AuditOutcome>Non Compliance</AuditOutcome>
                <HeadOfficeRegion/>
                <ScopeOfLicencing>YES</ScopeOfLicencing>
                <LicStatus>Licensed</LicStatus>   
            </CustomerData>
            <OperationResult xmlns="urn:schemas.general.com.au:canonical:technical:v1">
                <Status>00</Status>
                <StatusMessage>Success</StatusMessage>
            </OperationResult>
        </getSupplierDataResponse>
    </soapenv:Body>
</soapenv:Envelope>

以下是邮递员测试:

pm.test('Verify the LicStatus', function() {
var responseJson = xml2Json(responseBody);
pm.expect(responseJson.results[0].LicStatus).to.eql("Licensed");

})

1 个答案:

答案 0 :(得分:1)

尝试这样的事情:

pm.test('Verify the LicStatus', function() {
    var xmlTree = xml2Json(responseBody);
    var licenseStatus = xmlTree['soapenv:Envelope']['soapenv:Body'].getSupplierDataResponse.CustomerData.LicStatus;

    pm.expect(licenseStatus).to.eql("Licensed");
})