Forum Discussion

uma6kasturi's avatar
uma6kasturi
Occasional Contributor
9 years ago

replace response with parameter from request

Hi All,   In the below case i need a script for both rest and soap services    SOAP services 1.Request consists of a value UPRN which is the key driver  2.I have external file where my UPRN fil...
  • rupert_anderson's avatar
    rupert_anderson
    9 years ago

    Hi,

     

    I think if you create a new mock response called Default Response and paste the default.xml XML into it (with the property expansion mentioned before) then the following code change should put the customerid into the property uprn and despatch the Default Response containing the customerid:

     

     

    else{
    /*
    def tempContent = groovy.xml.XmlUtil.serialize(new XmlParser().parse(groovyUtils.projectPath+"/MOCK/default.xml"))
    /**replacing the place holders in the response **/
    tempContent = tempContent.replace("\$uprnumber",customerId)
    
    //finall setting the response content
    context.content = tempContent
    */
    
    requestContext["uprn"]=customerId
    return "Default Response"
    }

    Make sense?

    Regards,

    Rupert