Befolgen Sie die nachfolgenden Anweisungen, um den untergeordneten Nachrichtenfluss für eine Gutschrift auf einem Girokonto zu erstellen.
Knotentyp | Knotenname |
---|---|
Input | Input |
JavaCompute-Knoten | RetrieveCurrentAccountBalance |
JavaCompute-Knoten | CreditCurrentAccountBalance |
JavaCompute-Knoten | UpdateCurrentAccountBalance |
Output | Output |
Knotenname | Terminal | Mit diesem Knoten verbinden |
---|---|---|
Input | Ausgangsterminal | RetrieveCurrentAccountBalance |
RetrieveCurrentAccountBalance | Ausgangsterminal | CreditCurrentAccountBalance |
CreditCurrentAccountBalance | Ausgangsterminal | UpdateCurrentAccountBalance |
UpdateCurrentAccountBalance | Ausgangsterminal | Output |
import java.math.BigDecimal;
//Go to tree roots MbElement inRoot = inMessage.getRootElement(); MbElement outRoot = outMessage.getRootElement(); MbMessage locEnv = inAssembly.getLocalEnvironment(); MbMessage newLocEnv = new MbMessage(); //Get the operation name MbElement sca = locEnv.getRootElement().getFirstElementByPath("SCA"); MbElement input = sca.getFirstElementByPath("Input"); MbElement operation = input.getFirstElementByPath("Operation"); String operationName = operation.getValue().toString(); //Get the old balance MbElement variables = locEnv.getRootElement().getFirstElementByPath("Variables"); float oldBalance = Float.parseFloat(variables.getFirstElementByPath("oldBalance").getValue().toString()); //Get the amount to transfer MbElement soap = inRoot.getFirstElementByPath("SOAP"); MbElement body = soap.getFirstElementByPath("Body"); MbElement action = body.getLastChild(); MbElement request = action.getLastChild(); MbElement amount = request.getFirstElementByPath("amount"); float transferValue = Float.parseFloat(amount.getValue().toString()); //Calculate the new balance total float newBalance = oldBalance + transferValue; MbElement newVariables = newLocEnv.getRootElement().createElementAsLastChild(MbElement.TYPE_NAME, "Variables", null); //Accept the transfer and set new balance in LE newVariables.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "newBalance", new BigDecimal(newBalance).setScale(2, java.math.BigDecimal.ROUND_HALF_UP).toString()); //Setup the message reply MbElement newXMLNSC = outRoot.createElementAsLastChild(MbXMLNSC.PARSER_NAME); MbElement newOperation = newXMLNSC.createElementAsLastChild(MbElement.TYPE_NAME, operationName + "Response", null); newOperation.setNamespace("http://CurrentAccount/"); MbElement newResponse = newOperation.createElementAsLastChild(MbElement.TYPE_NAME, "CurrentAccountResponse", null); newResponse.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "accept", "yes"); // Create the new assembly with the new property overrides MbMessageAssembly outAssembly = new MbMessageAssembly( inAssembly, newLocEnv, inAssembly.getExceptionList(), outMessage);
MbMessageAssembly outAssembly = new MbMessageAssembly(inAssembly, outMessage);
Jetzt können Sie den Nachrichtenfluss für das Girokonto erstellen. Informationen hierzu finden Sie im Abschnitt Nachrichtenfluss für Girokonto erstellen.