Tsung在POST请求中使用动态变量

时间:2017-05-30 12:04:09

标签: post dynamic tsung

我有这样的xml文件,我想将POST请求的响应用作在下一个请求中使用的变量。我看过this链接,但我找不到解决方案。如何使用shop_id这是第二个请求中第一个请求的响应?

<request> 
<dyn_variable name="shop_id" re=".*" ></dyn_variable>
<http url="/service/shop" method="POST" version="1.1">
<http_header name="x-auth-id" value="c44e2dcbd271400112ee5def4a1c601d449930276e24fa495c3162f971962088208213b1f2bfba2f04c4fc01c40f00a6ce02abc18da92021ae176e72cecf324d3bf16b398084d84f30c8701696e9f6032661f9854de67ea5be92091e51340e8b77358145"/>
<http_header name="lang" value="fa"/>

</http>
</request>



<request subst="true"> 

<http url="/service/shopping/%%_shop_id%%" method="POST" version="1.1"  > 

<http_header name="x-auth-id" value="c44e2dcbd271400112ee5def4a1c601d449930276e24fa495c3162f971962088208213b1f2bfba2f04c4fc01c40f00a6ce02abc18da92021ae176e72cecf324d3bf16b398084d84f30c8701696e9f6032661f9854de67ea5be92091e51340e8b77358145"/>

<http_header name="lang" value="fa"/>
<http_header name="Content-Type" value="application/json"/>


</http> </request>

1 个答案:

答案 0 :(得分:0)

您是否尝试过该链接的解决方案?

查看您尝试设置shop_id的示例请求,您将完全错过:

<request subst="true">

因此,而不是:

<request> 
<dyn_variable name="shop_id" re=".*" ></dyn_variable>
<http url="/service/shop" method="POST" version="1.1">
...

试试这个

<request subst="true"> 
<dyn_variable name="shop_id" re=".*" ></dyn_variable>
<http url="/service/shop" method="POST" version="1.1">
...