xml - Populate multiple response items from database query in soap -
i'm trying make soap mockservice more dynamic , have come across bit of problem. have no idea how populate multiple response items information database rows. i'll explain project setup , i'm trying best can.
project works this: 1. application setup send off xml requests soap mockservice. 2. mockservice uses groovy script setup database connection. gets relevant rows database using information passed in request.
(the following part in trying figure out) 3. each row in database query response seperate item in response.
an example of like.
request:
<?xml version="1.0" encoding="utf-8"?> <soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <soapenv:body> <qdigetpartyfull xmlns="urn:qdiservices"> <anitem>3328666</anitem> <anitem>3328666</anitem> </qdigetpartyfull> </soapenv:body>
response:
<?xml version="1.0" encoding="utf-8"?> <soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <soapenv:body> <itemfullresponse xmlns="urn:services"> <itemfullreturn> <itemreponse> <country>qwe</country> <county>abc</county> <postcode>123</postcode> <itemerror> <errorcode>0</errorcode> <errormessage xsi:nil="true"/> </itemerror> <status>xyz</status> </itemreponse> <itemreponse> <country>qwe</country> <county>abc</county> <postcode>123</postcode> <itemerror> <errorcode>0</errorcode> <errormessage xsi:nil="true"/> </itemerror> <status>xyz</status> </itemreponse> <ierror xsi:nil="true"/> </itemfullreturn> </itemfullresponse> </soapenv:body>
sorry poor formatting.
where right now: have database connection returning rows using groovy need figure out how place each row new itemresponse.
i should mention number of items in request = number of items / rows in response
figured out.
i used markupbuilder generate xml used context write generated xml response.
probably better ways of doing seems work.
will post code when finish off
Comments
Post a Comment