【问题标题】:Postman test fails while parsing the xml soap response解析 xml 肥皂响应时邮递员测试失败
【发布时间】:2019-06-13 00:50:44
【问题描述】:

我正在使用 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>

下面是post man测试:

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

})

【问题讨论】:

  • 你从哪里得到results[0]?通过查看回复,我会认为responseJson.CustomerData.LicStatus 会更接近您的需要。当你做console.log('responseJson')时你看到了什么?

标签: soap postman


【解决方案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");
})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-06
    • 1970-01-01
    • 1970-01-01
    • 2018-08-18
    相关资源
    最近更新 更多