User Guide Cancel

CreateObject: web service object

 

Note:

As of ColdFusion (2021 release), CORBA has been removed. You can no longer use CORBA-related features, functions, and tags.

Description

This function can create a web service object.

Returns

A web service object.

History

ColdFusion 10: Added argument wsversion.

Function syntax

CreateObject(type, urltowsdl[, portname, wsdl2JavaArgs,wsVersion])
OR
CreateObject(type, urltowsdl, argStruct)
CreateObject(type, urltowsdl[, portname, wsdl2JavaArgs,wsVersion]) OR CreateObject(type, urltowsdl, argStruct)
CreateObject(type, urltowsdl[, portname, wsdl2JavaArgs,wsVersion]) 
 
OR 
 
CreateObject(type, urltowsdl, argStruct)

Parameters

Parameter

Description

type

Type of object to create.

  • com
  • corba
  • java
  • component
  • webservice
    The default value of type is component .

urltowsdl

Specifies the URL to web service WSDL file. One of the following:

  • The absolute URL of the web service
  • The Name (string) assigned in the ColdFusion Administrator to the web service

portname

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.

wsdl2JavaArgs

A string containing a space-delimited list of arguments to pass to the WSDL2Java tool that generates Java stubs for the web services. Useful arguments include the following:

  • W or -noWrapped: Turns off the special treatment of wrapped document/literal style operations.
  • a or -all: Generates code for all elements in the WSDL, even unreferenced ones.
  • w or -wrapArrays: Prefers building beans to straight arrays for wrapped XML array types. This switch is not in included in the Axis documentation.
    For detailed information on valid arguments, see the Apache Axis WSDL2Java Reference.

argStruct

wsVersion

A structure containing web service configuration arguments. For more information see Usage

Specifies version of the axis to be used. If the wsversion is specified as "1", then axis 1 will be used. If it is "2", then axis 2 will be used.

NTLM attributes

authType

The authentication type to use. You can use NTLM or BASIC.

ntlmdomain

Host name of the domain controller. Note: When a user is part of a domain, the ntlmDomain attribute is mandatory. When a user is not part of a domain, the ntlmDomainattribute is not mandatory.

workstation

Host name of the client machine.

Usage

You can use the CreateObject function to create a web service. The argStruct structure can contain any combination of the following values:

Name

Default

Description

password

Password set in the Administrator, if any

The password to use to access the web service. If the webservice attribute specifies a web service name configured in the Administrator, overrides any user name specified in the Administrator entry.

port

 

See portname in the Syntax Parameter table.

proxyPassword

http.proxyPassword system property, if any

The user's password on the proxy server.

proxyPort

http.proxyPort system property, if any

The port to use on the proxy server.

proxyServer

http.proxyHost system property, if any

The proxy server required to access the webservice URL.

proxyUser

http.proxyUser system property, if any

The user ID to send to the proxy server.

refreshWSDL

no

  • yes: Reload the WSDL file and regenerate the artifacts used to consume the web service
  • no

saveJava

no

  • yes: Save the Java generated by the WSDL2Java converter that generates Java web service stubs. This code can be useful in debugging errors.
  • no

timeout

0 (no time-out)

The time-out for retrieving the web service WSDL, in seconds.

username

User name set in the Administrator, if any

The user name to use to access the web service. If the webservice attribute specifies a web service name configured in the Administrator, overrides any user name specified in the Administrator entry.

wsdl2javaArgs

 

See the Syntax parameter table.

Example

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

Using NTLM attributes

<cfscript>
wsobj = createObject("webservice", "http://localhost/AxisWs/services/Converter?wsdl",{refreshwsdl=true,username="user name",password="password",
authtype="NTLM",workstation="workstation",ntlmdomain="ntlmdomain",wsversion=2});
</cfscript>
<cfscript> wsobj = createObject("webservice", "http://localhost/AxisWs/services/Converter?wsdl",{refreshwsdl=true,username="user name",password="password", authtype="NTLM",workstation="workstation",ntlmdomain="ntlmdomain",wsversion=2}); </cfscript>
<cfscript>
 wsobj = createObject("webservice", "http://localhost/AxisWs/services/Converter?wsdl",{refreshwsdl=true,username="user name",password="password",
      authtype="NTLM",workstation="workstation",ntlmdomain="ntlmdomain",wsversion=2});
</cfscript>

Get help faster and easier

New user?