lunes, 30 de junio de 2014

AIF Woes: The class method for the specified action '%1' could not be found.

Error.

In AX 2009 after restoring the production server over the development one I found that none of my custom AIF services were working.  Curious, after having compiled and synchronised all.  Also more frustrating as the base AX AIF services that I have subsequently modified actually seem to work.

The first place to go was to change the web site that actually publishes the AIF beast and update those root values...  And don't forget to Validate that it works.
Base > Configuration > AIF > Web Sites
Updating and regenerating our services all appeared to go well...  But wait.  No service operations?
Base > Configuration > AIF > Services

We can find an error message, finally. by passing down the Extreme end point > Action directive methods.
An error message is generated moving down the list
Open up the message into the dev environment, and remember that the breakpoint is our friend here..
The class method for the specified action '%1' could not be found.
Here I identified that our ClassId was 30073, yet in my development environment it was identified as 30226

Looking directly in to the AifService and AifAction table (shared across companies), the DirContacPersonsService classId equated between the value in the table and the id of the class while my own classes did not have corresponding values with those of the table.  There was a difference for my custom classes!
Updating ClassId 30073 to 30226 in tables: AifService & AIFAction
Either I could ALT-F9 and delete these rows, then update/regenerate the services...  Or swallow a mouthful of whisky and directly update the ClassId value in the table...
UPDATE [DynamicsAxDEV].[dbo].[AIFACTION]
   SET [CLASSID] = 30226
 WHERE [ACTIONID] IN ( 'HIECustNameService.find', 'HIECustNameService.read')
GO

...And the result feels great!
Note the relationship between the AIFService ClassId reference between entities...

There are more steps however as the above 'CustomerName' service is one that is used across all companies, using a virtual company.

Cannot find the schema parameter.
Other services published via the company specific local end points has ClassIds stored in another entity,  AifEndpointActionParameterSchema.  Let's update those DocumentClassId fields but this is across multiple company instances.  Just remember that this table may be cached...

Identify the matching class from the source environment and update directly in SQL if you're already on your third whisky.  It'll all turn out okay in the end!

 UPDATE [DynamicsAxDEV].[dbo].[AIFENDPOINTACTIONPARAMETER2257]
SET DOCUMENTCLASSID = 30245
WHERE DOCUMENTCLASSID = 30123

Finally, avoid having to manually regenerate the fields published by the action directives by updating the AIFDataPolicy table....  There MAY be differences between the custom table field ids as well of course and it'll be inevitable to update these things by hand.

UPDATE [DynamicsAxDEV].[dbo].[AIFDATAPOLICY]
  SET DOCUMENTCLASSID = 30245
  WHERE DOCUMENTCLASSID = 30123
GO