在我的JMeter場景中,我正在測試SOAP Web服務。我將初始請求發送給webservice S1,然後使用它的響應來建立對S2的請求。 從S1的響應進來的形式:將無節點本身的xml節點內容提取到Jmeter中的變量中
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<s:response xmlns:s="http://custom.namespace.com/namespace">
...
<s:responseDetails>
<s:detail1>some info</s:detail>
<s:detail2>another info<s:detail2>
...
</s:responseDetails>
</s:response>
</soap:Body>
</soap:Envelope>
我需要使用內部<s:responseDetails>
一切建立請求,S2,但包裝不同的XML元素中:在請求而不是
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s="http://custom.namespace.com/namespace">
<soap:Body>
<s:request>
<s:details>
<s:detail1>some info</s:detail>
<s:detail2>another info<s:detail2>
...
</s:details>
</s:request>
</soap:Body>
</soap:Envelope>
注元素<s:details>
<s:responseDetails>
。
我開始使用XPath提取希望用XPath表達式把一切都在<s:responseDetails>
標籤到JMeter的變量:
//*[local-name()='responseDetails']/node()
- 給我一組與<s:responseDetails>
不同的孩子JMeter的變量,而我希望他們在一個變量//*[local-name()='responseDetails']
- 給我的整個節點<s:responseDetails>
,我不能因爲根標籤<s:responseDetails>
,我需要<s:details>
什麼是正確的表達得到一切內部<s:responseDetails>
到變量,這樣我可以在以後使用
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s="http://custom.namespace.com/namespace">
<soap:Body>
<s:request>
<s:details>
${details}
</s:details>
</s:request>
</soap:Body>
</soap:Envelope>
或者,也許有另一種方式來解決我的問題?
我是BeanShell Sampler的新手,我想問一下:如果我將在負載測試中使用BeanShell,會帶來任何問題scenari o有很多線程? –
我更新了我的答案。 –
謝謝你這個偉大的答案!我必須花一些時間來實現解決方案,然後才能接受答案 –