keikom1
15 years agoOccasional Contributor
How to create MockService response using request message
Hi, I think it's too easy question, but I'm a beginner of groovy and I have no idea how to do it.
Could you please help me?
If the request message is
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sam="http://www.example.com/xx/sample">
<soapenv:Header/>
<soapenv:Body>
<sam:testMethod>
<ifCommonHeader>
<requestId>abcde</requestId>
<requestTimestamp>20101217093000</requestTimestamp>
<requestProgram>dummy</requestProgram>
</ifCommonHeader>
<messageBody>
<int_sample>0</int_sample>
<str_sample>zzz</str_sample>
<dec_sample>0.0</dec_sample>
</messageBody>
</sam:testMethod>
</soapenv:Body>
</soapenv:Envelope>
I'd like to create response message as below.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sam="http://www.example.com/sample">
<soapenv:Header/>
<soapenv:Body>
<sam:testMethodResponse>
<returnMessage>
<ifCommonHeader>
<requestId>abcde</requestId>
<requestTimestamp>20101217093000</requestTimestamp>
<requestProgram>dummy</requestProgram>
<result>OK</result>
</ifCommonHeader>
</returnMessage>
</sam:testMethodResponse>
</soapenv:Body>
</soapenv:Envelope>
I'd like to copy 'ifCommonHeader' from request message to response and add an element in ifCommonHeader. How can I write a script?
Thanks for your help.

If the request message is
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sam="http://www.example.com/xx/sample">
<soapenv:Header/>
<soapenv:Body>
<sam:testMethod>
<ifCommonHeader>
<requestId>abcde</requestId>
<requestTimestamp>20101217093000</requestTimestamp>
<requestProgram>dummy</requestProgram>
</ifCommonHeader>
<messageBody>
<int_sample>0</int_sample>
<str_sample>zzz</str_sample>
<dec_sample>0.0</dec_sample>
</messageBody>
</sam:testMethod>
</soapenv:Body>
</soapenv:Envelope>
I'd like to create response message as below.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sam="http://www.example.com/sample">
<soapenv:Header/>
<soapenv:Body>
<sam:testMethodResponse>
<returnMessage>
<ifCommonHeader>
<requestId>abcde</requestId>
<requestTimestamp>20101217093000</requestTimestamp>
<requestProgram>dummy</requestProgram>
<result>OK</result>
</ifCommonHeader>
</returnMessage>
</sam:testMethodResponse>
</soapenv:Body>
</soapenv:Envelope>
I'd like to copy 'ifCommonHeader' from request message to response and add an element in ifCommonHeader. How can I write a script?
Thanks for your help.