Whatever message this page gives is out now! Go check it out!
<cffunction name="echoString" returnType="string" output="no"> <cfargument name="input" type="string"> <cfreturn #arguments.input#> </cffunction> </cfcomponent> |
<cffunction name="echoString" returnType="string" output="no" access="remote"> |
<cffunction name="trimString" returnType="string" output="no"> <cfargument name="inString" type="string"> <cfargument name="trimLength" type="numeric"> </cffunction> </cfcomponent> |
ColdFusion data type | WSDL data type published |
numeric | SOAP-ENC:double |
Boolean | SOAP-ENC:boolean |
string | SOAP-ENC:string |
array | SOAP-ENC:Array |
binary | xsd:base64Binary |
date | xsd:dateTime |
guid | SOAP-ENC:string |
uuid | SOAP-ENC:string |
void (operation returns nothing) | |
struct | Map |
query | QueryBean |
any | complex type |
component definition | complex type |
http://localhost/echo.cfc?wsdl |
namespace = "http://www.mycompany.com/" serviceportname = "RestrictedEmpInfo" porttypename = "RestrictedEmpInfo" bindingname = "myns:RestrictedEmpInfo" displayname = "RestrictedEmpInfo" hint = "RestrictedEmpInfo"> |
<cffunction name = "echoString" returnType = "string" output = "no" access = "remote"> <cfargument name = "input" type = "string"> <cfreturn #arguments.input#> </cffunction> </cfcomponent> |
<wsdl:definitions targetNamespace="http://ws" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://ws" xmlns:intf="http://ws" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://rpc.xml.coldfusion" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <!--WSDL created by ColdFusion --> <wsdl:types> <schema targetNamespace="http://rpc.xml.coldfusion" xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> <complexType name="CFCInvocationException"> <sequence/> </complexType> </schema> </wsdl:types> <wsdl:message name="CFCInvocationException"> <wsdl:part name="fault" type="tns1:CFCInvocationException"/> </wsdl:message> <wsdl:message name="echoStringResponse"> <wsdl:part name="echoStringReturn" type="xsd:string"/> </wsdl:message> <wsdl:message name="echoStringRequest"> <wsdl:part name="input" type="xsd:string"/> </wsdl:message> <wsdl:portType name="echo"> <wsdl:operation name="echoString" parameterOrder="input"> <wsdl:input message="impl:echoStringRequest" name="echoStringRequest"/> <wsdl:output message="impl:echoStringResponse" name="echoStringResponse"/> <wsdl:fault message="impl:CFCInvocationException" name="CFCInvocationException"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="echo.cfcSoapBinding" type="impl:echo"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/ http"/> <wsdl:operation name="echoString"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="echoStringRequest"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/" namespace="http://ws" use="encoded"/> </wsdl:input> <wsdl:output name="echoStringResponse"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/" namespace="http://ws" use="encoded"/> </wsdl:output> <wsdl:fault name="CFCInvocationException"> <wsdlsoap:fault encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/" name="CFCInvocationException" namespace= "http://ws" use="encoded"/> </wsdl:fault> </wsdl:operation> </wsdl:binding> <wsdl:service name="echoService"> <wsdl:port binding="impl:echo.cfcSoapBinding" name="echo.cfc"> <wsdlsoap:address location="http://localhost:8500/ws/echo.cfc"/> </wsdl:port> </wsdl:service> </wsdl:definitions> |
<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>hello |
ws = CreateObject("webservice", "http://localhost/echo.cfc?wsdl"); wsresults = ws.echoString("hello"); writeoutput(wsresults); </cfscript> |
<cfproperty name="AddrNumber" type="numeric"> <cfproperty name="Street" type="string"> <cfproperty name="City" type="string"> <cfproperty name="State" type="string"> <cfproperty name="Country" type="string"> </cfcomponent> |
<cfproperty name="Firstname" type="string"> <cfproperty name="Lastname" type="string"> </cfcomponent> |
<cffunction name="echoName" returnType="name" access="remote" output="false"> <cfargument name="input" type="name"> <cfreturn #arguments.input#> </cffunction> <cffunction name="echoAddress" returnType="address" access="remote" output="false"> <cfargument name="input" type="address"> <cfreturn #arguments.input#> </cffunction> </cfcomponent> |
<sequence> <element name="firstname" nillable="true" type="soapenc:string"/> <element name="lastname" nillable="true" type="soapenc:string"/> </sequence> </complexType> |
<cffunction name="allNames" returnType="name[]" access="remote" output="false"> <cfset var returnarray = ArrayNew(1)> <cfset var temp = ""> <cfquery name="empinfo" datasource="cfdocexamples"> SELECT firstname, lastname FROM employee </cfquery> <cfloop query="empinfo" > <cfobject component="name" name="tempname"> <cfset tempname.Firstname = #empinfo.firstname#> <cfset tempname.Lastname = #empinfo.lastname#> <cfset temp = ArrayAppend(returnarray, tempname)> </cfloop> <cfreturn returnarray> </cffunction> </cfcomponent> |
<cfinvoke webservice ="http://localhost:8500/ws/cfcarray.cfc?wsdl"
method ="allNames"
returnVariable="thearray">
<cfif IsArray(thearray)>
<h1>loop through the employees</h1>
<p>thearray has <cfoutput>#ArrayLen(thearray)#</cfoutput> elements.</p>
<cfloop index="i" from="1" to="#ArrayLen(thearray)#">
<cfoutput>#thearray[i].firstname#, #thearray[i].lastname# </cfoutput><br>
</cfloop>
<cfelse>
<h1>Error: thearray is not an array</h1>
</cfif><soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> |
<cffunction name = "getEmp" returntype="string" output = "no" access = "remote"> <cfargument name="empid" required="yes" type="numeric"> <cfset var fullname = ""> <cfquery name="empinfo" datasource="cfdocexamples"> SELECT emp_id, firstname, lastname FROM employee WHERE emp_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.empid#"> </cfquery> <cfif empinfo.recordcount gt 0> <cfset fullname = empinfo.lastname & ", " & empinfo.firstname> <cfelse> <cfset fullname = "not found"> </cfif> <cfreturn #fullname#> </cffunction> </cfcomponent> |
webservice = "http://some.cfc?wsdl" returnVariable = "foo" ... username="aName" password="aPassword"> <cfoutput>#foo#</cfoutput> |
<cfset isAuthorized = false> <cfif isDefined("cflogin") <!--- Verify user name from cflogin.name and password from cflogin.password using your authentication mechanism. ---> > <cfset isAuthorized = true> </cfif> </cflogin> <cfif not isAuthorized> <!--- If the user does not pass a user name/password, return a 401 error. The browser then prompts the user for a user name/password. ---> <cfheader statuscode="401"> <cfheader name="WWW-Authenticate" value="Basic realm=""Test"""> <cfabort> </cfif> |