I am trying to use Microsoft's Speech Platform 11 through PHP's DOTNET object
https://msdn.microsoft.com/en-us/library/jj127858.aspx
The platform should be instantiated as follows
$platform = new DOTNET("assembly-name", "Microsoft.Speech.Recognition");
But how to retrieve the assembly name for Speech Platform 11? (to replace "assembly-name" in the initialization call)
I have tried several assembly names by... guesswork, obviously with no luck.
The initialization error being thrown
Failed to instantiate .Net object [CreateInstance] [0x80070002] The system cannot find the file specified
UPDATE
With the following code, I was able to get PHP to find and use the assembly
$full_assembly_string = 'Microsoft.Speech, Version=11.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35';
$full_class_name = 'Microsoft.Speech.Recognition.SpeechRecognitionEngine';
$interface = new DOTNET($full_assembly_string, $full_class_name);
However, there's a new roadblock:
Failed to instantiate .Net object [Unwrapped, QI for IDispatch] [0x80004002] No such interface supported
At first glance it seems it has to do with COM visibility. But if for any reason the class isn't visible to COM (and it seems odd), how to change this? Is it even possible?
Not tested. Just another guess.
According to the Microsoft Speech Platform SDK 11 Docs:
https://msdn.microsoft.com/en-us/library/microsoft.speech.recognition.speechrecognitionengine.aspx
i would give this a try:
"assembly" Microsoft.Speech
"classname" Microsoft.Speech.Recognition.SpeechRecognitionEngine
Microsoft.Speech.Recognition is only the namespace
$sre = new DOTNET(
'Microsoft.Speech',
'Microsoft.Speech.Recognition.SpeechRecognitionEngine'
);
Methods are documented here: https://msdn.microsoft.com/en-us/library/microsoft.speech.recognition.speechrecognitionengine_members(v=office.14).aspx#Anchor_2
Related
I want to do some stuff in some ms word documents using PHP (mostly search-replace), and I've discovered the COM class. But I have a question (because I'm also relative new on PHP), how can I found all methods related to word for example:
$objBookmark = $word->ActiveDocument->Bookmarks($bookmarkname);
$range = $objBookmark->Range;
How should I now about ActiveDocument, Bookmarks, Range...etc. Is there any way to have a list with all this?
To have autocomplete (InteliSense) you need a PHP class model and a good IDE. This will make your work much much easier.
One of the best IDE's I have come acrross is PHP Tools for Visual Studio. Look for it in the Visual Studio plugin gallery or in the Devsense website. You can use Visual Studio for FREE with the community edition.
To generate a PHP based class model you can either use the COM built in function:
com_print_typeinfo ( object $comobject [, string $dispinterface [, bool $wantsink = false ]] )
Or the NetPhp component (this link is to a step by step example with Word Interop) that will dump all types inside the binary to a complete PHP based class model:
http://www.drupalonwindows.com/en/blog/php-com-class-consuming-net-php
You can also use NetPhp to directly consume the OpenXML binaries and manipulate Word documents without Interop:
http://www.codeproject.com/Tips/994905/Edit-Word-Documents-using-OpenXML-and-Csharp-Witho
Trying to use the Microsoft's .NET classes from System.Security.Cryptography.X509Certificates located in System assembly raises the following error:
$certificate2 = new DOTNET('System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089', 'System.Security.Cryptography.X509Certificates.X509Certificate2');
com_exception: Failed to instantiate .Net object [Unwrapped, QI for IDispatch] [0x80004002] No such interface supported
in ...\test.php on line 2
Whereas the following calls do work and return DOTCOM instances.
$certificate = new DOTNET('mscorlib', 'System.Security.Cryptography.X509Certificates.X509Certificate');
$form = new DOTNET('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089', 'System.Windows.Forms.Form');
Is there something special to System.dll or its classes contained in System.Security.Cryptography.X509Certificates?
Why could this file or classes not be usable?
digging deeper
The Exception origins to a failed method call in php_dotnet extension source code, line 250. But this is too low level for me. The call is:
hr = IUnknown_QueryInterface(V_UNKNOWN(&unwrapped), &IID_IDispatch, &V_DISPATCH(&obj->v));
side notes
PHP version is 5.5.5
this happens on a Windows 7 and Windows Server 2008 R2 box
the assembly seems to accessed correctly, but classes can not be found
selected .NET Framework Version is 2.0.0.0 (<=3.5), because PHP DOTNET does not work with Version >= 4
Cryptography classes from mscorlib do not suffice, because of limited functionality
Try this.It's working for me
<?php
$stack = new DOTNET("mscorlib", "System.Collections.Stack");
$stack->Push(".Net");
$stack->Push("Hello ");
echo $stack->Pop() . $stack->Pop();
?>
The link for the doc, Click here
i am working on AMFPHP and i had this problem
-> i am using XAMPP server with AMFPHP gate way for flex and this is working well for returning values from PHP
->the problem is how can i get the object in php which i passed to the pap class using flex code is here:-
connection.objectEncoding = ObjectEncoding.AMF3;
connection.connect("http://localhost/flashservices/gateway.php");
var obj:Employ = new Employ(inputs.ename.text,inputs.occu.text,inputs.adder.text,inputs.ph.text );
var responder = new Responder(recvdata,recverror);
connection.call("Employ.employrecord.employdata.insertrecord",responder,obj);
the obj is a employ class object and i want to get it in php class but how "need help"
thanx in advance
AMFPHP will handle the heavy lifting of converting the Flash/Flex data structures into PHP equivalents. At most you should just define a service handler and provide the appropriate arguments for the method so AMF can pass the client-side data to the PHP handler.
There's a decent example of both sides of the process here.
I wish to call a web service, using SOAP, from PHP (using the included SOAP extension). The web service in question is http://www.webservicex.net/CurrencyConvertor.asmx
Now the Currency type is an enum, and I cannot figure out how to work with these in PHP in order to be able to call the 'ConversionRate' function. I know I have to do something with a class map, but I can only find limited and unhelpful information on this topic. Can anyone help? A working example maybe?
Thanks!!!!
The enum here only defines legitimate values, that is your data type is actually a string of one of those values.
Here's some psuedo-code to get you on your way:
$from_currency = "AFA";
$to_current = "ALL";
$soap_handler->ConversionRate($from_currency, $to_currency);
$exchange_rate = $soap_handler->response();
I'm using the native SOAP class in PHP 5, having changed from NuSOAP as the native class is faster (and NuSOAP development seems to have ceased). However the PHP 5 SOAP lacks the ability to generate WSDL.
Has anyone experience of generating WSDL in PHP? If so, please recommend your preferred method.
Thanks.
Stuart,
If you or anyone else is looking for a solution to this problem here's what I did.
First get this script: http://www.phpclasses.org/browse/download/zip/package/3509/name/php2wsdl-2009-05-15.zip
Then look at its example files. After that I just sliced it the way I needed because I'm using codeigniter:
function wsdl(){
error_reporting(0);
require_once(APPPATH."/libraries/WSDLCreator.php"); //Path to the library
$test = new WSDLCreator("Webservice", $this->site."/wsdl");
//$test->includeMethodsDocumentation(false);
$test->addFile(APPPATH."/controllers/gds.php");
$test->addURLToClass("GDS", $this->site);
$test->ignoreMethod(array("GDS"=>"GDS"));
$test->ignoreMethod(array("GDS"=>"accessCheck"));
$test->createWSDL();
$test->printWSDL(true); // print with headers
}
That it, your all done.
Btw, I'm using SoapServer and SoapClient in php5+
You can try these options:
- https://code.google.com/p/php-wsdl-creator/ (GPLv3)
- https://github.com/piotrooo/wsdl-creator/ (GPLv3)
- http://www.phpclasses.org/package/3509-PHP-Generate-WSDL-from-PHP-classes-code.html (BSD like)
The first one might be your best option if the licence fits your project.
Generating a WSDL on the fly is not something that happens very often - it would tend to raise a few questions about the stability of your service!
Zend Studio can generate a WSDL from a PHP class, and there are a few other similar tools.
If you do need to generate the WSDL dynamically, take a look at Zend Framework library: Zend_Soap_AutoDiscover
Zend_Soap_AutoDiscover is a good alternative to NuSOAP. But, you can also create the WSDL file from scratch which can be very complicated and error prone. To ease this process, you can use an IDE to generate the WSDL file for your PHP functions and pass it as a parameter to your PHP SoapServer class. Check out the complete tutorial on How to generate wsdl for php native soap class