Generic Request Application with custom Web Services
The Generic request and Custom Web Services application is runnable in the Demo environment or in your own instance of .
To learn how to install NAE CE locally or on a server, follow this tutorial.
Custom Web Service code snippet
groovy
import javax.net.ssl.HttpsURLConnection
import groovy.json.JsonSlurper
def randomPerson(def name, def surname, def email) {
URL url = new URL("https://randomuser.me/api/")
HttpsURLConnection con = (HttpsURLConnection) url.openConnection()
con.setRequestMethod("GET")
int status = con.getResponseCode()
Reader streamReader = null
if (status > 299) {
streamReader = new InputStreamReader(con.getErrorStream())
} else {
streamReader = new InputStreamReader(con.getInputStream())
}
def json = new JsonSlurper()
def object = json.parseText(streamReader.text)
change name value { object.results.get(0).get("name").get("first") }
change surname value { object.results.get(0).get("name").get("last") }
change email value { object.results.get(0).get("email") }
}Runner code snippet
groovy
import com.netgrif.application.engine.auth.domain.*
import com.netgrif.application.engine.petrinet.domain.roles.ProcessRole
import com.netgrif.application.engine.auth.service.interfaces.IUserService
// Class definition omitted for brevity
@Autowired
private IUserService userService
@Override
void run(String... args) throws Exception {
log.info("Calling custom runner")
userService.saveNew(new User(
name: "User",
surname: "Test",
email: "test@netgrif.com",
password: "password",
state: UserState.ACTIVE,
authorities: [] as Set,
processRoles: [] as Set))
}