I have a scripting functoid on the map. I need to pass in the message to the parameter of a method, and return an associated document. The method I thought would work would be this:
public XLANGMessage Map(XLANGMessage src);
However, I can't find confirmation; can I pass an entire message via the mapping tool, treat it as a document, and return a response? Is my approach correct?
Scripting functoids can only take in strings and return strings. You'll have to do what you're trying to do in an Orchestration or helper library, or use inline XSLT (which could select a nodeset and produce output based on that).
In an orchestration, I'd do something like this in a MessageAssignment shape:
msg_NewMsg = new System.Xml.XmlDocument();
UtilityClass.Map(msg_OldMsg, msg_NewMsg);
msg_MapOutput.FieldToAssign = msg_NewMsg.OuterXml();
Where FieldToAssign is a distinguished field in the message. In the utilities class, you'd do something like this:
public static void Map(XLANGMessage from, XLANGMessage to)
{
using(MemoryStream ms = from[0].RetreiveAs(typeof(Stream)))
{
using (StreamReader reader = new StreamReader(ms))
{
string x = reader.ReadToEnd();
// do stuff with x; alternative, XDocument xd = XDocument.Parse(reader.ReadToEnd());
}
}
to[0].LoadFrom(new StringReader(x));
// alt: save the XDocument to a memory stream and call LoadFrom on the memory stream
}