Assuming I am in an Integration Server, I would call WmPublic pub.web:stringToDocument and WmPublic pub.web:documentToRecord to get an IData representation of the XML dcoument and write a Java service that takes the price record and does something like this:
IDataCursor ic = pipeline.getCursor();
IData price = IDataUtil.getIData(ic, “price”);
if (price == null) {
ic.destroy();
throw new ServiceException(“missing required parameter ‘price’”);
}
IDataCursor icp = price.getCursor();
String priceType = IDataUtil.getString(icp, “@priceType”);
String newKey = “pricePriceType”+priceType;
// May need to generically loop through
// child elements and copy them to
// newRecord with the exception of @priceType
String amount = IDataUtil.getString(icp, “amount”);
Object o = {
{“amount”,amount}
};
IData newRecord = IDataFactory.create(o);
IDataUtil.put(ic, newKey, newRecord);
ic.destroy();
and after calling this service, drop the original price record.
Depending on the bigger picture of other required transformations, the structure of the document and where the document is going the Java service may need to do a little more (like take an array of price Records) and there may need to be a Record input to documentToRecord to get the IData structure formatted that way you want.
#webMethods#webMethods-General#Integration-Server-and-ESB