我们可以像在SoapUI工具中对肥皂服务那样使用setNodeValue方法来设置其余服务的节点值吗?
ex-
XMLHolder。setNodeValue(“ // typ:name”,名称)
XMLHolder。setNodeValue(“” // typ:id“,id)
XMLHolder。setNodeValue(“” // typ:部门“,部门)
XMLHolder。setNodeValue(“” // typ:age“,年龄)
REST可以容纳XML以及JSON,您需要哪一个?如果您使用XML,则可以使用相同的方法,如果将其用于JSON,请遵循以下内容
import groovy.json.JsonSlurper
import groovy.json.JsonOutput
// Define Request
def request = '{ "name":"John", "country":"India", "car":"Honda" }'
// Parse The Request
def jsonReq = new JsonSlurper().parseText(request);
// Set Values
jsonReq.name = "Wilfred"
jsonReq.country = "India"
jsonReq.car = "Honda"
// Parse JSON to string
def jsonReqAsString = JsonOutput.toJson(jsonReq)
// Print or You can do anything
log.info (jsonReqAsString)