Closed dileepsam closed 4 years ago
An XML response is just plain text, so you can transform all things you like.
I have configured response like below
"Response": {
"BodyAsFile": "Success.xml",
"Headers": {
"Content-Type": "application/xml; charset=UTF-8"
},
"StatusCode": 201,
"UseTransformer": true
}
Success.xml contains Handlebar transformation which does not seem to work.
Am I missing something.?
Currently the transformation is only done for the filename, not yet for the file contents.
I'll take a look.
A preview NuGet is available on MyGet: WireMock.Net.1.0.38-ci-12271.nupkg
You need to provide an extra property ("UseTransformerForBodyAsFile": true
)in the mapping:
{
"Guid": "fd8ca21b-db82-48bc-ae5a-fc2153c2b0db",
"Request": {
"Path": {
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "/bodyasfile_transform123"
}
]
},
"Methods": [
"get"
]
},
"Response": {
"StatusCode": 200,
"Headers": { "Content-Type": "application/xml" },
"BodyAsFile": "c:\\temp-wiremock\\__admin\\mappings\\_{{request.query.MyUniqueNumber}}_\\MyXmlResponse.xml",
"UseTransformer": true,
"UseTransformerForBodyAsFile": true
}
}
Thank you, Stef. It works.
Hi,
I am trying to use this as a standalone app to mock the server, when configured an XML file as a response,
how to transform the contents of the file.?
Thanks,