We have a need to mimic an external 3rd party webs...
# help
r
We have a need to mimic an external 3rd party webservice endpoint for our internal dev testing needs. We have we have been able to use fixed/static soap responses by putting the hard coded response files under __files/ directory of wiremock. For the matching request, the hard coded response from the file wsdl/2019-12-21_WEP.xml is spitted out perfectly.
Copy code
"request" : {
      "url" : "/some/operation1",
      "method" : "POST"
    },
    "response" : {
      "status" : 200,
      "bodyFileName" : "wsdl/2019-12-21_WEP.xml",
      "headers" : {
        "Content-Type" : "text/xml"
      },
      "transformers" : [ "response-template" ]
    }
Now the need is to extract some xpath values from the in coming soap request body and replace/substitute them in the hard code soap responses at runtime. Using the soapXPath helpers mentioned in the section https://wiremock.org/docs/response-templating/#xpath-helpers of the documentation, extraction of the value can be done. However we are unable to find how to insert those into the soap response . ---we want to dynamically replace certain parts of the hard coded soap response that is in the file wsdl/2019-12-21_WEP.xml What are the possible ways to do this using wiremock. Thanks in advance.
t
Hi @Rahul Agrawal, you can use the template helpers directly in your
2019-12-21_WEP.xml
body file, so something like this:
Copy code
<item>{{{soapXPath request.body '//request-data-item/text()'}}}</item>
r
Thank you so much. Let me try it.
Thanks this worked. It is just that I had to run the standalone mode with additional parameters to support templating
Copy code
java -jar wiremock-standalone-3.1.0.jar --verbose --local-response-templating
did not work with
Copy code
java -jar wiremock-standalone-3.1.0.jar --verbose
Also instead of double // it seems we have to use a single /
Copy code
<item>{{{soapXPath request.body '/request-data-item/text()'}}}</item>
Once again thank for getting such a prompt response from someone of your level. 👏
t
No worries. FYI local response templating will be on by default from 3.2.0.
👍 1
a
@Tom When will the docker docker 3.2.0 version relased ? assuming they are inlined with app version
t
Early next week assuming all goes smoothly with the PRs we intend to merge beforehand
a
sounds good
thanks