Request Matching Protobuf - Multiple Proto Definition files Fail #732

Closed
opened 2025-12-29 15:32:29 +01:00 by adam · 1 comment
Owner

Originally created by @Allen0117 on GitHub (Dec 17, 2025).

Describe the bug

I’m trying to enable WireMock.NET gRPC to support multiple Proto definition files.
After reviewing the official documentation, I found that it previously described how to apply this setup, and I followed the configuration order as outlined in the docs.

However, I still encounter errors when running it, so I’d like to confirm whether there is a correct or recommended way to configure this, or if there are any additional considerations I might be missing.

Reference documentation:
https://wiremock.org/dotnet/request-matching-protobuf/

(Section: Multiple Proto Definition files)

Expected behavior:

It should be able to successfully mock multiple proto definitions.

Code to Reproduce

UnitTestCode

var allenPath = Path.Combine(RootPath, "Protos", "greet.proto");
var requestPath = Path.Combine(RootPath, "Protos", "request.proto");
var allenProtoDefinitionText = File.ReadAllText(allenPath);
var requestProtoDefinitionText = File.ReadAllText(requestPath);
var protoDefinitionId = "GrpcGreet";
var server = WireMockServer.Start(useHttp2: true);
server
    .AddProtoDefinition(protoDefinitionId, allenProtoDefinitionText, requestProtoDefinitionText)
    .Given(Request.Create()
        .UsingPost()
        .WithPath("/grpc/greet.Greeter/SayHello")
        .WithBodyAsProtoBuf("greet.HelloRequest", new JsonMatcher(new { name = "stef" }))
    )
    .WithProtoDefinition(protoDefinitionId)
    .RespondWith(Response.Create()
        .WithHeader("Content-Type", "application/grpc")
        .WithTrailingHeader("grpc-status", "0")
        .WithBodyAsProtoBuf("greet.HelloReply",
            new
            {
                message = "hello {{request.BodyAsJson.name}} {{request.method}}"
            })
        .WithTransformer()
    );

greet.proto:

syntax = "proto3";
package greet;
service Greeter {
  rpc SayHello (HelloRequest) returns (HelloReply);
}
message HelloRequest {
  string name = 1;
}
message HelloReply {
  string message = 1;
}

request.proto:

syntax = "proto3";

package greet;

message HelloRequest {
  string name = 1;
}

Error

Grpc.Core.RpcException : Status(StatusCode="Unimplemented", Detail="Bad gRPC response. HTTP status code: 404")
Originally created by @Allen0117 on GitHub (Dec 17, 2025). ### Describe the bug I’m trying to enable WireMock.NET gRPC to support multiple Proto definition files. After reviewing the official documentation, I found that it previously described how to apply this setup, and I followed the configuration order as outlined in the docs. However, I still encounter errors when running it, so I’d like to confirm whether there is a correct or recommended way to configure this, or if there are any additional considerations I might be missing. Reference documentation: https://wiremock.org/dotnet/request-matching-protobuf/ (Section: Multiple Proto Definition files) ### Expected behavior: It should be able to successfully mock multiple proto definitions. ### Code to Reproduce **UnitTestCode** ```csharp var allenPath = Path.Combine(RootPath, "Protos", "greet.proto"); var requestPath = Path.Combine(RootPath, "Protos", "request.proto"); var allenProtoDefinitionText = File.ReadAllText(allenPath); var requestProtoDefinitionText = File.ReadAllText(requestPath); var protoDefinitionId = "GrpcGreet"; var server = WireMockServer.Start(useHttp2: true); server .AddProtoDefinition(protoDefinitionId, allenProtoDefinitionText, requestProtoDefinitionText) .Given(Request.Create() .UsingPost() .WithPath("/grpc/greet.Greeter/SayHello") .WithBodyAsProtoBuf("greet.HelloRequest", new JsonMatcher(new { name = "stef" })) ) .WithProtoDefinition(protoDefinitionId) .RespondWith(Response.Create() .WithHeader("Content-Type", "application/grpc") .WithTrailingHeader("grpc-status", "0") .WithBodyAsProtoBuf("greet.HelloReply", new { message = "hello {{request.BodyAsJson.name}} {{request.method}}" }) .WithTransformer() ); ``` **greet.proto:** ```protobuf syntax = "proto3"; package greet; service Greeter { rpc SayHello (HelloRequest) returns (HelloReply); } message HelloRequest { string name = 1; } message HelloReply { string message = 1; } ``` **request.proto:** ```protobuf syntax = "proto3"; package greet; message HelloRequest { string name = 1; } ``` ### Error ``` Grpc.Core.RpcException : Status(StatusCode="Unimplemented", Detail="Bad gRPC response. HTTP status code: 404") ```
adam added the question label 2025-12-29 15:32:29 +01:00
adam closed this issue 2025-12-29 15:32:30 +01:00
Author
Owner

@Allen0117 commented on GitHub (Dec 19, 2025):

After experimenting, I found that the statement mentioned in the article—“A comment is needed for each referenced (imported) proto file”—means that the comment must be added at the very top of the file, as shown in the screenshot.

Image
@Allen0117 commented on GitHub (Dec 19, 2025): After experimenting, I found that the statement mentioned in the article—“A comment is needed for each referenced (imported) proto file”—means that the comment must be added at the very top of the file, as shown in the screenshot. <img width="411" height="350" alt="Image" src="https://github.com/user-attachments/assets/7690981b-5439-4493-b00f-3a033f31466c" />
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#732