Retornar valores randomicos.
02/05/2012 15:58
class ExemploService {
static transactional = false
static expose = ['cxf']
Retorno ConsultarSaldo(String cpf, int idLoja) {
Retorno ret = new Retorno(Erro:"0", Saldo:"1500")
return ret as JSON
}
class Retorno {
String Erro
String Saldo
}
}
def pool = ['a'..'z','A'..'Z',0..9,'_'].flatten()
Random rand = new Random(System.currentTimeMillis())
def final = (0..25).collect({ pool[rand.nextInt(pool.size())] }).join()
return ret as JSON
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Cannot cast object '{"class":"exemplo.ExemploService$Retorno","erro":"0","saldo":"1500","this$0":{"class":"exemplo.ExemploService"}}' with class 'grails.converters.JSON' to class 'exemplo.ExemploService$Retorno'</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
return ret
Retorno ConsultarSaldo(String cpf, int idLoja) {
return new Retorno(
Erro:0,
Saldo:1500
)
}
class Retorno {
int Erro
Double Saldo
}
Para se registrar, clique aqui.