I am trying to fetch the list of vendors from the AX database.
I want to show a list of vendors in my aspx page.How can i achieve this?
here is what i have done so far
1-Deployed the Ax webservices. 2-Created a client class to call the service.
i am stuck here and not sure how to fetch the data.
Please advice.
I found out how to do it..here is the solution as to how to Consume AIF webservices.here is the code.Please refer the following article http://msdn.microsoft.com/en-us/library/cc652581.aspx
customerService.CustomerServiceClient sc = new ConsumingAxWebService.customerService.CustomerServiceClient();
AxdCustomer axdCustomer;
QueryCriteria queryCriteria;
CriteriaElement[] criteriaElements;
IEnumerator enumerator;
int iCountLoops1 = 0;
AxdEntity_CustTable cust;
criteriaElements = new CriteriaElement[1];
criteriaElements[0] = new CriteriaElement();
criteriaElements[0].DataSourceName = "CustTable";
criteriaElements[0].FieldName = "AccountNum";
criteriaElements[0].Operator = Operator.Range;
criteriaElements[0].Value1 = "1101";
criteriaElements[0].Value2 = "1102";
queryCriteria = new QueryCriteria();
queryCriteria.CriteriaElement = criteriaElements;
axdCustomer = sc.find(queryCriteria);
enumerator = axdCustomer.CustTable.GetEnumerator();
while (enumerator.MoveNext())
{
++iCountLoops1;
cust = (AxdEntity_CustTable)enumerator.Current;
Response.Write(cust.AccountNum + "\n");
}
As dates and I can move decimal to the web service in Ax, the name of the service I am using is CustFreeTextInvoice ..
Passing string data no problem but with date and decimal data itself.
code attached ...
private void btnIngresar_Click(object sender, EventArgs e)
{
FreeTextInvoiceServiceClient service = new FreeTextInvoiceServiceClient();
if (null == service)
{
throw new Exception("Cannot instantiate service.");
}
AxdFreeTextInvoice FreeTextInvoice = new AxdFreeTextInvoice();
//Record
AxdEntity_CustInvoiceTable CustInvoiceTable = new AxdEntity_CustInvoiceTable();
CustInvoiceTable.InvoiceId = "100";
CustInvoiceTable.Name = txtName.Text;
CustInvoiceTable.OneTimeCustomer = 0;
CustInvoiceTable.OrderAccount = txtOrderAccount.Text;
//CustInvoiceTable.DocumentDate = DateTime.Now;
//CustInvoiceTable.DueDate = Convert.ToDateTime("20/12/2011");
CustInvoiceTable.InvoiceDate = Convert.ToDateTime("20/11/2011");
CustInvoiceTable.CustInvoiceLine = new AxdEntity_CustInvoiceLine[2];
CustInvoiceTable.CustInvoiceLine[0] = new AxdEntity_CustInvoiceLine();
CustInvoiceTable.CustInvoiceLine[0].Description = "Primer registro";
CustInvoiceTable.CustInvoiceLine[0].LedgerAccount = "610208";
CustInvoiceTable.CustInvoiceLine[0].TaxGroup = "IVAVTAS12";
CustInvoiceTable.CustInvoiceLine[0].TaxItemGroup = "all";
CustInvoiceTable.CustInvoiceLine[0].AmountCur = 1000;
CustInvoiceTable.CustInvoiceLine[1] = new AxdEntity_CustInvoiceLine();
CustInvoiceTable.CustInvoiceLine[1].Description = "segundo registro";
CustInvoiceTable.CustInvoiceLine[1].LedgerAccount = "610208";
CustInvoiceTable.CustInvoiceLine[1].TaxGroup = "IVAVTAS12";
CustInvoiceTable.CustInvoiceLine[1].TaxItemGroup = "all";
CustInvoiceTable.CustInvoiceLine[1].AmountCur = 90;
FreeTextInvoice.CustInvoiceTable = new AxdEntity_CustInvoiceTable[1] { CustInvoiceTable };
try
{
testws.FTIS.EntityKey[] returned = service.create(FreeTextInvoice);
testws.FTIS.EntityKey returnedValues = (testws.FTIS.EntityKey)returned.GetValue(0);
Console.WriteLine("Valor retornado: " + returnedValues.KeyData[0].Value);
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.ToString());
Console.ReadLine();
}
}
来源:https://stackoverflow.com/questions/4667013/fetching-data-from-dynamics-ax-2009-using-ax-webservices-and-c-sharp