User Guide

Table Of Contents
Using request and response headers 907
</cfif>
</cflogin>
<cfif not isAuthorized>
<!--- If the user does not pass a username/password, return a 401 error.
The browser then prompts the user for a username/password. --->
<cfheader statuscode="401">
<cfheader name="WWW-Authenticate" value="Basic realm=""Test""">
<cfabort>
</cfif>
This example does not show how to perform user verification. For more information on
verification, see Chapter 16, “Securing Applications,” on page 373.
Best practices for publishing web services
ColdFusion web services provide a powerful mechanism for publishing and consuming
application functionality. However, before you produce web services for publication, you might
want to consider the following best practices:
1.
Minimize the use of ColdFusion complex types, such as query and struct, in the web services
you create for publication. These types require consumers, especially those consuming the web
service using a technology other than ColdFusion, to create special data structures to handle
complex types.
2.
Locally test the ColdFusion components implemented for web services before publishing them
over the Internet.
Using request and response headers
ColdFusion MX includes a set of functions that enable your web service to get and set request and
response headers. You use these functions to retrieve the response headers from a web service
request and to create SOAP headers in a request that has the
mustUnderstand attribute set to be
True.
You typically use different functions in web services clients and in the web service CFC, itself:
In the client:
AddSOAPRequestHeader, called before the request to set a SOAP header.
GetSOAPResponseHeader, called after the request to retrieve a SOAP header.
In the web service CFC:
IsSOAPRequest, called to determine whether the CFC method is being called as a web service.
GetSOAPRequestHeader, called to retrieve a SOAP header set by the client.
AddSOAPResponseHeader, called to set a SOAP header that is returned to the client.
Note: When used in a CFC, you can only use these functions in CFC methods if they are being used
as web services. Use the
IsSOAPRequest function to determine whether the CFC method is being
called as a web service.