Skip to main content
Known Participant
February 5, 2012
Question

Connecting to COM objects

  • February 5, 2012
  • 4 replies
  • 2099 views

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!

    This topic has been closed for replies.

    4 replies

    PreservedAuthor
    Known Participant
    February 7, 2012

    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

    BKBK
    Community Expert
    Community Expert
    February 8, 2012

    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".

    PreservedAuthor
    Known Participant
    February 6, 2012

    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.

    Community Expert
    February 6, 2012

    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

    Dave Watts, Eidolon LLC
    Community Expert
    February 6, 2012

    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

    Dave Watts, Eidolon LLC
    BKBK
    Community Expert
    Community Expert
    February 6, 2012

    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!

    Community Expert
    February 6, 2012

    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

    Dave Watts, Eidolon LLC
    BKBK
    Community Expert
    Community Expert
    February 5, 2012

    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.

    PreservedAuthor
    Known Participant
    February 5, 2012

    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

    Community Expert
    February 6, 2012

    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

    Dave Watts, Eidolon LLC