2016-06-28 55 views
1

使用崇替换字符在一个动态的变量

<dyn_variable name="OK_Button" jsonpath="test.items[0].links[0].href"/> 

我能够从JSON http://localhost:8081/mycode/1.5.0/extended/call/action

提取下面的网址,但在接下来的请求Iwant利用上述网址通过改变例如IP和端口

回答

2

<dyn_variable name="ok_button" jsonpath = "test.items[0].links[0].href"/> 
<setdynvars sourcetype="eval" 
     code='fun({Pid,DynVars})-> 
        {ok,Val}=ts_dynvars:lookup(ok_button,DynVars), 
        L1 = re:replace(Val,"localhost","192.169.1.100",[{return,list}]), 
        L2 = re:replace(L1,"8801","8800",[{return,list}]), 
        L2 end.'> 
    <var name="new_address" /> 
</setdynvars> 

%% ok_button tolower 
%% L2 = "http://192.169.1.100:8800/mycode/1.5.0/extended/call/action" 

<request subst="true"> 
    <http url="%%_new_address%%" method="POST" contents="......." 
</request> 
+0

由于BR o,它工作:) – Sanal