createObject

The createObject function takes different arguments depending on the value of the type argument:

createObject('component', cfcName)
createObject('java', class)
createObject('webservice', urltowsdl, [, portname])
createObject('.NET', class, assembly [, server, port, protocol, secure])
createObject('com', class, context, serverName)

createObject(type, class) → returns Object

Argument Reference for the createObject function

type

Required: Yes
The type of Values:
  • component
  • corba
  • com
  • java
  • webservice
  • .NET
  • dotnet

context

Required: Yes

class

Required: Yes

locale

Required: Yes

servername

Required: Yes

component_name

Required: Yes

urltowsdl

Required: Yes
WSDL file URL; location of web service

portname

Required: No
The port name for the web service. This value is case-sensitive
and corresponds to the port element's name attribute under the
service element.
Specify this parameter if the web service contains multiple ports.
If no port name is specified, ColdFusion uses the first port found
in the WSDL.

Compatibility

ColdFusion:

CORBA support DEPRECATED in CF 11+

Examples sample code invoking the createObject function


Create a CFC / Component Instance

createObject Component

<cfscript> 
 tellTimeCFC=createObject("component","appResources.components.tellTime"); 
 tellTimeCFC.getLocalTime();
 </cfscript>       

Create a SOAP WebService Instance

createObject WebService

<cfscript> 
 ws = createObject("webservice", "http://www.xmethods.net/sd/2001/TemperatureService.wsdl"); 
 xlatstring = ws.getTemp(zipcode = "55987"); 
 writeOutput("The temperature at 55987 is " & xlatstring); 
 </cfscript>      

Fork me on GitHub