July 8, 2004
Web Services a quickie
Web Services is a term that has come to encompass the ways for discovering software as services accross the web. Services can be truly exploited with CFMX in a very easy manner.
Web services group together several different technologies, SOAP, WSDL, and UDDI. Simple Object Access Protocal, SOAP, is an XML envelope describing how to use and what is there. In addition within the envelop is the rules for how to process. WSDL or Web Services Description Language is an XML of the service interface and directions of how to use. UDDI is short for Universal Description, Discover, and Integration and is the way to describe a web service. UDDI registries allow business to publish and query existing web services.
Using Web Services is exceptionately easy with coldfusion.
For example here is a Service that calculates BMI: I had the file in the http://localhost/bmi/bmi.cfc of my development maching.
<cffunction name="calculateBMI" access="remote" returntype="numeric" hint="This function calculates an individuals Body Mass Index">
<cfargument name="WeightLbs" type="numeric" required="yes" hint="The person's weight in pounds">
<cfargument name="HeightInches" type="numeric" required="yes" hint="The person's height in inches">
<cfset HeightInchesSquared = HeightInches * HeightInches>
<cfset WHI = WeightLbs / HeightInchesSquared>
<cfset BMI = WHI * 703>
<cfreturn DecimalFormat(BMI)>
</cffunction>
</cfcomponent>
And here is an example consuming that service
<cfinvoke webservice="http://localhost/bmi/bmi.cfc?wsdl" method="calculateBMI" returnvariable="varBMI">
<cfinvokeargument name="WeightLbs" value="140">
<cfinvokeargument name="HeightInches" value="72">
</cfinvoke>
And finally so everything is in one place here is an example of the wsdl for that service.
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions targetNamespace="http://bmi" xmlns:impl="http://bmi" xmlns:intf="http://bmi" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns1="http://rpc.xml.coldfusion" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
- <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://rpc.xml.coldfusion">
<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="calculateBMIResponse">
<wsdl:part name="calculateBMIReturn" type="xsd:double" />
</wsdl:message>
- <wsdl:message name="calculateBMIRequest">
<wsdl:part name="WeightLbs" type="xsd:double" />
<wsdl:part name="HeightInches" type="xsd:double" />
</wsdl:message>
- <wsdl:portType name="bmi">
- <wsdl:operation name="calculateBMI" parameterOrder="WeightLbs HeightInches">
<wsdl:input name="calculateBMIRequest" message="impl:calculateBMIRequest" />
<wsdl:output name="calculateBMIResponse" message="impl:calculateBMIResponse" />
<wsdl:fault name="CFCInvocationException" message="impl:CFCInvocationException" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="bmi.cfcSoapBinding" type="impl:bmi">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="calculateBMI">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="calculateBMIRequest">
<wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://bmi" />
</wsdl:input>
- <wsdl:output name="calculateBMIResponse">
<wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://bmi" />
</wsdl:output>
- <wsdl:fault name="CFCInvocationException">
<wsdlsoap:fault use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://bmi" />
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="bmiService">
- <wsdl:port name="bmi.cfc" binding="impl:bmi.cfcSoapBinding">
<wsdlsoap:address location="http://localhost/bmi/bmi.cfc" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Good article it clarified much. Only problem, when I tried to print this for easy reading, it really came out screwy on the printer.
Posted by: fats at July 27, 2004 10:39 AMFinally passed the test
Managing in light of McGregor's Theory X and Theory Y
CMMI
Kicking HIT Leadership Up a Notch
That's just some mumbo jumbo project management BS
Outcomes - The tactic to get to the strategy
Nurse Call, VOIP, and Wi-Fi: Its just cool when things come together!
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
December 2006
November 2006
August 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
November 2005
October 2005
September 2005
August 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
December 2003
November 2003
October 2003
Joel on Software
David Ross
Edward Prevost
Martin Fowler
The Health Care Blog
The Tales of Hoffman
The Business Word
Medical Rants
Christina's Considerations
Paul Levy
HIS Talk
Appropriate IT
Candid CIO
RSS feed




