【发布时间】:2013-12-09 14:01:13
【问题描述】:
我使用 Visual Studio 使用了一个 Web 服务,并使用托管代码在 AX 2012 中调用它。 现在,如果我在一个简单的工作中运行代码:
static void CurrencyService(Args _args)
{
CurrencyConvert.Currency_Convert.CurrencyServiceClient convertcurrency;
CurrencyConvert.Currency_Convert.Currency currency;
System.ServiceModel.Description.ServiceEndpoint endPoint;
System.Type type;
System.Exception ex;
str s1;
try
{
type = CLRInterop::getType('CurrencyConvert.Currency_Convert.CurrencyServiceClient');
convertcurrency = AifUtil::createServiceClient(type);
endPoint = convertcurrency.get_Endpoint();
// endPoint.set_Address(new System.ServiceModel.EndpointAddress("http://localhost/HelloWorld"));
currency = convertcurrency.GetConversionRate(CurrencyConvert.Currency_Convert.CurrencyCode::AUD,CurrencyConvert.Currency_Convert.CurrencyCode::INR );
info(strFmt('%1', CLRInterop::getAnyTypeForObject(currency.get_Rate())));
}
catch(Exception::CLRError)
{
ex = CLRInterop::getLastException();
info(CLRInterop::getAnyTypeForObject(ex.ToString()));
}
}
上述工作运行良好,并在信息日志中产生结果。
现在,如果在批处理作业(扩展 Runbasebatch 类)的类下编写相同的代码,就像我们通常为任何批处理作业所做的那样,它会抛出错误:
Microsoft.Dynamics.Ax.Xpp.ErrorException:异常类型 'Microsoft.Dynamics.Ax.Xpp.ErrorException' 被抛出。
在 Dynamics.Ax.Application.BatchRun.runJobStatic(Int64 batchId) 中 BatchRun.runJobStatic.xpp:第 38 行
在 BatchRun::runJobStatic(Object[] )
在 Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(类型 类型、String MethodName、Object[] 参数)
在 BatchIL.taskThreadEntry(Object threadArg)
除了使用的 Web 服务之外的其他批处理作业正常工作。 我已经尝试了很多事情,例如:类的 RunOn 属性设置为“服务器”等。 我们使用的每个 Web 服务都是这种情况。 有人对此有适当的解决方案吗?
【问题讨论】:
-
您是否创建了从 AifDocumentService 扩展的类并为该类设置了批处理作业?
-
@Setiaji 据我所知,要在批处理作业中使用一个类,我认为我们必须创建扩展“RunBaseBatch”类的类。如果我错了,请纠正我??
-
没错,我告诉你你可以在扩展 AifDocumentService 类的类中测试你的脚本,并为这个类设置批处理作业。例如(在类声明中):class onHandServices extends AifDocumentService {}
-
hi @MohdSaddafkhan - 您的错误是仅在批处理队列中运行时引发的,还是您在通过批处理对话框手动运行时看到错误?
-
@AnthonyBlake - 只有在批处理队列中运行时才会出现问题,否则工作正常。
标签: batch-processing axapta x++ dynamics-ax-2012 dynamics-ax-2012-r2