I have very similar requests (soap) that differ very slightly. My regexes work individually, but when I deploy the mappings to the server, the wrong regex always works. I have the impression he just takes the first one that fits. I tested my regex in online regex generators, there shouldn't be any confusion, but it just doesn't work on wiremock.
Unfortunately I can't publish any details, but I have set up my mapping in this form:
.
.
.
"bodyPatterns": [
{
"matches": "1abcdf"
}
]
.
.
.
"bodyPatterns": [
{
"matches": "4abcdf"
}
]
.
.
.
"bodyPatterns": [
{
"matches": "10abcdf"
}
]
TBOMK, WireMock takes the best matching request, and, if multiple match, it picks the one which was added the most recent. If you want to prioritize requests in this case, you can add this to the stub ( https://wiremock.org/docs/stubbing/#stub-priority ). So from your description, it sounds like all requests match, so it takes the last one.
For the body pattern: this is an array, so if multiple match, WireMock aggregates the result, helping you to narrow down the result (in case there are partial matches). Maybe this is an option to improve your matches.
Furthermore, I would suggest that you try using
XPathalong with WireMock ( https://wiremock.org/docs/request-matching/#xpath + https://wiremock.org/docs/request-matching/#combining-date-matchers-as-jsonpathxpath-sub-matchers ) to create more exact matches.You can also increase verbosity to get some information on why a stub was chosen and improving your matching logic.