# Calling a CORBA Object

In the CFOBJECT tag, several key attributes are required for calling CORBA objects:

- Set the TYPE attribute to CORBA. If no TYPE is specified, COM is assumed.
- The CONTEXT attribute shows how the object reference is obtained. Set the CONTEXT either to "IOR" for a file containing the object's unique Interoperable Object Reference or to "NameService".
- If the CONTEXT attribute is set to IOR, set the CLASS attribute to the file containing the stringified version of the IOR. ColdFusion must be able to read this IOR file at all times, so it should be local to the server or on the network in an accessible location.
- If the CONTEXT attribute is set to a NameService, the CLASS attribute must include a period-delimited name such as Allaire.Department.Dev. Currently ColdFusion can only resolve objects registered in VisiBrokers's Naming Service. This will change when ORB vendors implement the CORBA 3.0 specification. Make sure that the NamingService (NS) is brought-up with a default NamingContext. The server implementing the object should bind to the default context, and register the appropriate name. ColdFusion also binds to the default context to resolve the name.
- Set the NAME attribute to the name your application uses to call the object's operations and attributes.

See the CFML Language Reference for the complete CFOBJECT syntax.

## Declaring structures and sequences

Once the object is created, attributes and operations on the object can be invoked using the syntax outlined in the above sections. In addition, ColdFusion also supports the use of complex types such as structures and sequences. For structures, use ColdFusion structures. For sequences, use ColdFusion arrays.

### Example

The IDL for an object

    struct SimpleStruct
    {
      short s;
      long l;
      float d;
    };

    struct NestedStruct
    {
      SimpleStruct f;
      char c;
      string s;
    };

    typedef sequence<long, 5> BLongSequence;

    interface SomeObject {
      short SomeMethod( in NestedStruct inStruct,  in BlongSequence inSeq);

    };

The applicable ColdFusion code

    <!--Declare a couple of structures -
    <CFSET x = StructNew()>
    <CFIF IsStruct(x)>
        <CFSET temp=StructInsert(x,"s",3)>
        <CFSET temp=StructInsert(x,"l", 256)>
        <CFSET temp=StructInsert(x,"d", 93.45)>
    </CFIF>

    <CFSET NestedStruct = StructNew()>
    <CFIF IsStruct(xx)>
        <CFSET temp=StructInsert(NestedStruct,"f",x)>
        <CFSET temp=StructInsert(NestedStruct,"c", 'b')>
        <CFSET temp=StructInsert(NestedStruct,"s", " bu-bu")>
    </CFIF>

    <!--Declare a sequence -
    <CFSET FixedSeq = ArrayNew(1)>

    <CFLOOP INDEX="LoopCount" FROM="1" TO="5">
        <CFSET FixedSeq [LoopCount] = #LoopCount#>
    </CFLOOP>

    <CFSET retA=obj.SomeMethod(NestedStruct, FixedSeq)>

## Exception handling

Exceptions thrown by the CORBA object methods can be caught with the CFTRY and CFCATCH tags. However, no information can be extracted from the exception object in this release.