我的测试我必须从通道队列中选择一条消息。所以我有这样的步骤:
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>
`
答案 0 :(得分: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>