
Is it possible to return an XmlDataDocument from a .NET assembly to AX 4.0?
I have requirement to look at data from legacy systems and would rather re-use existing functionality than do a re-write. If this not possible what would be an appropriate alternative?
Thanks in advance...
*This post is locked for comments
I have the same question (0)for anyone who is also looking to solve this problem - if you return the actual inner XML text you load this into an AX XMLDocument. The same techinque can be used to pass data back to .NET and into a dataset.
.NET functions/methods:
Public Function GetDotNetDataset(ByVal vTopCount As Integer) As String
Dim DBConnection As SqlConnection = New SqlConnection(???)
Dim adpGetData As New SqlDataAdapter("sp_GetMyData", DBConnection)
Dim dstResults As New DataSet
Dim xmlDoc As Xml.XmlDocument
With adpGetData.SelectCommand
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@TopCount", SqlDbType.Int).Value = vTopCount
End With
adpGetData.Fill(dstResults, "MYDATA")
xmlDoc = New Xml.XmlDataDocument(dstResults)
Return xmlDoc.InnerXml
End Function
Public Sub ReceiveXMLStringSaveDataset(ByVal vInnerXMLString As String)
Dim dstAddress As New DataSet
Dim xmlDoc As Xml.XmlDataDocument = New Xml.XmlDataDocument
xmlDoc.InnerXml = vInnerXMLString
dstAddress.ReadXml(New Xml.XmlNodeReader(xmlDoc))
dstAddress.WriteXml("C:\temp\xmldataset.xml")
End Sub
X++ code:
void GetDotNetData()
{
VBPassBackDataset.DBLookup myVBclass;
XmlDocument xmlDOTNETdata;
XmlNodeList nodeList;
XmlNode node;
str xmlText;
myVBclass = new VBPassBackDataset.DBLookup();
xmlDOTNETdata = new XmlDocument();
xmlText = myVBclass.GetDotNetDataset(250);
xmlDOTNETdata.loadxml(xmlText);
nodeList = xmlDOTNETdata.documentElement().childNodes();
do
{
node = nodeList.nextNode();
if (node)
{
info( node.nodeName() + ':' + node.innerText());
}
} while(node);
}