home *** CD-ROM | disk | FTP | other *** search
Wrap
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta name="GENERATOR" content="Quadralay WebWorks Publisher Professional Edition 7.0.2.1206" /> <meta name="TEMPLATEBASE" content="Newton Win 1.0" /> <meta name="LASTUPDATED" content="04/19/02 11:55:59" /> <title>Producing WSDL files</title> <link rel="StyleSheet" href="document.css" type="text/css" /> <link rel="StyleSheet" href="catalog.css" type="text/css" /> </head> <body><script language="javascript"> if (window.name != "content") document.write("<center><a href='index.html?page=webser28.htm'>show framing</a></center>") </script> <table width="100%" border="0"> <tr> <td width="89%"> </td> <td colspan="2" align="right"> <a href="webser27.htm"><img src="images/previous.gif" width="18" height="16" border="0" alt="Previous"></a><img src="images/shim.gif" width="1" height="1"><img src="images/shim.gif" width="1" height="1"><img src="images/shim.gif" width="1" height="1"><img src="images/shim.gif" width="1" height="1"><img src="images/shim.gif" width="1" height="1"><img src="images/shim.gif" width="1" height="1"><img src="images/shim.gif" width="1" height="1"><a href="webser29.htm"><img src="images/next.gif" width="18" height="16" border="0" alt="Next"></a> </td> </tr> <tr> <td colspan="3"> <hr> </td> </tr> </table> <h2 class="pHeading2"> Producing WSDL files </h2> <p class="pBody"> ColdFusion automatically creates a WSDL file for any component referenced as a web service. For example, if you have a component named echo.cfc in your web root directory, you can view its corresponding WSDL file by requesting the component as follows: </p> <div class="pPreformatted"><pre>http://localhost/echo.cfc?wsdl </pre></div><p class="pBody"> For example, you define a ColdFusion component as follows: </p> <div class="pPreformatted"><pre><cfcomponent> <cffunction name = "echoString" returnType = "string" output = "no" access = "remote"> <cfargument name = "input" type = "string"> <cfreturn #arguments.input#> </cffunction> </cfcomponent> </pre></div><p class="pBody"> If you register the component in Dreamweaver MX, it appears in the Application panel as shown below. </p> <p style="color: Black; font-family: Verdana, Arial, sans-serif; font-size: small; font-style: italic; font-variant: normal; font-weight: normal; text-decoration: none; text-transform: none"> 570</p><div align="left"><img src="images/webser_3.jpg" height="141" width="570" alt="This is a picture of the feature being described." border="0" hspace="1" vspace="1"/></div><p style="color: Black; font-family: Verdana, Arial, sans-serif; font-size: small; font-style: italic; font-variant: normal; font-weight: normal; text-decoration: none; text-transform: none"> </p> <p class="pBody"> Requesting the WSDL file returns the following: </p> <div class="pPreformatted"><pre><?xml version="1.0" encoding="UTF-8" ?> <wsdl:definitions targetNamespace="http://webservices" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:intf="http://webservices" xmlns:impl="http://webservices-impl" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns="http://schemas.xmlsoap.org/wsdl/"> <b class="cBold"> <wsdl:message name="echoStringResponse"> </b><b class="cBold"> <wsdl:part name="return" type="SOAP-ENC:string" /> </b><b class="cBold"> </wsdl:message> </b><b class="cBold"> <wsdl:message name="echoStringRequest"> </b><b class="cBold"> <wsdl:part name="input" type="SOAP-ENC:string" /> </b><b class="cBold"> </wsdl:message> </b> <wsdl:portType name="echo"> <wsdl:operation name="echoString" parameterOrder="in0"> <wsdl:input message="intf:echoStringRequest" /> <wsdl:output message="intf:echoStringResponse" /> </wsdl:operation> </wsdl:portType> <wsdl:binding name="echo.cfcSoapBinding" type="intf:echo"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/ http" /> <<b class="cBold">wsdl:operation name="echoString"</b>> <wsdlsoap:operation soapAction="" style="rpc" /> <<b class="cBold">wsdl:input</b>> <wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/ soap/encoding/" namespace="http://webservices" /> </wsdl:input> <<b class="cBold">wsdl:output</b>> <wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/ soap/encoding/" namespace="http://webservices" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="echo.cfcService"> <wsdl:port name="echo.cfc" binding="intf:echo.cfcSoapBinding"> <wsdlsoap:address location="http://SMGILSON02/webservices/echo.cfc" /> </wsdl:port> </wsdl:service> </wsdl:definitions> </pre></div><h2 class="pProcedure"> To publish a web service: </h2> <div class="pSmartList1"><ol type="1"> <div class="pSmartList1"><li>Create a ColdFusion page with the following content:</li></div> <div class="pPreformattedRelative"><pre><cfcomponent output="false"> <cffunction name = "echoString" returnType = "string" output = "no" access = "remote"> <cfargument name = "input" type = "string"> <cfreturn #arguments.input#> </cffunction> </cfcomponent> </pre></div><div class="pSmartList1"><li>Save this file as echo.cfc in your web root directory.</li></div> <div class="pSmartList1"><li>Create a ColdFusion page with the following content:</li></div> <div class="pPreformattedRelative"><pre><cfinvoke webservice ="http://localhost/echo.cfc?wsdl" method ="echoString" input = "hello" returnVariable="foo"> <cfoutput>#foo#</cfoutput> </pre></div><div class="pSmartList1"><li>Save this file as echoclient.cfm in your web root directory.</li></div> <div class="pSmartList1"><li>Request echoclient.cfm in your browser. </li></div> <p class="pBodyRelative"> The following string appears in your browser: </p> <div class="pPreformattedRelative"><pre>hello </pre></div></ol></div> <p class="pBody"> You can also invoke the web service using the following code: </p> <div class="pPreformatted"><pre><cfscript> ws = CreateObject("webservice", "http://localhost/echo.cfc?wsdl"); wsresults = ws.echoString("hello"); writeoutput(wsresults); </cfscript> </pre></div> <table width="100%" border="0"> <tr> <td colspan="3"> <hr> </td> </tr> <tr> <td width="89%"> </td> <td colspan="2" align="right"> <a href="webser27.htm"><img src="images/previous.gif" width="18" height="16" border="0" alt="Previous"></a><img src="images/shim.gif" width="1" height="1"><img src="images/shim.gif" width="1" height="1"><img src="images/shim.gif" width="1" height="1"><img src="images/shim.gif" width="1" height="1"><img src="images/shim.gif" width="1" height="1"><img src="images/shim.gif" width="1" height="1"><img src="images/shim.gif" width="1" height="1"><a href="webser29.htm"><img src="images/next.gif" width="18" height="16" border="0" alt="Next"></a> </td> </tr> </table> </body> </html>