Home
Extended ECM
API, SDK, REST and Web Services
Calling .Net/COM Object from OScript
Prasad_Apte_(PrasadApte_(Delete)_3848183)
HiI am wondering if we can call .NET component or COM component from the OScript. From the OScript reference, it looks like we cannot do that.Any help is appreciated.ThanksThanga
Find more posts tagged with
Comments
Donna Nalls
I think you will have to write a dropin. I don't have any experience in this arena. Do some research on dropins -- or, hopefully, someone with that experience will respond to your message.I have on occasion made calls to windows apps from Oscript, using MSWindows.WinExec(), but, because it is an asynchronous call - there is no way to return results from the windows app back to your oscript. ;o( i don't think you see the documentation for this class package when you access Help from Builder...go to your builder/documentation directory and navigate down to packages/mswindows.htmlBest,Donna
Magnus_S_(novnoruser_-_(deleted))
Directory Service moduleHave a drop in I think for requesting information from the Directory. The Corba module was a way before to request information from outside.... Have not seen it used to much I think the correct way forward is to use Livelink Java....but I havn't tested it RegardsMagnus
Krishnankutty_Nair
like dnalls says there are undocumented methods.I enclose a script that works ..... well to make a point.I have never been able to use the method's of the activex object which I created.If somebody can tell me if that's possible I will be grateful.The script will run in any livelink request handler.
David_Forbes_(dforbes_-_(deleted))
An alternate approach....Both as ASP.net and ASP application objects can be called from Oscript, via a URL redirection. The target ASP.net application must (eventually) return a URL which a LL request handler can work with.David
Prasad_Apte_(PrasadApte_(Delete)_3848183)
I just tried to open the Notepad.exe using MSWindows.WinExec() and it works. However, Activex.CreateObject() fails even for Scripting.FileSystemObject(). I tried my own simple COM object and that also fails.Do I need to orphan any modules? I prefer to go for COM object.
Krishnankutty_Nair
For almost five years I have been a memebr of this knowledge base I am yet to see a sample that calls windows executables from oscript.The indirect methods are url re-direction,corba(?), even there is a perl example (John Shoun) has provided.What that tells me is OT does not necessarily advocate calling COM from oscript.There is something called 'dropins' if you are so inclined you need to get a special package from OT and develop dropins.The script I put there yesterday works on my machine(simple winxp prof) so I suspect problematic permissions on your machine.Having said that I really don't think it gives you any more.Atleast I could not use any of the com methods once it was created.The easiest way for you to have best of both worlds is to use Livelink API for .Net where you get to work with objects of the windows system and the livelink objects too.Also you can probably raise a ticket with support and who knows they may very well help you
Prasad_Apte_(PrasadApte_(Delete)_3848183)
Hi All,Thanks for your help. Atlast I could make the OScript to call my COM Component successfully. Here is the code snippet which works for me.Dynamic myComObjActiveX.Initialize() <-- You have to call Initialize otherwise it will not work.myComObj = ActiveX.CreateObject("LiveLinkTest.MyCOMObj") <-- Prog ID of my COM Object.myComObj.MyTestMethod() <--- Call you COM object method.ActiveX.UnInitialize()ThanksThanga
eLink User
Message from Nair, Krishnankutty N. via eLinkSo any idea where I am going wrong ActiveX.Initialize() MyFileObject=activex.CreateObject("Scripting.FileSystemObject") writeFile="c:\\temp\\test.xls" MyTextFile=MyFileObject.CreateTextFile(writeFile,true) //Upto this it will work //allright the file will be created //but you can't do anything with it //because the next lines don't work MyTextFile.WriteLine("lets see if this works") MyTextFile.closeIt hangs at the WriteLine methodThanks MuchKrishnankutty N NairWork 918-661-5824 Fax:918-661-9206Learn more about EDMS powered by Livelink at
http://edms.conoco.net/edms.htm-----Original
Message-----From: eLink Discussion: Development Discussion[mailto:development@elinkkc.opentext.com] Sent: Wednesday, May 04, 2005 1:05 PMTo: eLink RecipientSubject: COM Works !!!COM Works !!!Posted by PrasadApte on 05/04/2005 02:00 PMHi All,Thanks for your help. Atlast I could make the OScript to call my COMComponent successfully. Here is the code snippet which works for me.Dynamic myComObjActiveX.Initialize() <-- You have to call Initialize otherwise it willnot work.myComObj = ActiveX.CreateObject("LiveLinkTest.MyCOMObj") <-- Prog ID ofmy COM Object.myComObj.MyTestMethod() <--- Call you COM object method.ActiveX.UnInitialize()ThanksThanga[To reply to this thread, use your normal E-mail reply function.]============================================================Topic: Calling .Net/COM Object from OScript
https://knowledge.opentext.com/knowledge/livelink.exe?func=ll&objId=3968260&objAction=viewDiscussion
: Development Discussion
https://knowledge.opentext.com/knowledge/livelink.exe?func=ll&objId=786303&objAction=viewLivelink
Server:
https://knowledge.opentext.com/knowledge/livelink.exe
Prasad_Apte_(PrasadApte_(Delete)_3848183)
Krishna,It fails for me also at the WriteLine() for FileSystemObject. But with my COM Component I am able to call all the Methods without any problem. My theory here is that the CreateTextFile() returns a "TextStream" Object. Since the TextStream is not a COM object and so the Livelink is not able to resolve the method("WriteLine") call. In fact all the call on the object returned by CreateTextFile() will fail. These guys mostly will use the IDispatch methods to call a method. So, blindly the will try to call "GetIdsByname()" which will fails for TextStream Object.-Thanga
eLink User
Message from Nair, Krishnankutty N. via eLinkNot bad.So you basically wrapped what you need in your COM objectrather than relying on well published methods.That is probably whatDonna meant by the asynchronous thingWell if it works then this may be an alternativeThanks MuchKrishnankutty N NairWork 918-661-5824 Fax:918-661-9206Learn more about EDMS powered by Livelink at
http://edms.conoco.net/edms.htm-----Original
Message-----From: eLink Discussion: Development Discussion[mailto:development@elinkkc.opentext.com] Sent: Wednesday, May 04, 2005 2:01 PMTo: eLink RecipientSubject: Krishna,Krishna,Posted by PrasadApte on 05/04/2005 02:56 PMKrishna,It fails for me also at the WriteLine() for FileSystemObject. But withmy COM Component I am able to call all the Methods without any problem. My theory here is that the CreateTextFile() returns a "TextStream"Object. Since the TextStream is not a COM object and so the Livelink isnot able to resolve the method("WriteLine") call. In fact all the callon the object returned by CreateTextFile() will fail. These guys mostlywill use the IDispatch methods to call a method. So, blindly the willtry to call "GetIdsByname()" which will fails for TextStream Object.-Thanga[To reply to this thread, use your normal E-mail reply function.]============================================================Topic: Calling .Net/COM Object from OScript
https://knowledge.opentext.com/knowledge/livelink.exe?func=ll&objId=3968260&objAction=viewDiscussion
: Development Discussion
https://knowledge.opentext.com/knowledge/livelink.exe?func=ll&objId=786303&objAction=viewLivelink
Server:
https://knowledge.opentext.com/knowledge/livelink.exe
Trach_Van
writing to a socket server may be an alternative. SeeClass Socket.synchronous calls can be made to the Socket Server app which hosts the COM...
Trevor_Smith
They will work wonderfully in the Builder, but they can get screwed up in the regular muilti-threaded environment. You will need to construct the socket connections and calls in a Singleton, which then has performance implications.