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" /> <title>Producing WSDL files</title> <link rel="stylesheet" href="help.css"> </head> <body><script language="javascript"> if (window.name != "content") document.write("<center><a href='index.html?page=webser29.htm'>show framing</a></center>") </script> <table width="100%" border="0"> <tr> <td width="89%"> </td> <td colspan="2" align="right"> <a href="webser28.htm"><img src="images/previous.gif" border="0" alt="Previous"></a><a href="webser30.htm"><img src="images/shim.gif"><img src="images/next.gif" border="0" alt="Next"></a> </td> </tr> <tr> <td colspan="3"> <hr /> </td> </tr> </table> <h1>Producing WSDL files</h1> <p>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> <pre> http://localhost/echo.cfc?wsdl </pre> <p>For example, you define a ColdFusion component as follows:</p> <pre> <cfcomponent> <cffunction <br>name = "echoString" <br>returnType = "string" <br>output = "no"<br>access = "remote"> <cfargument name = "input" type = "string"> <cfreturn #arguments.input#> </cffunction> </cfcomponent> </pre> <p>If you register the component in Dreamweaver MX, it appears in the Components tab of the Application panel.</p> <p>Requesting the WSDL file returns the following:</p> <pre> <?xml version="1.0" encoding="UTF-8" ?> <wsdl:definitions targetNamespace="http://webservices" <br>xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" <br>xmlns:xsd="http://www.w3.org/2001/XMLSchema" <br>xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" <br>xmlns:intf="http://webservices" <br>xmlns:impl="http://webservices-impl" <br>xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" <br>xmlns="http://schemas.xmlsoap.org/wsdl/"> <b> <wsdl:message name="echoStringResponse"></b> <b> <wsdl:part name="return" type="SOAP-ENC:string" /> </b> <b> </wsdl:message></b> <b> <wsdl:message name="echoStringRequest"></b> <b> <wsdl:part name="input" type="SOAP-ENC:string" /> </b> <b> </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" /> <<code><b>wsdl:operation name="echoString"</b></code>> <wsdlsoap:operation soapAction="" style="rpc" /> <<code><b>wsdl:input</b></code>> <wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://webservices" /> </wsdl:input> <<code><b>wsdl:output</b></code>> <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> <h4><a name="wp1169930"></a>To publish a web service:</h4> <ol> <li>Create a ColdFusion page with the following content: <pre> <cfcomponent output="false"> <cffunction <br> name = "echoString" <br> returnType = "string" <br> output = "no" <br> access = "remote"> <cfargument name = "input" type = "string"> <cfreturn #arguments.input#> </cffunction> </cfcomponent> </pre> </li> <li>Save this file as echo.cfc in your web root directory. </li> <li>Create a ColdFusion page with the following content: <pre> <cfinvoke webservice ="http://localhost/echo.cfc?wsdl" method ="echoString" input = "hello" returnVariable="foo"> <cfoutput>#foo#</cfoutput> </pre> </li> <li>Save this file as echoclient.cfm in your web root directory. </li> <li>Request echoclient.cfm in your browser. <p>The following string appears in your browser:</p><pre> hello </pre> </li> </ol> <p>You can also invoke the web service using the following code:</p> <pre> <cfscript> ws = CreateObject("webservice", "http://localhost/echo.cfc?wsdl"); wsresults = ws.echoString("hello"); writeoutput(wsresults); </cfscript> </pre> <table width="100%" border="0"> <tr> <td colspan="3"> <hr /> </td> </tr> <tr> <td width="89%"> </td> <td colspan="2" align="right"> <a href="webser28.htm"><img src="images/previous.gif" border="0" alt="Previous"></a><a href="webser30.htm"><img src="images/shim.gif"><img src="images/next.gif" border="0" alt="Next"></a> </td> </tr> </table> </body> </html>