【发布时间】:2016-10-09 21:43:41
【问题描述】:
- 这是我对 soapUI 的回应
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<SearchAirFaresResponse xmlns="http://www.sample.com/xchange">
<SearchAirFaresResult>
<![CDATA[
<FareSearchResponse>
<MasterDetails>
<CurrencyCode>INR</CurrencyCode>
<RecStNo>1</RecStNo>
<SessionID>5705b1a6-95ac-486c-88a1f90f85e57590</SessionID>
</MasterDetails>
</FareSearchResponse>
]]>
</SearchAirFaresResult>
</SearchAirFaresResponse>
</soap:Body>
</soap:Envelope>
-
如何使用 groovy 脚本提取 CDATA 中的 SessionID 元素并将其用于另一个请求,例如
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <xch:GetMoreFares> <xch:sGetMoreFare> <![CDATA[ <MoreFlights> <MasterDetails> <NoOfResult Index="1">40</NoOfResult> <BranchId>1</BranchId> <SessionId>5705b1a6-95ac-486c-88a1f90f85e57590</SessionId> </MasterDetails> <Journey>DOM</Journey> <ResponseType>XML</ResponseType> <SearchType>OW</SearchType> </MoreFlights> ]]> </xch:sGetMoreFare> </soap:Body> </soap:Envelope>3.我一直在搜索,但没有找到合适的,而且也是使用soapUi的groovy脚本的新手,请指导我在soapUi中逐步执行。
【问题讨论】:
-
看起来您收到了不同类型的回复,您想从两个回复中提取
sid?顺便说一句,第一个响应似乎格式不正确,并且是searchResponse真正嵌套的。你能提供正确的xml吗?更新问题。 -
实际上我需要像我在第 2 节中提到的第二个 xml 结构一样发送请求
-
您是否尝试过官方文档中的任何内容? soapui.org/functional-testing/working-with-cdata.html