home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 July / 07_02.iso / software / mdmx / files / DreamweaverMXInstaller.exe / Disk1 / data1.cab / Help_En / cfbooks.chm / webser28.htm < prev    next >
Encoding:
Extensible Markup Language  |  2002-05-01  |  8.3 KB  |  162 lines

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