Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

We can't call record static methods with Dynamics AX .NET Business Connector from PHP code (AX 4.0)

Posted on by Microsoft Employee

Good morning to everybody.

We have a problem and we need help from community.

We are trying to call a record static method from PHP code (PHP 7) with this code >

$fas = 'Microsoft.Dynamics.BusinessConnectorNet,Version="4.0.0.0",Culture="neutral",PublicKeyToken="31BF3856AD364E35"';
$fcn = 'Microsoft.Dynamics.BusinessConnectorNet.Axapta';
$axp = new DOTNET($fas,$fcn);
$company = '';
$language = '';
$objectServer = '';
$configuration = '';
echo $axp->Logon($company,$language,$objectServer,$configuration);
$Class = 'DOTNET';
$Method = 'areyouthere';
$Parm1 = '';
$Parm2 = '';
$Parm3 = '';
$r = $axp->CallStaticClassMethod($Class,$Method,$Parm1,$Parm2,'');
$axp->Logoff();

... and the error message is >

com_exception: Source: Microsoft.Dynamics.BusinessConnectorNet
Description: Error al ejecutar c�digo: Se ha llamado al m�todo con un n�mero no v�lido de par�metros. Seguimiento de pila (C)\Classes\DOTNET\areyouthere in C:\inetpub\InfoWeb\LogisticInfo\com.php:34 Stack trace: #0 C:\inetpub\InfoWeb\LogisticInfo\com.php(34): dotnet->CallStaticClassMethod('DOTNET', 'areyouthere', '', '', '') #1 {main}

Translation of Description Message > "Error to execute code: invalid number or parameters in call method".

We think that the main problem could be in PHP kernel or similar.

Any idea? Had someone tried call AX class static methods o record static methods from PHP?

Thanks in advance. We are hurry about that.

*This post is locked for comments

  • Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: We can't call record static methods with Dynamics AX .NET Business Connector from PHP code (AX 4.0)

    Unfortunately you talk about a very old version (12 years), so I don't remember it in detail, but I don't think you can pass three parameters to a method that doesn't expect any. An error like "Error executing code: The method has been called with an invalid number of parameters" is exactly what I would expect to happen - it's the correct behavior in my opinion.

    Therefore your problem seems to be that you don't know how to call the right method override via DOTNET class in PHP, which you should discuss in a PHP forum and not an AX forum. Have you tried using null instead of empty strings?

    Anyway, can you please confirm that you areyouthere() is defined on the DOTNET class in AX? It's a weird name, so I suspect a bit that you confused the X++ class with the DOTNET class in PHP.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: We can't call record static methods with Dynamics AX .NET Business Connector from PHP code (AX 4.0)

    Not. The question is CallStaticClassMethod, which has 5 different versions depending on the number of parameters, seem to be only accesible from php with the 5 parameter version, so we had to provide this extra parameters just only to make the call. The areyouthere method actually don't have any parameter. If we call CallStaticClassMethod with any different number of parameters we get "The parameter is not valid".

  • Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: We can't call record static methods with Dynamics AX .NET Business Connector from PHP code (AX 4.0)

    Does your code mean that you have an AX class called DOTNET with a public static method areyouthere() accepting three string parameters?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: We can't call record static methods with Dynamics AX .NET Business Connector from PHP code (AX 4.0)

    Perfect. Read. I'm sorry. I'll take in account next time. Thanks.

    (We need help!) :)

  • Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: We can't call record static methods with Dynamics AX .NET Business Connector from PHP code (AX 4.0)

    Hi Daniel, please separate individual tags with comma, words in tags with spaces and don't prefix tags with #. You attached a single tag #AX4.0 #PHP #BussinesConnector #Error, which I'm going to replace with two tags PHP and Business Connector (the version is already specified in the version tag and Error is too vague to be useful).

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans