The docs have this example:
- path: "/users"
method: POST
capture:
petName:
xPath: "/env:Envelope/env:Body/pets:animal/pets:name"
store: testStore
xmlNamespaces:
env: "http://schemas.xmlsoap.org/soap/envelope/"
pets: "urn:com:example:petstore"
But I’m getting an error
14:01:37 INFO i.g.i.Imposter - Starting mock engine 4.0.0
14:01:37 DEBUG i.g.i.c.u.ConfigUtil - Loading configuration file: .configsgm-dds-config.yaml
14:01:38 DEBUG i.g.i.c.u.ConfigUtil - Loading configuration file: .configssingle-response-config.yaml
14:01:38 DEBUG i.g.i.p.PluginManager - Loaded 5 plugin(s): [js-detector, store-detector, rest, js-graal, store-inmem]
14:01:39 ERROR i.v.c.i.l.c.VertxIsolatedDeployer - Failed in deploying verticle
java.lang.RuntimeException: Error configuring plugin: rest
at io.gatehill.imposter.plugin.PluginManagerImpl.configurePlugins(PluginManagerImpl.kt:133) ~[imposter.jar:?]
at io.gatehill.imposter.plugin.PluginManagerImpl.startPlugins(PluginManagerImpl.kt:91) ~[imposter.jar:?]
at io.gatehill.imposter.Imposter$start$1.invokeSuspend(Imposter.kt:132) ~[imposter.jar:?]
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ~[imposter.jar:?]
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108) ~[imposter.jar:?]
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584) ~[imposter.jar:?]
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793) ~[imposter.jar:?]
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697) ~[imposter.jar:?]
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684) ~[imposter.jar:?]
Caused by: java.lang.RuntimeException: Error loading configuration file: my-config.yml , reason: Unrecognized field "xPath" (class io.gatehill.imposter.plugin.config.capture.ItemCaptureConfig), not marked as ignorable (12 known properties: "requestBody", "const", "queryParam", "pathParam", "formParam", "phase", "requestHeader", "jsonPath", "key", "store", "expression", "enabled"])
with the following config
---
plugin: rest
basePath: "/dds"
system:
xmlNamespaces:
soap: "http://schemas.xmlsoap.org/soap/envelope/"
star: "http://www.starstandard.org/STAR/5"
resources:
- path: "/appointments"
method: POST
capture:
serviceappointmentId:
xPath: "/star:ProcessServiceAppointment/star:ProcessServiceAppointmentDataArea/star:ServiceAppointment/star:ServiceAppointmentHeader/star:SecondaryDealerNumberID"
store: requestData
xmlNamespaces:
star: "http://www.starstandard.org/STAR/5"
requestBody:
xPath: "/star:ProcessServiceAppointment/star:ProcessServiceAppointmentDataArea"
operator: Exists
response:
statusCode: 202
content: "appt received"
Actually what I’m trying to do is capture the whole payload, but I switched it to just a single data item to as shown in the docs to see if that would work.
Note that if I leave out the capture settings, then the xPath
matching works fine.