• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Connecting to COM objects

New Here ,
Feb 05, 2012 Feb 05, 2012

Copy link to clipboard

Copied

Hi everyone,

I've got a project on the horizon that involves using an API to access a database. The API uses COM objects. 

Can I connect to the API using <cfobject> like this:

<cfobject 

    class = "program ID"

    name = "myneatobject"

    action = "connect"

    context = "remote"

    server = "http://someserverip">

    type = "com">

If the server is remote, isn't there some security involved? Login credinentials?  I'm trying to ge my head around this.  There's an exisiting website in place using the API, however we're planning on redoing everything in CF. 

Thanks for any tips in to set me straight!

Views

1.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 05, 2012 Feb 05, 2012

Copy link to clipboard

Copied

Yes, cfobject is one possible way to connect to a COM object. The assumption is that ColdFusion already has access to the server hosting the COM object. So it is up to you to ensure ColdFusion has the right security credentials.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 05, 2012 Feb 05, 2012

Copy link to clipboard

Copied

Hmm. So, does ColdFusion need to be on the same server as the server hosting the COM object?  If not, then can the CFadmin (running the website) be set to connect to the remote server hosting the COM object? Is this configured in the CFadmin "Data&Services>Web Services"??

"ColdFusion lets you register web services so that you do not have to specify the entire Web Services Description Language (WSDL) URL when invoking the web service. ColdFusion automatically registers WSDL URLs the first time they are referenced."

Webservice Name

ESDL URL

Username

Password

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 05, 2012 Feb 05, 2012

Copy link to clipboard

Copied

Hmm. So, does ColdFusion need to be on the same server as the server hosting the COM object?

With CF 5 and earlier, it was possible to register a remote DCOM service on the machine running CF, and have CF invoke that. I have no idea whether that's possible with newer versions of CF, as the way they interact with COM is quite a bit different.

Is this configured in the CFadmin "Data&Services>Web Services"??

"ColdFusion lets you register web services so that you do not have to specify the entire Web Services Description Language (WSDL) URL when invoking the web service. ColdFusion automatically registers WSDL URLs the first time they are referenced."

No. SOAP web services are an entirely different thing. Perhaps whoever created the COM API also created a SOAP API, though.

Dave Watts, CTO, Fig Leaf Software

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 06, 2012 Feb 06, 2012

Copy link to clipboard

Copied

Dave Watts wrote:

Hmm. So, does ColdFusion need to be on the same server as the server hosting the COM object?

With CF 5 and earlier, it was possible to register a remote DCOM service on the machine running CF, and have CF invoke that. I have no idea whether that's possible with newer versions of CF, as the way they interact with COM is quite a bit different.

It is possible.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Feb 06, 2012 Feb 06, 2012

Copy link to clipboard

Copied

It is possible.

More info might be useful here. I was with Dave on this one, I thought you'd have to write a CF webservice as a proxy, which connected locally to a COM object and exposed it via a CFC. Luckily it's not 1998 so I rarely have to use COM objects any more.

I'd suggest the OP just gives it a go; there are so many reasons it may or may not work I'm not sure you'll ever get a clear answer.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 06, 2012 Feb 06, 2012

Copy link to clipboard

Copied

Owain North wrote:

It is possible.

More info might be useful here. I was with Dave on this one, I thought you'd have to write a CF webservice as a proxy, which connected locally to a COM object and exposed it via a CFC. Luckily it's not 1998 so I rarely have to use COM objects any more.

For more info, see the section Registering Objects in this book chapter about extending ColdFusion with COM. See also this previous ColdFusion forum thread containing example code for a local COM object.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 05, 2012 Feb 05, 2012

Copy link to clipboard

Copied

I've got a project on the horizon that involves using an API to access a database. The API uses COM objects.

I'm sorry to hear that. I would look to see if there are any alternative approaches that might work better. And practically anything will work better. Is there a Java API? How about .NET? Or, how about accessing the database directly via JDBC? COM objects have never worked well with CF, and they work less well from newer versions of CF than they did with older versions.

Can I connect to the API using <cfobject> like this:

<cfobject 

    class = "program ID"

    name = "myneatobject"

    action = "connect"

    context = "remote"

    server = "http://someserverip">

    type = "com">

Almost certainly, no. To connect to COM objects on a remote server, those objects have to support DCOM ("Distributed COM"). In almost all likelihood, these are not DCOM objects. If they were DCOM objects, you wouldn't be able to use an HTTP URL to refer to the server anyway - CF doesn't support that, and many DCOM servers don't support that either.

If the server is remote, isn't there some security involved? Login credinentials?  I'm trying to ge my head around this.  There's an exisiting website in place using the API, however we're planning on redoing everything in CF.

This would be a matter of how DCOM is configured, and the user account with which CF itself is logged in. By default, CF runs as SYSTEM, which isn't really an account at all and has no network privileges.

Dave Watts, CTO, Fig Leaf Software

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 06, 2012 Feb 06, 2012

Copy link to clipboard

Copied

Dave Watts wrote:

Can I connect to the API using <cfobject> like this:

<cfobject 

    class = "program ID"

    name = "myneatobject"

    action = "connect"

    context = "remote"

    server = "http://someserverip">

    type = "com">

Almost certainly, no.

I would say, almost certainly, yes!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 06, 2012 Feb 06, 2012

Copy link to clipboard

Copied

Can I connect to the API using <cfobject> like this:

<cfobject 

    class = "program ID"

    name = "myneatobject"

    action = "connect"

    context = "remote"

    server = "http://someserverip">

    type = "com">

Almost certainly, no.

I would say, almost certainly, yes!

I didn't know you could use that syntax for the SERVER attribute, so thanks!

Dave Watts, CTO, Fig Leaf Software

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 06, 2012 Feb 06, 2012

Copy link to clipboard

Copied

Thanks Guys.

To be sure I'm describing this properly, I've got the manual for the API (updated in 2009) and it states

"The  API is a COM+ application (formerly MTS). It

provides a set of COM objects that can be manipulated by COM-

compliant development tools such as Visual Basic, Visual C++, Visual

C#, VSTA and so on.

The API provides the ability to search and locate accounts across

multiple  databases. It uses an advanced data cache mechanism to

minimize round-trips to database servers.

Once the account is located using a 10-digit telephone, and

optionally an account number, each subsequent attempt to connect to an

database requires a company number as well as a valid account

number."

The following example shows how to modify an existing user profile information:

Dim objUserProfile as Object

Dim lRetCode as Integer

Set objUserProfile = CreateObject("EnergyAPI.cUserProfile")

lRetCode = objUserProfile.ModifyUserInfo (sEmailAddress,

sPassword,sName,sPAsswordHint,sHintAnswer,lPreferences,cSysUser)

If lRetCode <> 0 Then

  ‘ Failure - Display error message

  Else

    ‘ Success

  End If

COM+ much different than COM?? Not from what I'm reading.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 06, 2012 Feb 06, 2012

Copy link to clipboard

Copied

COM+ much different than COM?? Not from what I'm reading.

COM+ applications run within a transaction service on a single machine. This is actually good news, as most COM+ applications are designed to be used remotely. If I recall correctly, you'll need to run dcomcnfg.exe on your client to register the DCOM server.

I'd still look for alternatives if they exist, as COM applications don't generally run well under CF.

Dave Watts, CTO, Fig Leaf Software

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 07, 2012 Feb 07, 2012

Copy link to clipboard

Copied

Well, as I stumble through this I find some additional documentation for the API that states:

"SConnect  is a collection of web-services that allow external

applications to programmatically exchange data with the

system. It uses XML documents to move data into and

out of the database(s), this allows SConnect to provide

back office integration to any application capable of creating or

consuming these XML documents.

SConnect offers support for web service com-

munication based on the WS-I basic profile 1.1 (WS-BP 1.1)

specification, this includes standards such SOAP 1.1, WSDL 1.1,

and message security 1.0. It uses HTTP for the transport and of-

fers interoperability across heterogeneous systems."

So, should I be able to SOAP requests?

It just does not look that way. The docs have this example:

Dim objUserProfile as Object

Dim lRetCode as Integer

Set objUserProfile = CreateObject("EnergyAPI.cUserProfile")

lRetCode = objUserProfile.ModifyUserInfo (sEmailAddress,

sPassword,sName,sPAsswordHint,sHintAnswer,lPreferences,cSysUser)

If lRetCode <> 0 Then

  ‘ Failure - Display error message

  Else

    ‘ Success

  End If

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 07, 2012 Feb 07, 2012

Copy link to clipboard

Copied

LATEST

In my opinion, that is the wrong example. It falis to show how to "programmatically exchange data with the  system.". Yes, you should be able to use SOAP. After all, the documentation says, "SConnect  is a collection of web-services...offers support for web service communication based on the WS-I basic profile 1.1 (WS-BP 1.1) specification".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation