我试图从SOAP请求XML中将一些值复制到SOAP响应XML文件中。使用groovy将SOAP UI中的值复制到SOAP UI响应中
考虑以下请求和响应XML以供参考:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ehit="http://www.calheers.ca.gov/EHITSAWSInterfaceMessageSchema" xmlns:ehit1="http://www.calheers.ca.gov/EHITSAWSInterfaceCommonSchema" xmlns:ns="http://niem.gov/niem/structures/2.0" xmlns:ns2="http://niem.gov/niem/niem-core/2.0" xmlns:ns1="http://niem.gov/niem/domains/screening/2.1">
<soapenv:Header/>
<soapenv:Body>
<ehit:DeterminationRequest>
<ehit:MessageInformation>
<ehit1:MessageID ns:id="?" ns:metadata="?" ns:linkMetadata="?">? </ehit1:MessageID>
<ehit1:MessageTimeStamp ns:id="?" ns:metadata="?" ns:linkMetadata="?">?</ehit1:MessageTimeStamp>
<ehit1:SendingSystem ns:id="?" ns:metadata="?" ns:linkMetadata="?">?</ehit1:SendingSystem>
<ehit1:ReceivingSystem ns:id="?" ns:metadata="?" ns:linkMetadata="?">?</ehit1:ReceivingSystem>
<ehit1:FipsCountyCode ns:id="?" ns:metadata="?" ns:linkMetadata="?">?</ehit1:FipsCountyCode>
<!--Optional:-->
<ehit1:TracerID ns:id="?" ns:metadata="?" ns:linkMetadata="?">?</ehit1:TracerID>
</ehit:MessageInformation>
.......continued......
和响应XML是:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ehit="http://www.calheers.ca.gov/EHITSAWSInterfaceMessageSchema" xmlns:ehit1="http://www.calheers.ca.gov/EHITSAWSInterfaceCommonSchema" xmlns:ns="http://niem.gov/niem/structures/2.0">
<soapenv:Header/>
<soapenv:Body>
<ehit:DeterminationResponse>
<ehit1:MessageID ns:id=${id} ns:metadata=${metadata} ns:linkMetadata="?">?</ehit1:MessageID>
<ehit1:AckTimeStamp ns:id="?" ns:metadata="?" ns:linkMetadata="?">?</ehit1:AckTimeStamp>
<!--Optional:-->
<ehit1:StatusCode ns:id="?" ns:metadata="?" ns:linkMetadata="?">?</ehit1:StatusCode>
<!--Optional:-->
<ehit1:ErrorCode ns:id="?" ns:metadata="?" ns:linkMetadata="?">?</ehit1:ErrorCode>
<!--Optional:-->
<ehit1:ErrorMessage ns:id="?" ns:metadata="?" ns:linkMetadata="?">?</ehit1:ErrorMessage>
</ehit:DeterminationResponse>
</soapenv:Body>
</soapenv:Envelope>
我创建了两个动态VAR这里$ {ID}和$ {}的元数据。
我试图复制。现在的ID和元数据属性来设置这些值从请求到响应我使用下面的脚本:
def req = new XmlSlurper().parseText(mockRequest.requestContent)
requestContext.id = [email protected];
requestContext.metadata = [email protected]data;
但它不返回任何值。有人能帮我弄清楚我在这里做错了吗?
此外,如果我想复制很多(考虑50+)从请求值到响应值,那么是否有任何简单的方法,而不是创建50+变量?因为在我的情况下,我不得不将所有请求中的值复制到响应消息中。
你是否在mockService的'onRequest script'上使用这个脚本? – albciff
是的,我正在用soap ui编写mockservice脚本 – Madhusudan