Running Webserver

The corbeans-corda-webserver example project implements an alternative to Corda’s default Node webserver using modules of corbeans. The server exposes basic endpoints by default but supports either a single node via runNodes or multiple manually configured nodes, see bellow for a configuration examples.

Download

You can use your own custom webserver based on the starter or download the sample at https://oss.sonatype.org/content/repositories/releases/com/github/manosbatsis/corbeans/corbeans-corda-webserver/

The corbeans-corda-webserver only goes up to version 0.30, the reason being you are actually expected to use corbeans for creating your own Spring Boot app anyway.

Running the Server

Spring Boot applications using the starter can be run either manually (i.e. ../gradlew bootRun) or via runNodes as a drop-in replacement to the corda-webserver.

Configure for runNodes

To use with runNodes, add your custom or sample webserver JAR in the node folder and renaming the file to replace the default corda-webserver.jar:

├── nodes
│   ├── BankA
│   │   ├── additional-node-infos
│   │   ├── certificates
│   │   ├── corda.jar
│   │   ├── cordapps
│   │   ├── corda-webserver.jar
│   │   ├── drivers
│   │   ├── logs
│   │   ├── network-parameters
│   │   ├── node.conf
│   │   ├── nodeInfo-4B67...
│   │   ├── persistence.mv.db
│   │   ├── persistence.trace.db
│   │   └── web-server.conf
│   ├── BankA_node.conf
│   ├── BankA_web-server.conf
│   ├── Notary Service
│   ├── Notary Service_node.conf
│   ├── runnodes
│   ├── runnodes.bat
│   └── runnodes.jar

With Corda and cordformation Gradle plugin versions 4+ and 4.0.25+ and up respectively, you can automate this by setting the webserverJar property of the CordForm plugin, by applyihng the following changes in your cordapp build:

// 1: Add proper cordformation and quasar plugin versions
buildscript {
    dependencies {
        classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version"
        classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version"
        //...
    }
}
// 2: Add Corda v4
dependencies {
    cordaCompile "net.corda:corda-rpc:$corda_release_version"
    cordaCompile "net.corda:corda-core:$corda_release_version"
    cordaRuntime "net.corda:corda:$corda_release_version"
}

// 3: Add webserverJar to each node
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
    //...
    node {
        name "O=BankA,L=London,C=GB"
        p2pPort 10005
        cordapps = []
        rpcUsers = ext.rpcUsers
        rpcSettings {
            port 10007
            adminPort 10008
        }
        webPort 10009
        webserverJar  "/PATH/TO/MY/corbeans-corda-webserver.jar"
    }

}

Then use runnodes as usual to see the corbeans app in place of the original corda wobserver:

runnodes xterm shells

Configure for Multiple Nodes

There are multiple ways to let Spring Boot know about your Corda nodes using externalized configuration.

For a simple example, consider an application.properties file like:

spring.jackson.serialization.fail-on-empty-beans=false
springfox.documentation.swagger.v2.path=/api-docs

corbeans.nodes.partyA.username=user1
corbeans.nodes.partyA.password=test
corbeans.nodes.partyA.lazy=true
corbeans.nodes.partyA.address=localhost:10006


corbeans.nodes.partyB.username=user1
corbeans.nodes.partyB.password=test
corbeans.nodes.partyB.lazy=true
corbeans.nodes.partyB.address=localhost:10009
corbeans.nodes.partyB.primaryServiceType=com.github.manosbatsis.corbeans.corda.webserver.components.SampleCustomCordaNodeServiceImpl

logging.level.root=INFO
logging.level.com.github.manosbatsis=DEBUG
logging.level.net.corda=INFO

Optional Properties

The following properties are optional per node (e.g. partA) with defaults taken from CordaRPCClientConfiguration.DEFAULT

# RPC SSL 
#corbeans.nodes.partyA.trustStorePath=
#corbeans.nodes.partyA.trustStorePassword=
#corbeans.nodes.partyA.trustStoreProvider=JKS

# Other RPC properties
#corbeans.nodes.partyA.connectionMaxRetryInterval=
#corbeans.nodes.partyA.connectionRetryInterval=
#corbeans.nodes.partyA.connectionRetryIntervalMultiplier=
#corbeans.nodes.partyA.deduplicationCacheExpiry=
#corbeans.nodes.partyA.maxFileSize=
#corbeans.nodes.partyA.maxReconnectAttempts=
#corbeans.nodes.partyA.minimumServerProtocolVersion=
#corbeans.nodes.partyA.observationExecutorPoolSize=
#corbeans.nodes.partyA.reapInterval=
#corbeans.nodes.partyA.trackRpcCallSites=

Run

You can pass that file to the webserver executable with:

java -jar corbeans-corda-webserver-VERSION.jar  --spring.config.location=/path/to/application.properties

For more alternatives see Externalized Configuration in Spring Boot docs.

API Reference

You can browse a running server’s swagger-ui to view documentation of the available endpoints:

Corda Webserver Boot'sSwagger UI