User Guide

684 Chapter 3: ColdFusion Functions
IsSOAPRequest
Description
Determines whether a CFC is being called as a web service.
Returns
True if CFC is being called as a web service; False, otherwise.
Category
XML functions
History
ColdFusion MX 7: Added this function.
Function syntax
IsSOAPRequest()
See also
AddSOAPRequestHeader
, AddSOAPResponseHeader, GetSOAPRequest,
GetSOAPRequestHeader, GetSOAPResponse, GetSOAPResponseHeader; “Basic web service
concepts” in Chapter 36, “Using Web Services,” in ColdFusion MX Developers Guide.
Usage
Call this function within a CFC to determine if it is running as a web service.
Example
This example creates a CFC web service that illustrates the operation of the IsSOAPRequest
function and also provides a web service that illustrates the operation of other ColdFusion SOAP
functions.
Save the following code as headerservice.cfc in a folder called soapheaders under your web root.
Test its operation, and specifically the operation of the
IsSOAPRequest function, by executing the
examples that invoke this web service. For example, see the example for
AddSOAPRequestHeader.
<h3>IsSOAPRequest Example</h3>
<cfcomponent displayName="tester" hint="Test for SOAP headers">
<cffunction name="echo_me"
access="remote"
output="false"
returntype="string"
displayname="Echo Test" hint="Header test">
<cfargument name="in_here" required="true" type="string">
<cfset isSOAP = isSOAPRequest()>
<cfif isSOAP>
<!--- Get the first header as a string and as XML --->
<cfset username = getSOAPRequestHeader("http://mynamespace/", "username")>