It would be awesome to have better SOAP support and Mark D. Sievers has provided a nice snippet for this in this StackOverflow answer:
Setup:
public <T> void stubOperation(String operation, Class<T> clazz,
Predicate<T> predicate, Object response) {
wireMock.stubFor(requestMatching(
new SoapObjectMatcher<>(context, clazz, operation, predicate))
.willReturn(aResponse())
.withHeader("Content-Type", "text/xml")
.withBody(serializeObject(response))));
}
Usage:
SoapContext context = new SoapContext(...); // URIs, QName, Prefix, ect
context.stubOperation("createUser", CreateUser.class, (u) ->
"myUser".equals(u.getUserName()), new CreateUserResponse());
soapClient.createUser("myUser");
Could something based on that be added to WireMock?
Any chance this gets implemented @tomakehurst? I'd really like to not use SOAPUI for SOAP-Testing.
I'd love to be able to tackle this problem properly, but I'm unlikely to find the time for it in the near future unfortunately.
Having said that I was always planning to add SOAP support as an extension library rather than to WireMock's core, so there's no reason it has to be me that works on it.
Most helpful comment
I'd love to be able to tackle this problem properly, but I'm unlikely to find the time for it in the near future unfortunately.
Having said that I was always planning to add SOAP support as an extension library rather than to WireMock's core, so there's no reason it has to be me that works on it.