Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Tuned Listener
kr123456
Posts: 25
Country: France
Message 1 of 19 (2,669 Views)
Accepted Solution

Using ACT Framework with PHP via COM Interop ?

Is it even possible ? If it is, where to begin ?

 

For example, I heard that in order to be used with PHP COM Interop, the .NET assemblies (so here the Act dlls) must have their "ComVisible" attribute set to True. Is it the case ?

 

Anyway, does someone have some leads about using ACT framework with PHP ?

 

Thanks

Please use plain text.
Employee
alduet
Posts: 888
Country: USA
Message 2 of 19 (2,632 Views)

Re: Using ACT Framework with PHP via COM Interop ?

In general all public type members are exposed as visible from a .Net assembly by default to COM.  the ComVisibleAttribute is meant as a means to mark a certain member as not available to COM (so you'd use it to explicitly hide something from COM rather than allow access by COM).  

 

Are you using PHP on Windows?  What's your web host for PHP?  Is this all installed on the same machine as your ACT! client install?  I think getting PHP/COM interop assemblies to work with .Net ACT! framework assemblies is less of a problem than understanding where all of these components will reside on your production systems.  

Allen Duet
Please use plain text.
Tuned Listener
kr123456
Posts: 25
Country: France
Message 3 of 19 (2,612 Views)

Re: Using ACT Framework with PHP via COM Interop ?

Thanks a lot for your answer.

 

In fact, in order to do local tests, all these elements reside on my own machine for now, which is running on Windows ;

 

I use EasyPHP 1.7 (with PHP 4.3.3), with ACT! 2010, both installed on my own machine. I made an integral copy of the websites and their mysql databases (which my PHP application will interact with) on my machine too.

 

In the future this PHP application will be stored on a local server (running also on Windows) with the ACT main database and ACT .NET framework, and will interact with the real websites databases hosted on a Nuxit server.

 

I can handle the mysql part, but the COM interop is a little more tricky for me. I also heard of a PHP 5 class called "DOTNET", could it be more adapted to ACT framework than COM ?

 

Anyway, thanks for your help.

Please use plain text.
Employee
alduet
Posts: 888
Country: USA
Message 4 of 19 (2,595 Views)

Re: Using ACT Framework with PHP via COM Interop ?

[ Edited ]

Cool, I like these kinds of projects! I think you may have to  register the ACT! assemblies you want to use in your project using the regasm.exe in the .Net root driectory, this will make the .Net assembly a registered COM reference. Once your assembly is registered I think...  

 

My PHP is pretty rusty but I think you just need to do something like: 

 

<? 
$MyObject = new COM ("ACT.Framework.NameSpace.Class");
 
$MyObject->Input = "Argument";
 

echo "Input : $MyObject->Input";
 
echo "<BR>OutPut : $MyObj->methodx";
 
?>
  

 

I have no way to test this currently and the italicised items are referential, but hope this gives you an idea.

Message Edited by alduet on 06-10-2010 10:18 AM
Allen Duet
Please use plain text.
Tuned Listener
kr123456
Posts: 25
Country: France
Message 5 of 19 (2,573 Views)

Re: Using ACT Framework with PHP via COM Interop ?

[ Edited ]

Thanks for your lead. I couldn't manage to instanciate an "Act.Framework.ActFramework", but then I used regasm.exe and registered the Act.Framework.dll.

 

Now the instanciation works. But I noticed a little problem with the log-on part ;

 

<?

$actFramework = new COM("Act.Framework.ActFramework");     // Now working thanks to regasm.exe Act.Framework.dll

$actFramework->LogOn("C:\\...\\ACT2010Demo.pad");

?>

 

The line above is working, I manage to log on to the database without specifying a user name nor a password (by default it logs as "Chris Huffman" and doesn't ask password). Allright!

 

So I came into ACT! users configuration and tried to put a password for Chris Huffman. Then of course the LogOn line doesn't work anymore, so I wanted to use an overload of this method to specify which user and password to use ;

 

<?

$actFramework->LogOn("C:\\...\\ACT2010Demo.pad", "Chris Huffman", "test");

?>

 

The matter is, this overload is working under Visual C# Express, but doesn't seem to in PHP. It shows me this error :

 

"Fatal error: Uncaught exception 'com_exception' with message 'Error [0x8002000e]...." and tells me that number of parameters is incorrect.

 

It seems that the COM instanciated ActFramework has imported only one definition of the LogOn method ?

 

If not, how could I specify which overload I want to use ? Or is there something I missed to do ?

 

----

 

Edit : well, I think I know why I have this error ; I found out that in PHP the overloading of method can't be done the same way that in .NET (must use something like __call() for instance).

 

That's good to know if you are developping you're own classes, but in my case I just import .NET classes which posess already overloaded methods...

 

So I deduce that during the wrapping by COM interop, only the first definition of each method is preserved. I didn't found any clear explanation on the subject, though.

 

Does someone know more about that ?

 

 

Message Edited by kr123456 on 06-11-2010 05:30 AM
Message Edited by kr123456 on 06-11-2010 05:31 AM
Please use plain text.
Employee
alduet
Posts: 888
Country: USA
Message 6 of 19 (2,539 Views)

Re: Using ACT Framework with PHP via COM Interop ?

When regasm builds its COM magic, it automatically appends a suffix of _2, _3, etc. to any overloaded methods.

 

So try LogOn_2(....)

Allen Duet
Please use plain text.
Tuned Listener
kr123456
Posts: 25
Country: France
Message 7 of 19 (2,507 Views)

Re: Using ACT Framework with PHP via COM Interop ?

Thanks Allen, I didn't manage to find this crucial information anywhere else !

 

I tested it and it works pretty well. For now it's all that I need, but I'll surely come back with others questions...

 

In the meantime, I wish you a nice week.

 

Kevin

Please use plain text.
Tuned Listener
kr123456
Posts: 25
Country: France
Message 8 of 19 (2,442 Views)

Re: Using ACT Framework with PHP via COM Interop ?

Hi,

 

Here I come again with another problem about using Act Framework in PHP via COM Interop. In the example :

 

$actFramework = new COM("Act.Framework.ActFramework");

 

The line above works fine, and I think the COM wrapper calls the constructor ActFramework() in order to instanciate the object.

 

But now I need to instanciate a class that doesn't have a default constructor (constructor without any parameter) : this class is Act.Framework.Lookups.Criteria.

 

I must create these objects to implement criterias, in order to search contacts by name, etc. So how am I supposed to do ?

This line :

 

$criteria = new COM("Act.Framework.Lookups.Criteria");  

 

doesn't work (syntax error due, I suppose, to the lack of default constructor), and I can't find a way to give the correspondant parameters to the COM class. Should I deduce that COM can only instanciate classes that posess a default constructor ? Or is there a way to have my criterias instanciated ?

 

Also tell me if I shoud create another thread for this problem.

Thanks for your answers.

 

 

Please use plain text.
Employee
alduet
Posts: 888
Country: USA
Message 9 of 19 (2,428 Views)

Re: Using ACT Framework with PHP via COM Interop ?

 

Have you tried using the DOTNET class of PHP? 

 I think it would look something like:

 

$criteria = new DOTNET("Act.Framework", "Lookups.Criteria");  

 

You still have the same problem with default constructors (if that's your problem), but I'm wondering if it's any smarter than just the COM Class...

 

 

Allen Duet
Please use plain text.
Tuned Listener
kr123456
Posts: 25
Country: France
Message 10 of 19 (2,428 Views)

Re: Using ACT Framework with PHP via COM Interop ?

Thanks for the advice, but I just tried the line you wrote, and it doesn't work. (Also, I've already tried this DOTNET class before to instanciate an ActFramework, and couldn't manage to make it work neither)

 

The error is :  "Failed to instantiate .Net object [CreateInstance] [0x80070002]" followed by something like "specified file cannot be found".

 

Same problem with :

 

 $criteria = new DOTNET("Act.Framework.Lookups", "Criteria"); 

 

And indeed, my problem still the default constructor of the Criteria class, which is not directly accessible, and then prevents instanciation of any Criteria.

 

If this can't be resolved, is there another way to get contacts by name, company or email ? Perhaps it could works with COM Interop...

 

Thanks for your help.

Please use plain text.