Can I preserve Mapping title and matchers for proxy response?
See original GitHub issueHello.
I use a third party SOAP service that I’ve been told I run tests against too often. I was hoping to use WireMock to proxy and record these requests. Then I’d like to use the recorded mappings as stubs going forward. To proxy and record the initial set, I use something like this:
server
.Given(Request.Create().WithPath("/*")
.WithBody(new RegexMatcher("<RequestType>Auth</RequestType")))
.WithTitle(rule.Name)
.RespondWith(Response.Create().WithProxy(new ProxyAndRecordSettings
{
Url = proxyTarget,
AllowAutoRedirect = true,
SaveMapping = true,
SaveMappingToFile = true,
}));
Because it is a SOAP service, all the requests use the same URL. The request primarily differ on the body contents. Currently when I run these requests, it seems like a new mapping is creating, using the path and method to create a new title. Since the path and method are the same for each request, each request overwrites the one before it. It also seems that the regex matchers that were specified in the original mapping are being discarded in favor of matching the url, path, headers, and an exact match on the body of the request.
If that understanding is correct, is there a way to work around this behavior to preserve the original mapping? If there isn’t a work around, I’d like to submit a PR. In it, I’d try to add an option to ProxyAndRecordSettings and use that to decide how to build the resulting mapping. Would that help?
Issue Analytics
- State:
- Created a year ago
- Comments:14

Top Related StackOverflow Question
Thanks @StefH I appreciate all of your help!
Done.