Search code examples
javaglassfishcorda

How to organize the interaction between a corda node and a GlassFish java web server?


I use the corda platform and want to use the glassfish server, tell me how to organize the interaction of the corda node and the GlassFish java web server?


Solution

  • Take a look at the Spring Webserver example here for an example of a Spring Boot webserver that interacts with a Corda node. The design will be similar for a GlassFish webserver.

    Communicating with the node:

    The key file is https://github.com/corda/samples/blob/release-V3/spring-webserver/src/main/kotlin/net/corda/server/NodeRPCConnection.kt. Here, we create a long-lived CordaRPCClient instance. The webserver's controllers use this client to send messages to and from the node, as shown here: https://github.com/corda/samples/blob/release-V3/spring-webserver/src/main/kotlin/net/corda/server/controllers/StandardController.kt.

    Dependencies:

    The webserver requires dependencies on Corda itself (for the core classes and the RPC client classes). See https://github.com/corda/samples/blob/release-V3/spring-webserver/build.gradle#L47. The webserver will also require dependencies on any CorDapps that contain classes that will be used by the controllers. For example, if you have a controller with an endpoint that extracts IOUStates from the vault, then the IOUCorDapp will be a dependency of your webserver.