ColdFusion 9.0 Resources |
Publishing document-literal style web servicesIn addition to RPC-oriented operations, for which consumers specify a method and arguments, ColdFusion also lets you publish web services using the document-literal style. When you use document-literal style, the WSDL for the web service tells the client to use XML schemas rather than RPC calling conventions. In most cases, the publisher of a web services identifies it as document-literal or RPC style. To identify the type, open the WSDL document and find the soap:binding element and examine its style attribute, as the following example shows: <wsdl:binding name="WeatherForecastSoap" type="tns:WeatherForecastSoap"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> In this example, the style is document-literal. Examine the WSDL to determine the methods you can call and the parameters for each method. On the client side, the cfinvoke tag and other ColdFusion methods for calling web services handle the style automatically. In most cases, no modifications are necessary. Similarly, when publishing CFCs as document-literal style web services, ColdFusion automatically creates and manages the appropriate WSDL. To publish CFCs as document-literal style web services, specify cfcomponent style="document", along with the other attributes required for document-literal style web services. For example, ColdFusion publishes the following CFC using document-literal style: <cfcomponent 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> |