Hello,
I am getting error in integration of CRM and AX through custom web service.
First what i have done is i made a WCF web service in which i referenced my AX AIF web service.
And then i call that WCF web service on my CRM form on save. In this way i am going to integrate AX with CRM.
I am putting some code here...
ax.SalesOrderServiceClient sc =new ax.SalesOrderServiceClient(); sc.ClientCredentials.Windows.ClientCredential.UserName="crmusername"; sc.ClientCredentials.Windows.ClientCredential.Password="crmpassword"; sc.ClientCredentials.Windows.AllowedImpersonationLevel=System.Security.Principal.TokenImpersonationLevel.Impersonation;// Create an instance of the document class. ax.AxdSalesOrder salesOrder =new ax.AxdSalesOrder();// Create instances of the entities that are used in the service and// set the needed fields on those entities. ax.AxdEntity_SalesTable salesTable =new ax.AxdEntity_SalesTable(); salesTable.CurrencyCode="INR"; salesTable.CustAccount="C-00000001"; salesTable.DeliveryDate=Convert.ToDateTime("11/28/2012");//salesTable.Payment = "100 %"; salesTable.PurchOrderFormNum="PO"; ax.AxdEntity_SalesLine salesLine =new ax.AxdEntity_SalesLine(); salesLine.ItemId="ITEM00000015"; salesLine.SalesQty=Convert.ToDecimal(10); salesLine.SalesUnit="NOS"; ax.AxdEntity_InventDim inventDim =new ax.AxdEntity_InventDim(); inventDim.configId ="--"; inventDim.InventColorId="0"; inventDim.InventSizeId="GENERAL";// Add the sub-entity instances to their parent entities as an array// of the sub-entity type. salesLine.InventDim=new ax.AxdEntity_InventDim[1]{ inventDim }; salesTable.SalesLine=new ax.AxdEntity_SalesLine[1]{ salesLine }; salesOrder.SalesTable=new ax.AxdEntity_SalesTable[1]{ salesTable };try{// Call the create method on the service passing in the document. ax.EntityKey[] returnedSalesOrderEntityKey = sc.create(salesOrder);// The create method returns an EntityKey which contains the ID of the sales order. ax.EntityKey returnedSalesOrder =(ax.EntityKey)returnedSalesOrderEntityKey.GetValue(0);returnstring.Format("The sales order created has a Sales ID of ",returnedSalesOrder.KeyData[0].Value);}catch(Exception e){returnstring.Format("Error Occurs :- {0}",e.StackTrace.ToString());}
I am getting error "Request Failed. See the Exception Log for details." at .create method call.
What can be done here.. Please help.