| Contents > Developing ColdFusion MX Applications > Using Web Services > Publishing web services > Producing WSDL files |
|
|
|
|
||
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:
http://localhost/echo.cfc?wsdl
For example, you define a ColdFusion component as follows:
<cfcomponent> <cffunction
name = "echoString"
returnType = "string"
output = "no"
access = "remote"> <cfargument name = "input" type = "string"> <cfreturn #arguments.input#> </cffunction> </cfcomponent>
If you register the component in Dreamweaver MX, it appears in the Components tab of the Application panel.
Requesting the WSDL file returns the following:
<?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/"> <wsdl:message name="echoStringResponse"> <wsdl:part name="return" type="SOAP-ENC:string" /> </wsdl:message> <wsdl:message name="echoStringRequest"> <wsdl:part name="input" type="SOAP-ENC:string" /> </wsdl:message> <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" /> <wsdl:operation name="echoString"> <wsdlsoap:operation soapAction="" style="rpc" /> <wsdl:input> <wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://webservices" /> </wsdl:input> <wsdl:output> <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>
<cfcomponent output="false"> <cffunction
name = "echoString"
returnType = "string"
output = "no"
access = "remote"> <cfargument name = "input" type = "string"> <cfreturn #arguments.input#> </cffunction> </cfcomponent>
<cfinvoke webservice ="http://localhost/echo.cfc?wsdl" method ="echoString" input = "hello" returnVariable="foo"> <cfoutput>#foo#</cfoutput>
The following string appears in your browser:
hello
You can also invoke the web service using the following code:
<cfscript>
ws = CreateObject("webservice", "http://localhost/echo.cfc?wsdl");
wsresults = ws.echoString("hello");
writeoutput(wsresults);
</cfscript>
|
|
||
| Contents > Developing ColdFusion MX Applications > Using Web Services > Publishing web services > Producing WSDL files |
|
|
ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 6.1
Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.