Forum Discussion
I'm a bit confused by your post. Can you just clarify a couple of points.
Where you state " I want to get the message inside the SOAP Body for the Request and write it out to a file." , what do you actually mean by "get the message inside the soap body". Are you saying that you have a payload contained within your soapbody container tag (which is all standard stuff) and youre using a mockservice/virt and you want to get the request's payload saved to a file or the response's payload saved to a file?
When you say "you've tried many methods", can you explain what you've tried?
In summary, if you coulr explain exactly what you need so its really clear, that'll only help people be able to sort you out.
Ta
Rich
- Admins4 years agoOccasional Contributor
Rich
Yes, I want the XML Payload (ApplicationOutcomeUpdate) in the SOAP Body...
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
<s:Body>
<ns0:ApplicationOutcomeUpdate xmlns:ns0="http://CompanyA/v1">.......and I have a MockService which accepts this Request from an Application and I want to save the XML Payload inside the SOAP Body to a file.
I have got the Request using...
def request = new XmlParser().parseText(mockRequest.requestContent)
I then try and use XmlHolder, XmlSlurper or XmlParser to extract the Xml I need inside the SOAP Body but all I seem to get is Null.
Regards
Stewart
- richie4 years agoCommunity HeroHey Admins,
Cool, i might be able to help with th4 groovy, but the real scripters on here are better placed to do that.
Can you provide exactly whst you've tried using each of the xml scraping methods you mention? There's no point me duplicating effort.
It shouldn't be strsightforward to extract the whole response the whole envelope, then it just needs a bit of tinkering to scrape thr payload from the soapbody.
I've just re-read what you've written. Are you saying you want to save the payload from the request or the response? It sounds like you want to save the request...
Ta
Rich - Admins4 years agoOccasional Contributor
Richie
Apologies for the delay.
What I want to get is the Request which contains the Soap Envelope inside is the Soap Body and inside this is the payload message Its the payload message inside the Soap Body I want to save off to a file.
I have tried the following...
def req = new XmlHolder(messageExchange.requestContent)
def req = new XmlHolder(mockRequest.requestContent)
def req = new XmlHolder(context.request)
def req = new XmlSlurper(messageExchange.requestContent)
def req = new XmlSlurper(mockRequest.requestContent)
def req = new XmlSlurper(context.request)
...but I get either an error or null returned.
- Admins4 years agoOccasional Contributor
Richie
OK, an update.
I have been able to get hold of the Request i.e. the SOAP Envelope using the following...
def request = mockRequest.getRequestContent()
Now I need to extract the payload inside the SOAP Body. That's what I need help on now.
Related Content
Recent Discussions
- 9 hours agoKLWallace
- 7 days agoruchisingh