Как создать xPath для мыла и тела - PullRequest
1 голос
/ 08 июля 2019

Я пытаюсь создать заглушку для запроса мыла с заголовком и телом, следующим является запрос мыла:

<soap:Envelope
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ns3="http://example.com/ws/Namespaces/CustomerCareProductAndInsurance/Types/Public/CommonDataModel.xsd"
    xmlns:inq="http://example.wsproduct.com/ws/Namespaces/Container/Public/InquireProductDetailsRequest.xsd"
    xmlns="http://example.wsproduct.com/ws/Namespaces/Types/Public/MessageHeader.xsd">
    <soap:Header>
        <MessageHeader>
            <TrackingMessageHeader>
                <version>224</version>
            </TrackingMessageHeader>
        </MessageHeader>
    </soap:Header>
    <soap:Body>
        <inq:InquireProductDetailsRequest>
            <inq:ProductSelector>
                <inq:code>013881004138416</inq:code>
            </inq:ProductSelector>
        </inq:InquireProductDetailsRequest>
    </soap:Body>
</soap:Envelope>

Ниже приведена заглушка, созданная с помощью средства сопоставления xPath, однако она не работает иЯ получаю, что тело не совпадает каждый раз.

 {
    "request": {
        "method": "POST",
        "url": "/inquireProductDetails",
        "headers": {
            "Content-Type": {
                "contains": "text/xml"
            }
        },
        "bodyPatterns": [
            {
                "matchesXPath": "//version='224'"
            },{
                "matchesXPath": "//code='013881004138416'"
            }
        ]
    },
    "response": {
        "transformers": [
            "response-template"
        ],
        "bodyFileName": "productDetails-Success-Response.xml",
        "status": 200
    }
}

Может ли кто-нибудь помочь создать соответствующий xPath для указанного выше запроса на мыло.Заранее спасибо !!

1 Ответ

2 голосов
/ 09 июля 2019

Попробуйте это

{
    "request": {
        "method": "POST",
        "url": "/inquireProductDetails",
        "headers": {
            "Content-Type": {
                "contains": "text/xml"
            }
        },
       "bodyPatterns": [
            {
                "matchesXPath": "//*[local-name()='code'][text()='224']"
            },{
                "matchesXPath": "//*[local-name()='version'][text()='013881004138416']"
            }
        ]
    },
    "response": {
        "transformers": [
            "response-template"
        ],
        "bodyFileName": "productDetails-Success-Response.xml",
        "status": 200
    }
}
...