Sample XML consumption in C# code to AIF Inventory On Hand. This is from AX 4.0 but I think it's the same in AX 2009.
try
{
string strSoapEnvelope = "";
string responseString = "";
// Build SOAP envelope
strSoapEnvelope = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
strSoapEnvelope += "<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">";
strSoapEnvelope += "<soap12:Body>";
strSoapEnvelope += "<findListInventoryOnhand xmlns=\"http://schemas.microsoft.com/dynamics/2006/02/documents/InventoryOnhand\">";
strSoapEnvelope += "<DocumentContext>";
strSoapEnvelope += "<MessageId>" + Guid.NewGuid().ToString() + "</MessageId>";
strSoapEnvelope += "<SourceEndpointUser>
DOMAIN \\
WEBSERVICESUSER</SourceEndpointUser>";
strSoapEnvelope += "<SourceEndpoint>XXXXXXXXXXXXXXXX</SourceEndpoint>";
strSoapEnvelope += "<DestinationEndpoint>
ENDPOINT NAME</DestinationEndpoint>";
strSoapEnvelope += "</DocumentContext>";
strSoapEnvelope += "<QueryCriteria xmlns=\"http://schemas.microsoft.com/dynamics/2006/02/documents/QueryCriteria\">";
strSoapEnvelope += "<CriteriaElement>";
strSoapEnvelope += "<DataSourceName>InventSum</DataSourceName>"; strSoapEnvelope += "<FieldName>ItemId</FieldName>";
strSoapEnvelope += "<Operator>Equal</Operator>";
strSoapEnvelope += "<Value1>YYYYYYYYYYYYYYYYYY</Value1>";
strSoapEnvelope += "</CriteriaElement>";
strSoapEnvelope += "</QueryCriteria>";
strSoapEnvelope += "</findListInventoryOnhand>";
strSoapEnvelope += "</soap12:Body>";
strSoapEnvelope += "</soap12:Envelope>";
MSXML2.XMLHTTP xmlHTTP = new XMLHTTP();
xmlHTTP.open("Post", "http://
ZZZ.ZZ.ZZ.ZZZ:ZZZZ/inventoryonhandservice.asmx", false, @"
DOMAIN\WEBSERVICESUSER", "
PASSWORD");
xmlHTTP.setRequestHeader("Host", "
99.999.99.99");
xmlHTTP.setRequestHeader("Content-Length", strSoapEnvelope.Length.ToString());
xmlHTTP.setRequestHeader("Content-Type", "application/soap+xml; charset=utf-8");
xmlHTTP.send(strSoapEnvelope.ToString());
responseString = xmlHTTP.responseText.ToString();
MessageBox.Show(string.Format("XML: {0}", responseString.ToString()));
WebClient webby = new WebClient();
webby.Encoding = System.Text.Encoding.UTF8;
webby.Credentials = new NetworkCredential("
WEBSERVICESUSER ", "
PASSWORD", "
DOMAIN");
webby.Headers.Add("Content-Type", "text/xml;");
string stuff = webby.UploadString("http://
99.999.99.999/inventoryonhandservice.asmx", "POST", strSoapEnvelope.ToString());
MessageBox.Show(stuff);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}