Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call MTS methods in Javascript

Status
Not open for further replies.

BML

Programmer
Oct 24, 2000
37
PT
Hi,

I have an VB application that calls MTS methods (written with VC++).

Now I have to migrate the clients from VB to HTML, but the calls to the MTS components don't work, the out parameters always return indefined.

An practical example:

VC++ method:
Code:
HRESULT getName(/*[in]*/long cust_id, /*[out]*/BSTR *Name,/*[out]*/BSTR *msgErr, /*[out, retval]*/long res);
JavaScript call to MTS method:
Code:
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function xpto()
{
  var cust_id = 1000;
  var Name = String(&quot;&quot;);
  var msgErro = String(&quot;&quot;);
  
  var obj = new ActiveXObject(&quot;MyMTSComponent.MyClass&quot;);
  var Res = obj.getName(cust_id, Name, msgErro);

  alert(Name);
}
//-->
</SCRIPT>

The alert result is always: undefined

Why?

How can I get the Name parameter correctly?

regards,

Bruno Loureiro
<brunoloureiro@usa.net>
 
Bruno,

Does your COM Server have an IDispatch interface? That is required for scripting languages and VB as they cannot use a custom interface.

-pete
 
Palbano is correct when he states that COM servers MUST have an IDispatch interface to be called from script . . . this is because all calls in script are late bound (or would it be more correct to say that all calls in script are late bound because script MUST use IDispatch).
Be that as it may, there is one other possibility (assuming that your JScript is in an ASP page). ASP CAN NOT, by default, create an out of process object (which MTS objects are . . . the DLLs are inproc, but they are hosted be a surrogate process - MTX.EXE - and not IIS). You may need to change a setting in the registry to allow ASP to create an out of process component. Here is the RegKey from MSDN article Q172214) -


To allow out-of-process components, use Regedit to select the following key:


HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\W3SVC\ASP\Parameters


The Parameters key has several subvalues that control ASP. Make sure it has a subvalue named AllowOutOfProcCmpnts, and that this subvalue is set to 1.


I don't know if this is the exact problem that you were having, but it might be worth checking. Good Luck! :)

- Jeff Marler
(please note, that the page is under construction)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top