Designer 10.15 | webMethods Service Development Help | Working with gRPC Descriptors | About gRPC Descriptors | Example of a gRPC Service to a gRPC Descriptor
 
Example of a gRPC Service to a gRPC Descriptor
To demonstrate how a proto file that contains a gRPC service definition corresponds to a gRPC descriptor and its artifacts, consider the following proto file for a calculator. The proto file contains a single service named Calculator and multiple gRPC method definitions, one for each basic math operation: Add, Subtract, Multiply, and Divide. The proto file also contains two message definitions: CalcRequest and CalcReply.
syntax = "proto3";


option java_package = "com.webmethods.grpc.examples.calc";
option java_outer_classname = "CalcDemo";

package calc;

service Calculator {

rpc Add (CalcRequest) returns (CalcReply) {}
rpc Subtract (CalcRequest) returns (CalcReply) {}
rpc Multiply (CalcRequest) returns (CalcReply) {}
rpc Divide (CalcRequest) returns (CalcReply) {}
}

message CalcRequest{
double num1=1;
double num2=2;
}

message CalcReply{
double value=1;
}
Using Designer to create a gRPC descriptor named calcDemoProvider in the grpcCalc folder results in the following additions to the IS namespace.
Notice that in addition to the calcDemoProvider gRPC provider descriptor, Integration Server creates:
*A calc folder that corresponds to package calc in the proto file.
*A Calculator folder that corresponds to service Calculator in the proto file.
*Four gRPC method flow services named Add, Divide, Multiply, Subtract for each rpc method in the Calculator service.
*Two gRPC document types named CalcReply and CalcRequest that correspond to the messages of the same name in the proto file.
Note:
gRPC document types are IS document types but use a different icon to denote their role in gRPC descriptors. Do not move or rename gRPC document types. Do not use gRPC document types as publishable document types.
The gRPC descriptor editor displays the gRPC method flow services, include request and response messages, for the gRPC descriptor. Clicking on the Body for a Request displays the input signature for the gRPC method flow service.
The gRPC method flow service editor displays some automatically generated logic for the gRPC method flow service, essentially a placeholder MAP step followed by calls to the built-in services pub.grpc.observer:onNext and pub.grpc.observer:onCompleted. These services, located in the WmGRPC package, serialize the IData produced for the request into protocol buffers, sends the reply to the gRPC client, and closes the connection to the client. You must implement the logic for the RPC method in the gRPC method flow service prior to the execution of the pub.grpc.obsrver* services. For more information about editing the gRPC method flow services, see Editing a gRPC Method Flow Service.
The input and output signature of the gRPC method flow service contains document references to the gRPC document types for the request and reply messages, respectively. The input signature contains additional input parameters streamObserver and streamType which are used by the pub.grpc.observer:onNext and pub.grpc.observer:onCompleted services to send a response to the client.
For information about modifying the gRPC method flow service to include the logic needed to generate a response, see Editing a gRPC Method Flow Service.