Skip to content

Instantly share code, notes, and snippets.

@EvgenJin
Created July 20, 2020 19:11
Show Gist options
  • Save EvgenJin/7ea26d09d57e9f87bba9280601d0f582 to your computer and use it in GitHub Desktop.
Save EvgenJin/7ea26d09d57e9f87bba9280601d0f582 to your computer and use it in GitHub Desktop.
#parsing xml
ru.gpb.mule.util.Utils.makeString(payload)
def response = new XmlSlurper().parseText(payload)
def reestr = new XmlSlurper().parseText(response as String)
def code = reestr.CreditRequest.@Code
println(reestr.CreditRequest.@Code)
return response
#create json
def ob = [:];
ob.name = "obj_name_xml"
def jsonObj = new groovy.json.JsonBuilder(ob);
#flowVars
flowVars['ob'] = jsonObj
#парсинг json в модель
flowVars["documentModel"] = new JsonSlurper().parse(new File(this.getClass().getClassLoader().getResource("documentModel.json").getFile()))
#создать папку
def tmpFolderPath = flowVars["dirPath"]
flowVars["tmpFolderPath"] = tmpFolderPath
log.info("path = " + tmpFolderPath)
def src = new File(tmpFolderPath);
if (!src.exists()){
def mkdir = src.mkdirs()
if (!mkdir){
throw new Exception("Неудалось создать папку")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment