
1102
DEVELOPING
COLDFUSION 9 APPLICATIONS
Using Web Elements and External Objects
Las
t
upda
te
d 8/5/2010
<cftry>
Place your application code here ...
<cfcatch type="application">
<!--- Add exception processing code here ... --->
</cfcatch>
...
<cfcatch type="Any">
<!--- Add exception processing code appropriate for all other
exceptions here ... --->
</cfcatch>
</cftry>
For more information on error handling, see “
Handling Errors
” on page 275.
Handling inout and out parameters
Some web services define inout and out parameters. You use
out
parameters to pass a placeholder for a return value to
a web service. The web service then returns its result by writing it to the out parameter.
Inout
parameters let you pass
a value to a web service and lets the web service return its result by overwriting the parameter value.
The following example shows a web service that takes as input an inout parameter containing a string and writes its
results back to the string:
<cfset S="foo">
<cfscript>
ws=createobject("webservice", "URLtoWSDL")
ws.modifyString("S");
</cfscript>
<cfoutput>#S#</cfoutput>
Even though this web service takes as input the value of S, because you pass it as an inout parameter, you do not enclose
it in number signs.
Note:
ColdFusion supports the use of inout and out parameters to consume web services. However, ColdFusion does not
support inout and out parameters when creating web services for publication.
Configuring web services in the ColdFusion Administrator
The ColdFusion Administrator lets you register web services so that you do not have to specify the entire WSDL URL
when you reference the web service.
Note:
The first time you reference a web service, ColdFusion automatically registers it in the Administrator.
For example, the following code references the URL to the TemperatureService WSDL file:
<cfscript>
ws = CreateObject("webservice",
"http://www.xmethods.net/sd/2001/TemperatureService.wsdl");
xlatstring = ws.getTemp("55987");
writeoutput(xlatstring);
</cfscript>
If you register the TemperatureService web service in the Administrator using (for example, the name wsTemp), you
can then reference the web service as follows:
<cfscript>
ws = CreateObject("webservice", "wsTemp");
xlatstring = ws.getTemp("55987");
writeoutput("wsTemp: " & xlatstring);
</cfscript>
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...