Consuming a Web Service in AX 2012
在AX2012版本中如果想调用外部的Web Service变得非常容易。
第一步,在VS中创建一个Web Service并发布
第二步,创建一个Class Library,并将创建的Web Services引用到该类库当中,并ADD to AOD中
第三步,用JOB调用该Web Services,运行Job
static void KimConsumeWebService(Args _args) { ClassLibrary1.Class1 webService; ClassLibrary1.ServiceReference1.WebService1SoapClient clients; System.ServiceModel.Description.ServiceEndpoint endPoint; System.ServiceModel.EndpointAddress endPointAddress; System.Type type; System.Exception ex; ; try { type = CLRInterop::getType('ClassLibrary1.ServiceReference1.WebService1SoapClient'); clients = AifUtil::createServiceClient(type); print clients.Kim(); pause; } catch(Exception::CLRError) { ex = CLRInterop::getLastException(); while(ex) { info(CLRInterop::getAnyTypeForObject(ex.ToString())); ex = ex.get_InnerException(); } } }