我是SOAPUI的新手,并将几个简单的XML请求链接在一起。我想使用Groovy脚本来更新请求端的现有节点。
例如,我有GetRefData开始:
def GetRequestID = context.expand( '${GetRefData#Response#declare namespace abc=\'bbb\'; //abc:GetRefRq/MsgRqHeader/RequestId[1]}' )
我读了没有问题的回复:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context);
def request = context.expand('GetRefData#Request');
def requestHolder = groovyUtils.getXmlHolder(request);
requestHolder.namespaces["abc"] = "bbb";
def mypath = "//abc:GetRefRq/MsgRqHeader/RequestId[1]"
requestHolder.setNodeValue( mypath, "54321" )
如何在12345到53421的初始请求中更新RequestId?我试过了:
create procedure xxx
@P_Return_Status INT OUTPUT
,@P_Error_Code INT OUTPUT
,@P_Error_Messages VARCHAR(2000) OUTPUT
AS
BEGIN
BEGIN TRY
BEGIN TRANSACTION TR1
/* put statements from both transaction here
or
statements for TR1
AND
call the procedure containing code for TR2
*/
COMMIT TRANSACTIOn TR1
SET @P_Return_Status = 1;
END TRY
BEGIN CATCH
IF (@@TRANCOUNT > 0)
BEGIN
ROLLBACK TRANSACTION TR1
END
Set @P_Error_Code = Error_Number();
Set @P_Error_Messages = LEFT(ERROR_MESSAGE (), 2000)
SET @P_Return_Status = 0;
END CATCH
END
GO
但是当我运行它时,虽然我没有错误也没有更新。
有人可以指出这个菜鸟正确的方向吗?
答案 0 :(得分:1)
试试这个:)
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context);
def request = context.expand('GetRefData#Request');
def requestHolder = groovyUtils.getXmlHolder(request);
//namespace declaration
// assuming your node is <bbb:RequestId>12345</bbb:RequestId>
def ns = "bbb"
requestHolder.setNodeValue("//"+ns+":RequestId", "54321" )
//to verify
log.info requestHolder.getNodeValue("//ns:RequestId" )