Soap 在表Lua中合并表
如何将具有可变长度的LUA表合并到另一个LUA表中 在FOR循环中,我希望搜索记录(plunr和pluname)并将其放在表中。 如果每个记录都放在表中,我将把这个表合并到另一个“请求表”中 问题是只有最后一条记录被发送到Web服务器Soap 在表Lua中合并表,soap,lua,Soap,Lua,如何将具有可变长度的LUA表合并到另一个LUA表中 在FOR循环中,我希望搜索记录(plunr和pluname)并将其放在表中。 如果每个记录都放在表中,我将把这个表合并到另一个“请求表”中 问题是只有最后一条记录被发送到Web服务器 for rrplu in receipt:getPLUs() do local plunr = rrplu:getPLUNo(); local pluname = rrplu:getName(); plutable = { tag = "hot
for rrplu in receipt:getPLUs() do
local plunr = rrplu:getPLUNo();
local pluname = rrplu:getName();
plutable = { tag = "hot1:TicketDetail",
{ tag = "hot1:PLU", plunr},
{ tag = "hot1:Description", pluname},
}
end;
local soap_client = vpos.communication.SOAPClient (http)
local request = {
url = urlHTTPS,
soapaction = "http://blablabla.com/IXmlPosService/Charge",
namespace = {hot="http://blablabla.com/",
hot1="http://schemas.datacontract.org/2004/07/BlaBla.Web.DataContracts"},
method = "hot:Charge",
body = { tag = "hot:Charge",
{ tag = "hot:authentication",
{ tag = "hot1:Token", TokenValue},
},
{ tag = "hot:request",
{ tag = "hot1:PosDate", datum},
{ tag = "hot1:TicketDetails",
plutable
},
},
}
}
result, err, err_string = soap_client:call (request)
每次通过循环将
plutable
设置为新表。您可能希望插入到新表或现有表中
将plutable=
替换为
plutable = plutable or {}
table.insert(plutable, {
tag = "hot1:TicketDetail",
{ tag = "hot1:PLU", plunr },
{ tag = "hot1:Description", pluname }})