1

在我的测试中,我必须从通道队列中选择几条消息之一。所以我有这样的步骤:

http()
  .server(server_name)
  .receive()
  .post(eventService)
.selector("xpath://Envelope/Body/CreateMessageDrivenEventRequest/MessageHeader/CustomsData/TraderIdentifier=123456NA")

但是选择器不会从通道队列中选择需要的请求。任何人都可以分享正确 xpath 或其他类型选择器的示例吗?

谢谢,奥尔哈

评估请求:

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header>
        <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">
            <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-24012100">
                <wsse:Username>Username</wsse:Username>
                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
            </wsse:UsernameToken>
        </wsse:Security>
        <addr:To xmlns:addr="http://www.w3.org/2005/08/addressing">address</addr:To>
        <addr:Action xmlns:addr="http://www.w3.org/2005/08/addressing">action</addr:Action>
        <addr:ReplyTo xmlns:addr="http://www.w3.org/2005/08/addressing">
            <addr:Address>http://www.w3.org/2005/08/addressing/anonymous</addr:Address>
        </addr:ReplyTo>
        <addr:MessageID xmlns:addr="http://www.w3.org/2005/08/addressing">uuid:b23a690e-15fc-4ffa-8a7f-dd981ebb92ba-1a</addr:MessageID>
    </soapenv:Header>
    <soapenv:Body>
        <CreateMessageDrivenEventRequest xmlns="xxx">
            <cct:MessageHeader xmlns:cct="yyy">
                <cct:TransactionId>792974800</cct:TransactionId>
                <cct:MessageId>18c9d974-3a1c-48ca-811f-a0787d9d2ee5</cct:MessageId>
                <cd:CustomsData xmlns:cd="zzz">
                    <cd:TraderIdentifier>123456NA</cd:TraderIdentifier>
                    <cd:MailboxCollectId>NA123456NA</cd:MailboxCollectId>
                    <cd:MessageVersion>1</cd:MessageVersion>
                    <cd:DocumentFormat>xml</cd:DocumentFormat>
                    <cd:InputIndicator>DTI</cd:InputIndicator>
                    <cd:DateReceived>20161125141127</cd:DateReceived>
                </cd:CustomsData>
            </cct:MessageHeader>
            <n:MRN xmlns:n="xxx">123456789</n:MRN>
            <n:Event xmlns:n="xxxx">
                <cct:Date xmlns:cct="xxxx">20170126160630</cct:Date>
                <cct:User xmlns:cct="xxxx">System</cct:User>
                <cct:Comments xmlns:cct="xxxx">Message sent to Trader (Carrier)</cct:Comments>
                <cct:StateCode xmlns:cct="xxxx">I012</cct:StateCode>
                <cct:EventCode xmlns:cct="xxxx">1234</cct:EventCode>
            </n:Event>
</CreateMessageDrivenEventRequest>
</soapenv:Body>
</soapenv:Envelope>

`

4

1 回答 1

0

您的 XPath 表达式没有使用任何 XML 名称空间,但消息正在这样做。表达式必须引用 SOAP 和您的域的元素名称空间。

像这样的东西: xpath://soap:Envelope/soap:Body/ns:CreateMessageDrivenEventRequest/ns:MessageHeader/ns:CustomsData/ns:TraderIdentifier=123456NA

除此之外,您还需要在全局命名空间上下文中声明命名空间前缀和值,例如:

<citrus:namespace-context>
  <citrus:namespace prefix="soap" uri="http://schemas.xmlsoap.org/soap/envelope"/>
  <citrus:namespace prefix="ns" uri="xxx"/>
</citrus:namespace-context>
于 2017-02-08T21:40:19.523 回答