diff --git a/workflows/src/main/java/com/r3/developers/csdetemplate/flowexample/workflows/Message.java b/workflows/src/main/java/com/r3/developers/csdetemplate/flowexample/workflows/Message.java index 7e2a44e..b20791e 100644 --- a/workflows/src/main/java/com/r3/developers/csdetemplate/flowexample/workflows/Message.java +++ b/workflows/src/main/java/com/r3/developers/csdetemplate/flowexample/workflows/Message.java @@ -7,6 +7,10 @@ import net.corda.v5.base.types.MemberX500Name; // send it from one virtual node to another. @CordaSerializable public class Message { + + private MemberX500Name sender; + private String message; + public Message(MemberX500Name sender, String message) { this.sender = sender; this.message = message; @@ -20,6 +24,5 @@ public class Message { return message; } - public MemberX500Name sender; - public String message; + } diff --git a/workflows/src/main/java/com/r3/developers/csdetemplate/flowexample/workflows/MyFirstFlow.java b/workflows/src/main/java/com/r3/developers/csdetemplate/flowexample/workflows/MyFirstFlow.java index c13334a..a2ffb32 100644 --- a/workflows/src/main/java/com/r3/developers/csdetemplate/flowexample/workflows/MyFirstFlow.java +++ b/workflows/src/main/java/com/r3/developers/csdetemplate/flowexample/workflows/MyFirstFlow.java @@ -58,7 +58,7 @@ public class MyFirstFlow implements RPCStartableFlow { MyFirstFlowStartArgs flowArgs = requestBody.getRequestBodyAs(jsonMarshallingService, MyFirstFlowStartArgs.class); // Obtain the MemberX500Name of the counterparty. - MemberX500Name otherMember = flowArgs.otherMember; + MemberX500Name otherMember = flowArgs.getOtherMember(); // Get our identity from the MemberLookup service. MemberX500Name ourIdentity = memberLookup.myInfo().getName(); @@ -67,7 +67,7 @@ public class MyFirstFlow implements RPCStartableFlow { Message message = new Message(otherMember, "Hello from " + ourIdentity + "."); // Log the message to be sent. - log.info("MFF: message.message: " + message.message); + log.info("MFF: message.message: " + message.getMessage()); // Start a flow session with the otherMember using the FlowMessaging service. // The otherMember's virtual node will run the corresponding MyFirstFlowResponder responder flow. @@ -82,16 +82,15 @@ public class MyFirstFlow implements RPCStartableFlow { // The return value of a RPCStartableFlow must always be a String. This will be passed // back as the REST RPC response when the status of the flow is queried on Corda, or as the return // value from the flow when testing using the simulator. - return response.message; + return response.getMessage(); } } - /* RequestBody for triggering the flow via http-rpc: { "clientRequestId": "r1", - "flowClassName": "com.r3.developers.csdetemplate.workflows.MyFirstFlow", + "flowClassName": "com.r3.developers.csdetemplate.flowexample.workflows.MyFirstFlow", "requestData": { "otherMember":"CN=Bob, OU=Test Dept, O=R3, L=London, C=GB" } diff --git a/workflows/src/main/java/com/r3/developers/csdetemplate/flowexample/workflows/MyFirstFlowResponder.java b/workflows/src/main/java/com/r3/developers/csdetemplate/flowexample/workflows/MyFirstFlowResponder.java index 70d35f9..a41fc13 100644 --- a/workflows/src/main/java/com/r3/developers/csdetemplate/flowexample/workflows/MyFirstFlowResponder.java +++ b/workflows/src/main/java/com/r3/developers/csdetemplate/flowexample/workflows/MyFirstFlowResponder.java @@ -44,7 +44,7 @@ public class MyFirstFlowResponder implements ResponderFlow { Message receivedMessage = session.receive(Message.class); // Log the message as a proxy for performing some useful operation on it. - log.info("MFF: Message received from " + receivedMessage.sender + ":" + receivedMessage.message); + log.info("MFF: Message received from " + receivedMessage.getSender() + ":" + receivedMessage.getMessage()); // Get our identity from the MemberLookup service. MemberX500Name ourIdentity = memberLookup.myInfo().getName(); @@ -54,19 +54,9 @@ public class MyFirstFlowResponder implements ResponderFlow { "Hello " + session.getCounterparty().getCommonName() + ", best wishes from " + ourIdentity.getCommonName()); // Log the response to be sent. - log.info("MFF: response.message: " + response.message); + log.info("MFF: response.message: " + response.getMessage()); // Send the response via the send method on the flow session session.send(response); } } -/* -RequestBody for triggering the flow via http-rpc: -{ - "clientRequestId": "r1", - "flowClassName": "com.r3.developers.csdetemplate.MyFirstFlow", - "requestData": { - "otherMember":"CN=Bob, OU=Test Dept, O=R3, L=London, C=GB" - } -} - */ \ No newline at end of file diff --git a/workflows/src/main/java/com/r3/developers/csdetemplate/flowexample/workflows/MyFirstFlowStartArgs.java b/workflows/src/main/java/com/r3/developers/csdetemplate/flowexample/workflows/MyFirstFlowStartArgs.java index c67cad3..bfcca2d 100644 --- a/workflows/src/main/java/com/r3/developers/csdetemplate/flowexample/workflows/MyFirstFlowStartArgs.java +++ b/workflows/src/main/java/com/r3/developers/csdetemplate/flowexample/workflows/MyFirstFlowStartArgs.java @@ -4,12 +4,16 @@ import net.corda.v5.base.types.MemberX500Name; // A class to hold the arguments required to start the flow public class MyFirstFlowStartArgs { - public MemberX500Name otherMember; + private MemberX500Name otherMember; + + // The JSON Marshalling Service, which handles serialisation, needs this constructor. + public MyFirstFlowStartArgs() {} public MyFirstFlowStartArgs(MemberX500Name otherMember) { this.otherMember = otherMember; } - // The JSON Marshalling Service, which handles serialisation, needs this constructor. - public MyFirstFlowStartArgs() {} + public MemberX500Name getOtherMember() { + return otherMember; + } }