AIF Outbound Message - inserting data into the XML message

I need to populate some fields in my XML Outbound message. What is the best way to do this? I know on the inbound, you can use prepareForSave to insert data into your XML before it is processed. Can you use the prepareForSave on the outbound? Will it allow you to populate data into the XML before sending it out?

The other option I see is the outbound pipeline. Does anyone have any example of how to search for your XML tag in the existing XML and then insert the value you want? I saw some code that used the XMLTextReader to find your tag (xmlTextReader.readElementString2(‘ItemId’)) but the reader doesn’t have any ability to Write into it. How do you use the XMLTextReader and XMLTextWriter together to change your XML before it goes out? Or is there another way?

Thanks!

I don’t know if this is going to work or not, but there is a method you can override in your Axd class that is called processingRecord(). It passes in a common record. I’m going to see if this is my record and if it is, set it to the value that I want it to be. I stepped through it in debug mode, when it got to that method, I went in and modified the field to my value. When the XML was generated, my new value was in the XML. I looked in the database to make sure it didn’t change the value in the original record, and it didn’t. This seemed to have worked. This seems easier than deserializing the XMl in the outbound pipeline to insert my data.

Any other suggestions?

I figured I couldn’t use the parm methods on the Ax table class because that would insert that value for ALL services that use that table and I couldn’t figure out how to determine if it was my specific interface. You can use valueMappingOutbound() to see if this is an outbound interface, but I couldn’t figure out how to tell if it was MY specific outbound interface. Otherwise, I’d put it there.

Also, I can use the outbound pipeline by adding this code in the execute method of the pipeline:

public void execute(AifPipelineComponentRecId componentRecId, AifMessage message, AifPipelineParms parms)
{
XmlDocument xmlDoc = new XmlDocument();
XmlNode xmlNode;
XmlNodeList xmlNodeList;
XmlElement xmlElement;
;

xmlDoc = XmlDocument::newXml(message.getXml());
xmlNodeList = xmlDoc.getElementsByTagName(“SalesTable”);

// Obtain the first xmlNode.
xmlNode = xmlNodeList.nextNode();
xmlElement = xmlNode.getNamedElement(“CustAccount”);
xmlElement.text(“4005”); // If you use the sample CreateSalesOrder.xml file, the value should be 4000 instead of 4005.
message.setXml(xmlDoc.xml());
}

hello mstrillian,

you got any solution or not for this problem bcoz i am aslo having same requirement and i ahve to add some field in outbound XML file.