
Publishing web services
721
Publishing web services
To publish web services for consumption by remote applications, you create the web service using
ColdFusion components. For more information on components, see
Chapter 11, “Building and
Using ColdFusion Components,” on page 219
.
Creating components for web services
ColdFusion components encapsulate application functionality and provide a standard interface
for client access to that functionality. A component typically contains one or more functions
defined by the
cffunction
tag.
For example, the following component contains a single function:
<cfcomponent>
<cffunction name="echoString" returnType="string" output="no">
<cfargument name="input" type="string">
<cfreturn #arguments.input#>
</cffunction>
</cfcomponent>
The function, named echoString, echoes back any string passed to it. To publish the function as a
web service, you must modify the function definition to add the
access
attribute, as the
following example shows:
<cffunction name="echoString" returnType="string" output="no"
access="remote"
>
By defining the function as remote, ColdFusion includes the function in the WSDL file. Only
those functions marked as remote are accessible as a web service.
The following list defines the requirements for how to create web services for publication:
1
The value of the
access
attribute of the
cffunction
tag must be
remote
.
2
The
cffunction
tag must include the
returnType
attribute to specify a return type.
If the function does not return anything, set its
returnType
attribute to
void
.
3
The
output
attribute of the
cffunction
tag must be set to
No
because ColdFusion converts all
output to XML to return it to the consumer.
4
The attribute setting
required="false"
for the
cfargument
tag is ignored. ColdFusion
considers all parameters as required.
Specifying data types of function arguments and return values
The
cffunction
tag lets you define a single return value and one or more input parameters
passed to a function. As part of the function definition, you include the data type of the return
value and input parameters.
The following example shows a component that defines a function with a return value of type
string, one input parameter of type string, and one input parameter of type numeric:
<cfcomponent>
<cffunction name="trimString" returnType="string" output="no">
<cfargument name="inString" type="string">
<cfargument name="trimLength" type="numeric">
</cffunction>
</cfcomponent>
Содержание ColdFusion MX
Страница 1: ...Developing ColdFusion MX Applications...
Страница 22: ...22 Contents...
Страница 38: ......
Страница 52: ...52 Chapter 2 Elements of CFML...
Страница 162: ......
Страница 218: ...218 Chapter 10 Writing and Calling User Defined Functions...
Страница 250: ...250 Chapter 11 Building and Using ColdFusion Components...
Страница 264: ...264 Chapter 12 Building Custom CFXAPI Tags...
Страница 266: ......
Страница 314: ...314 Chapter 14 Handling Errors...
Страница 344: ...344 Chapter 15 Using Persistent Data and Locking...
Страница 349: ...About user security 349...
Страница 357: ...Security scenarios 357...
Страница 370: ...370 Chapter 16 Securing Applications...
Страница 388: ...388 Chapter 17 Developing Globalized Applications...
Страница 408: ...408 Chapter 18 Debugging and Troubleshooting Applications...
Страница 410: ......
Страница 426: ...426 Chapter 19 Introduction to Databases and SQL...
Страница 476: ...476 Chapter 22 Using Query of Queries...
Страница 534: ...534 Chapter 24 Building a Search Interface...
Страница 556: ...556 Chapter 25 Using Verity Search Expressions...
Страница 558: ......
Страница 582: ...582 Chapter 26 Retrieving and Formatting Data...
Страница 668: ......
Страница 734: ...734 Chapter 32 Using Web Services...
Страница 760: ...760 Chapter 33 Integrating J2EE and Java Elements in CFML Applications...
Страница 786: ...786 Chapter 34 Integrating COM and CORBA Objects in CFML Applications...
Страница 788: ......
Страница 806: ...806 Chapter 35 Sending and Receiving E Mail...