home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet Web Designer 86 / PIWD86.iso / pc / contents / dreamweaver / software / dwmx2004.exe / Disk1 / data1.cab / Help_En / cfbooks.chm / webser29.htm < prev    next >
Encoding:
Extensible Markup Language  |  2003-09-05  |  5.4 KB  |  143 lines

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  5. <meta http-equiv="Content-Style-Type" content="text/css" />
  6. <title>Producing WSDL files</title>
  7. <link rel="stylesheet" href="help.css">
  8. </head>
  9. <body><script language="javascript">
  10. if (window.name != "content")
  11.     document.write("<center><a href='index.html?page=webser29.htm'>show framing</a></center>")
  12. </script>
  13. <table width="100%" border="0">
  14.   <tr> 
  15.     <td width="89%"> </td>
  16.     <td colspan="2" align="right">
  17. <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>
  18.  
  19.  
  20.  
  21.  
  22. </td>
  23.   </tr>
  24.   <tr> 
  25.     <td colspan="3"> <hr /> </td>
  26.   </tr>
  27. </table>
  28.  
  29. <h1>Producing WSDL files</h1>
  30. <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>
  31. <pre>
  32. http://localhost/echo.cfc?wsdl
  33. </pre>
  34. <p>For example, you define a ColdFusion component as follows:</p>
  35. <pre>
  36. <cfcomponent>
  37.     <cffunction <br>name = "echoString" <br>returnType = "string" <br>output = "no"<br>access = "remote">
  38.         <cfargument name = "input" type = "string">
  39.         <cfreturn #arguments.input#>
  40.     </cffunction>
  41. </cfcomponent>
  42. </pre>
  43. <p>If you register the component in Dreamweaver MX, it appears in the Components tab of the Application panel.</p>
  44. <p>Requesting the WSDL file returns the following:</p>
  45. <pre>
  46. <?xml version="1.0" encoding="UTF-8" ?> 
  47. <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/">
  48. <b>    <wsdl:message name="echoStringResponse"></b>
  49. <b>            <wsdl:part name="return" type="SOAP-ENC:string" /> </b>
  50. <b>    </wsdl:message></b>
  51. <b>    <wsdl:message name="echoStringRequest"></b>
  52. <b>        <wsdl:part name="input" type="SOAP-ENC:string" /> </b>
  53. <b>    </wsdl:message></b>
  54.     <wsdl:portType name="echo">
  55.         <wsdl:operation name="echoString" parameterOrder="in0">
  56.             <wsdl:input message="intf:echoStringRequest" /> 
  57.             <wsdl:output message="intf:echoStringResponse" /> 
  58.         </wsdl:operation>
  59.     </wsdl:portType>
  60.     <wsdl:binding name="echo.cfcSoapBinding" type="intf:echo">
  61.         <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> 
  62.         <<code><b>wsdl:operation name="echoString"</b></code>>
  63.             <wsdlsoap:operation soapAction="" style="rpc" /> 
  64.             <<code><b>wsdl:input</b></code>>
  65.                 <wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://webservices" /> 
  66.             </wsdl:input>
  67.             <<code><b>wsdl:output</b></code>>
  68.                 <wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://webservices" /> 
  69.             </wsdl:output>
  70.         </wsdl:operation>
  71.     </wsdl:binding>
  72.     <wsdl:service name="echo.cfcService">
  73.         <wsdl:port name="echo.cfc" binding="intf:echo.cfcSoapBinding">
  74.             <wsdlsoap:address location="http://SMGILSON02/webservices/echo.cfc" /> 
  75.         </wsdl:port>
  76.     </wsdl:service>
  77. </wsdl:definitions>
  78. </pre>
  79. <h4><a name="wp1169930"></a>To publish a web service:</h4>
  80. <ol>
  81. <li>Create a ColdFusion page with the following content:
  82.  
  83.  
  84. <pre>
  85. <cfcomponent output="false">
  86.     <cffunction <br>            name = "echoString" <br>            returnType = "string" <br>            output = "no" <br>            access = "remote">
  87.         <cfargument name = "input" type = "string">
  88.         <cfreturn #arguments.input#>
  89.     </cffunction>
  90. </cfcomponent>
  91. </pre>
  92. </li>
  93. <li>Save this file as echo.cfc in your web root directory.
  94. </li>
  95. <li>Create a ColdFusion page with the following content:
  96.  
  97.  
  98. <pre>
  99. <cfinvoke webservice ="http://localhost/echo.cfc?wsdl"
  100.     method ="echoString"
  101.     input = "hello" 
  102.     returnVariable="foo">
  103.  
  104. <cfoutput>#foo#</cfoutput>
  105. </pre>
  106. </li>
  107. <li>Save this file as echoclient.cfm in your web root directory.
  108. </li>
  109. <li>Request echoclient.cfm in your browser. 
  110.  
  111. <p>The following string appears in your browser:</p><pre>
  112. hello
  113. </pre>
  114. </li>
  115. </ol>
  116. <p>You can also invoke the web service using the following code:</p>
  117. <pre>
  118. <cfscript>
  119.     ws = CreateObject("webservice", "http://localhost/echo.cfc?wsdl");
  120.     wsresults = ws.echoString("hello");
  121.     writeoutput(wsresults);
  122. </cfscript>
  123. </pre>
  124.  
  125. <table width="100%" border="0">
  126.   <tr> 
  127.     <td colspan="3"> <hr /> </td>
  128.   </tr>
  129.   <tr> 
  130.     <td width="89%"> </td>
  131.     <td colspan="2" align="right">
  132. <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>
  133.  
  134.  
  135.  
  136.  
  137. </td>
  138.   </tr>
  139. </table>
  140. </body>
  141. </html>
  142.  
  143.