In the cfobject
tag, you must specify the following attributes when calling CORBA objects:
type
attribute to CORBA
. If no type
is specified, COM is assumed.
context
attribute shows how the object reference is obtained. Set context
to IOR
for a file containing the object's unique Interoperable Object Reference or to NameService
.context
attribute 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 make it local to the server or on the network in an accessible location.context
attribute to NameService
, the class
attribute must include a period-delimited name, such as MyCompany.Department.Dev. Currently, ColdFusion can only resolve objects registered in a CORBA 3.0-compliant naming service. Make sure that the naming service (NS) is brought-up with a default naming context. 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.name
attribute to the name that your application uses to call the object's operations and attributes.
For the complete cfobject
syntax, see the CFML Reference.
After you create the object, you can invoke attributes and operations on the object using the syntax outlined in the previous sections. ColdFusion also supports the use of complex types such as structures and sequences. For structures, use ColdFusion structures; for sequences, use ColdFusion arrays.
Here is 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); };
Here is 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(NestedStruct)> <cfset temp=StructInsert(NestedStruct,"f",x)> <cfset temp=StructInsert(NestedStruct,"c", 'b')> <cfset temp=StructInsert(NestedStruct,"s", " Test")> </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)>
You can catch exceptions thrown by the CORBA object methods with the cftry
and cfcatch
tags. However, you cannot extract information from the exception object.