IBCRPC220FDW
The service contract interface that all Aptean Mesh mobile service codeunits must implement. Each service codeunit implements this interface to handle RPC calls dispatched by the MobileRPCRegistry220FDW.
Overview
- Object type: Interface
- Namespace:
Aptean.Mesh.SDUI - Purpose: Defines the single entry point that the registry calls when routing a mobile RPC request to your service
Aptean Mesh uses a service-locator pattern. The registry resolves a service code to a codeunit ID, then fires an integration event so that the matching codeunit can return itself as the IBCRPC220FDW implementation. The registry then calls RPC() on that implementation.
Methods
RPC
procedure RPC(var State: Codeunit MobileRPCState220FDW) ResponseJson: JsonObject
Executes an RPC method using pre-hydrated state containing the full request context. The registry calls State.Hydrate() before invoking this method, so the state object is already populated with method name, input, workflow, barcode data, and other request fields.
Parameters:
| Name | Type | Direction | Description |
|---|---|---|---|
State | Codeunit MobileRPCState220FDW | var (in/out) | Pre-hydrated state containing the parsed request. Use it to read input, manage workflow state, and build the response. |
Returns: JsonObject -- the JSON-RPC response payload that is sent back to the mobile client.
Implementation Pattern
Every service codeunit follows a three-part pattern:
- Event subscriber -- registers the codeunit with the MobileRPCRegistry220FDW via
OnResolveService - RPC entry point -- dispatches to method handlers based on
State.Method() - Method handlers -- contain the actual business logic
codeunit 50100 "My Service" implements IBCRPC220FDW
{
// 1. Register with the service registry
[EventSubscriber(ObjectType::Codeunit, Codeunit::MobileRPCRegistry220FDW,
OnResolveService, '', false, false)]
local procedure ResolveMyService(
CodeunitId: Integer;
var Service: Interface IBCRPC220FDW;
var IsServiceResolved: Boolean)
begin
if IsServiceResolved then
exit;
if CodeunitId <> Codeunit::"My Service" then
exit;
Service := this;
IsServiceResolved := true;
end;
// 2. RPC entry point -- state is already hydrated by the registry
procedure RPC(var State: Codeunit MobileRPCState220FDW) ResponseJson: JsonObject
begin
case State.Method() of
'Initialize':
Initialize(State);
'ScanItem':
ScanItem(State);
'Confirm':
Confirm(State);
end;
ResponseJson := State.Serialize();
end;
// 3. Method handlers
local procedure Initialize(var State: Codeunit MobileRPCState220FDW)
begin
// Set up initial workflow state, build info pane, etc.
State.SetDocumentNo('WH-001');
State.SetCurrentStep(Enum::StepType220FDW::Scan);
end;
local procedure ScanItem(var State: Codeunit MobileRPCState220FDW)
var
ScannedValue: Text[100];
begin
ScannedValue := State.GetScannedValue('01');
// Validate item, update state...
end;
local procedure Confirm(var State: Codeunit MobileRPCState220FDW)
begin
// Post warehouse transaction, return success...
State.SetResult('status', 'OK');
end;
}
Service Registry Configuration
Before your service can receive requests, map the service code to your codeunit in Business Central:
- Open Mobile App Bundles
- Select your bundle, then open Mobile Service Setup
- Add a row:
- Mobile Service Code -- e.g.,
MYSERVICE(must match theservicefield in the page JSON) - Codeunit Id -- e.g.,
50100(the object ID of your implementing codeunit)
- Mobile Service Code -- e.g.,
Dispatch Flow
Mobile App --> API Page --> MobileRPCRegistry220FDW
|
|--> State.Hydrate(RequestJson)
|--> Lookup service code in registry table
|--> Fire OnResolveService(CodeunitId, ...)
|--> ServiceHandler.RPC(State)
|--> Return ResponseJson to client
See Also
- MobileRPCState220FDW -- request parsing, state management, and response building
- MobileRPCRegistry220FDW -- the dispatcher that resolves and invokes service implementations