我正在尝试从AX数据库中获取供应商列表。
我想在我的aspx页面中显示供应商列表。我如何实现这一目标?
这是我到目前为止所做的事情
1 - 部署了Axe Web服务。 2 - 创建一个客户端类来调用该服务。
我被困在这里,不知道如何获取数据。
请建议。
答案 0 :(得分:2)
我发现了如何做到这一点。关于如何使用AIF webservices.here是代码的解决方案。请参阅以下文章 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");
}
答案 1 :(得分:0)
由于日期和我可以将十进制移动到Ax中的Web服务,我使用的服务名称是CustFreeTextInvoice ..
传递字符串数据没问题,但是日期和小数数据本身。
附加代码......
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();
}
}