I have a function in Axapta as follows:
static client XMLDocument GetXmlData()
{
XMLDocument xmlReturnDoc = new XMLDocument();
// Build XML Document
return xmlReturnDoc;
}
This returns an XML document. I’m then calling this from a .NET program using the business connector as follows:
Axapta ax;
object o;
ax = new Axapta();
ax.Logon(null, null, null, null);
o = ax.CallStaticClassMethod(“MyClass”, “GetXmlData”);
However, I don’t seem to be able to cast this to a System.Xml.XmlDocument in .NET. Is there a way to do 开发者_如何学Pythonthis, or do I need to return a string and reload the document?
AX XMLDocument
is not the same beast as CLR System.Xml.XmlDocument
.
There is no automatic conversion between object types. There are some implicit conversions of primitive types, but only one way. See How to: Marshal Between X++ and CLR Primitive Types.
Reading How to: Call Business Logic Using .NET Business Connector leaves little doubt that the easy way is to return the XML string.
IMHO, you can pass the correct type into Ax
void netGetXmlData(System.Xml.XmlDocument netXml)
{
XMLDocument xmlDoc = GetXmlData();
netXml.set_InnerText(xmlDoc.text());
}
and call this AX method from CLR :
ax.CallStaticClassMethod(“MyClass”, “GetXmlData”, xmlDoc);
AX works correctly with the CLR data types - you can generate NET XML document on the AX-side.
精彩评论