mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
WithCallback leads to empty response #222
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Mies75 on GitHub (Oct 15, 2019).
When I use
.WithBody(@"<soapenv:Envelopeetc. I get a response that is can be handled well by our applications.However when we use a callback, the response message is empty :
Leads to:
Am I doing something wrong?
Regards,
Michel
@StefH commented on GitHub (Oct 15, 2019):
You need to provide
DetectedBodyType = BodyType.StringSee
https://github.com/WireMock-Net/WireMock.Net/blob/master/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithCallbackTests.cs#L21
@Mies75 commented on GitHub (Oct 16, 2019):
Great, that works!
I also had to add:
responseMsg.Headers.Add("Content-Type", new WireMock.Util.WireMockList<string>() { "text/xml; charset=utf-8" } );It seems that one has to set all message properties in the callback. Would it be possible to still take the headers and status code from
.RespondWithinstead of arranging it in the callback?@StefH commented on GitHub (Oct 16, 2019):
If you only want to manipulate the body, then you can use:
WithBody([NotNull] Func<RequestMessage, string> bodyFactory, .....See example line 193 in
93682c9bbf/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithBodyTests.cs (L189-L193)@Mies75 commented on GitHub (Oct 16, 2019):
Cool, that works. I rather have my transform functions return strings instead of
ResponseMessages.Thanks!
@StefH commented on GitHub (Oct 16, 2019):
OK. Good to hear.
Closing...