Related samples:
Generic invocation in current Dubbo Go is centered on client.NewGenericService(...) and filter/generic.GenericService. Older examples based on ReferenceConfigBuilder, GenericLoad(), and GetRPCService() describe the legacy compatibility API and are no longer the recommended entry point.
The main runtime entry is in client/client.go:
genericService, err := cli.NewGenericService(
"org.apache.dubbo.samples.UserProvider",
client.WithProtocolTriple(),
client.WithSerialization(constant.Hessian2Serialization),
client.WithURL("tri://127.0.0.1:20000"),
)
NewGenericService(...) does three important things by default:
NONIDLhessian2 serializationInternally it creates filter/generic.GenericService, then wires it into the normal reference and invocation path.
The core type is:
type GenericService struct {
Invoke func(ctx context.Context, methodName string, types []string, args []hessian.Object) (any, error) `dubbo:"$invoke"`
}
This mirrors the generic invocation model used by Dubbo: you provide:
and the framework sends a generic $invoke request to the remote service.
Current Dubbo Go also provides InvokeWithType(...):
var user User
err := genericService.InvokeWithType(
ctx,
"getUser",
[]string{"java.lang.String"},
[]hessian.Object{"123"},
&user,
)
This helper deserializes the generic result into a concrete Go reply object. It is useful when you still want generic transport behavior but do not want to manually convert the returned map structure.
Generic invocation is usually used when:
For Triple plus Hessian2 compatibility scenarios, the generic sample is the best place to look first.
The implementation is not only a client helper. It is also connected to the generic filter chain under filter/generic, where Dubbo Go handles generic invocation encoding, decoding, and service-side adaptation.
That is why this feature belongs both to client APIs and to the framework’s filter-based extension model.