SlideShare a Scribd company logo
1 of 11
Powerpoint TemplatesPowerpoint Templates
RESTful API’s with ColdFusion
Kevin Schmidt
kevins@adobe.com
@kevpocalypse
Powerpoint Templates
Who am I?
Kevin Schmidt
Solution Engineer
Email: kevins@adobe.com
Twitter: @kevpocalypse
Blog: www.underprise.com
Powerpoint Templates
About REST
What is REST?
REST (REpresentational State Transfer) is an architectural style, and
an approach to communications that is often used in the development
of Web services.
Why REST?
The use of REST is often preferred over the more heavyweight SOAP
(Simple Object Access Protocol) style because REST does not
leverage as much bandwidth, which makes it a better fit for use over
the Internet. The SOAP approach requires writing or using a provided
server program (to serve data) and a client program (to request data).
Powerpoint Templates
REST Details
REST Contraints:
 Decouples consumers from producers
 Stateless existence
 Able to leverage a cache
 Leverages a layered system
 Leverages a uniform interface
REST Verbs:
•POST - Create
•GET - Read
•PUT - Update
•DELETE – Delete
Want to Geek Out?
Roy Fielding’s Dissertation:
http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.html
Powerpoint Templates
ColdFusion and REST
You can create REST services by defining certain attributes in the tags
cfcomponent, cffunction, and cfargument and publish as REST
resources.
•Follows HTTP request-response model: Beyond having HTTP as a medium,
the service lets you follow all HTTP norms. The components published as REST
services can be consumed over HTTP/HTTPS request. The REST services are
identified with URI (Uniform Resource Identifier) and can be accessed from a
web page as well as by specifying the URI in the browser's address bar.
•Supports all HTTP methods : The REST enabled CFCs support the following
HTTP methods: GET, POST, PUT, DELETE, HEAD, and OPTIONS.
•Implicit handling of serialization/deserialization: ColdFusion natively supports
JSON and XML serialization/deserialization. So client applications can consume
REST services by issuing HTTP/HTTPS request. The response can either be
serialized to XML or JSON format.
•Publish web service as both REST service and WSDL service: You can create
and publish the same ColdFusion component as a REST service and WSDL
service.
Powerpoint Templates
ColdFusion and REST
Creating the REST web service
You can create and publish a ColdFusion component or any functions in a
component as REST resource.
To create a CFC as REST web service, specify either of the following in the tag
cfcomponent: restPath or rest.
In cffunction, set the attribute access to remote for the functions that you have to
expose as REST resource.
Example:
<cfcomponent rest="true" restpath="/person">
<cffunction name="getAll” returntype="string” access="remote” httpmethod="GET”
produces="application/json”>
<cfset var response = Application['PersonGateway'].getAll() />
<cfreturn serializeJSON(response) />
</cffunction>
</cfcomponent>
Powerpoint Templates
ColdFusion and REST
Registering an application with the REST service
After you create the CFC you want to REST-enable, specify the folder
for registering as web service either using the autoRegister Application
setting, the function restInitAplication() or in the ColdFusion
Administrator or using the ColdFusion Admin API.
If you are in a shared environment:
<cfset this.restsettings.autoregister = true />
restInitApplication(rootPath[,serviceMapping[,options]])
These options not require administrator privileges.
Powerpoint Templates
ColdFusion and REST
Sample URI:
http://localhost:8500/rest/restTest/restService
URL Component Description
http://localhost:8500 Base URL which includes the IP address and port of the ColdFusion server.If you
deploy ColdFusion as a JEE application, the URL will contain a context root, for
example,
http://localhost:8500*/cfusion*
rest Implies that the request sent is a REST request.This default value can be
renamed by revising the context path in web.xml available at
cfusion/wwroot/WEB-INF and update the same mapping in
uriworkermap.properties file found at configwsconfig1.
restTest Application name or service mapping that you have used while registering the
service in ColdFusion Administrator. If you do not specify a service mapping in the
ColdFusion Administrator, then the application name is taken from Application.cfc.
restService Rest path you defined in the service. That is, the value of the attribute restPath in
the tag cfcomponent.
Powerpoint Templates
ColdFusion and REST
Default Response Description
200 OK Sent if the response has a body.
204 No Content Sent if the response doesn’t have a body.
Default Response Description
404 Not Found Request URL is not valid
406 Not Acceptable No function in the REST service can produce the MIME
type requested by the client
415 Unsupported Media Type A resource is unable to consume the MIME type of the
client request
405 Method not allowed If the client invokes an HTTP method on a valid URI to
which the request HTTP method is not bound.
Custom responses can be created using the restSetResponse method for
success or <cfthrow type=“RestError”> for errors.
Powerpoint Templates
DEMO
Powerpoint Templates
Questions? Comments? Insults?

More Related Content

Similar to Restful API's with ColdFusion

Creating Web Services with Zend Framework - Matthew Turland
Creating Web Services with Zend Framework - Matthew TurlandCreating Web Services with Zend Framework - Matthew Turland
Creating Web Services with Zend Framework - Matthew Turland
Matthew Turland
 
Transform-to-Smart-ERP-using-Custom-Mobile-Apps.pptx
Transform-to-Smart-ERP-using-Custom-Mobile-Apps.pptxTransform-to-Smart-ERP-using-Custom-Mobile-Apps.pptx
Transform-to-Smart-ERP-using-Custom-Mobile-Apps.pptx
kmani5
 
Transform-to-Smart-ERP-using-Custom-Mobile-Apps.pptx (3).ppt
Transform-to-Smart-ERP-using-Custom-Mobile-Apps.pptx (3).pptTransform-to-Smart-ERP-using-Custom-Mobile-Apps.pptx (3).ppt
Transform-to-Smart-ERP-using-Custom-Mobile-Apps.pptx (3).ppt
HusseinWassof
 

Similar to Restful API's with ColdFusion (20)

How we rest
How we restHow we rest
How we rest
 
KaTe RESTful adapter for SAP Process Integration: Introduction
KaTe RESTful adapter for SAP Process Integration: IntroductionKaTe RESTful adapter for SAP Process Integration: Introduction
KaTe RESTful adapter for SAP Process Integration: Introduction
 
Introduction To REST
Introduction To RESTIntroduction To REST
Introduction To REST
 
Building Restful Applications Using Php
Building Restful Applications Using PhpBuilding Restful Applications Using Php
Building Restful Applications Using Php
 
Rest web service
Rest web serviceRest web service
Rest web service
 
Introduction to the Client OM in SharePoint 2010
Introduction to the Client OM in SharePoint 2010Introduction to the Client OM in SharePoint 2010
Introduction to the Client OM in SharePoint 2010
 
What are restful web services?
What are restful web services?What are restful web services?
What are restful web services?
 
Creating Web Services with Zend Framework - Matthew Turland
Creating Web Services with Zend Framework - Matthew TurlandCreating Web Services with Zend Framework - Matthew Turland
Creating Web Services with Zend Framework - Matthew Turland
 
REST Servers in Delphi XE Using DataSnap
REST Servers in Delphi XE Using DataSnapREST Servers in Delphi XE Using DataSnap
REST Servers in Delphi XE Using DataSnap
 
SPFx Webinar Loading SharePoint data in a SPFx Webpart
SPFx Webinar Loading SharePoint data in a SPFx WebpartSPFx Webinar Loading SharePoint data in a SPFx Webpart
SPFx Webinar Loading SharePoint data in a SPFx Webpart
 
Transform-to-Smart-ERP-using-Custom-Mobile-Apps.pptx
Transform-to-Smart-ERP-using-Custom-Mobile-Apps.pptxTransform-to-Smart-ERP-using-Custom-Mobile-Apps.pptx
Transform-to-Smart-ERP-using-Custom-Mobile-Apps.pptx
 
Transform-to-Smart-ERP-using-Custom-Mobile-Apps.pptx (3).ppt
Transform-to-Smart-ERP-using-Custom-Mobile-Apps.pptx (3).pptTransform-to-Smart-ERP-using-Custom-Mobile-Apps.pptx (3).ppt
Transform-to-Smart-ERP-using-Custom-Mobile-Apps.pptx (3).ppt
 
ASP.NET WEB API Training
ASP.NET WEB API TrainingASP.NET WEB API Training
ASP.NET WEB API Training
 
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
 
RESTful WCF Services
RESTful WCF ServicesRESTful WCF Services
RESTful WCF Services
 
ColdFusion 10
ColdFusion 10ColdFusion 10
ColdFusion 10
 
JavaOne 2009 - TS-5276 - RESTful Protocol Buffers
JavaOne 2009 - TS-5276 - RESTful  Protocol BuffersJavaOne 2009 - TS-5276 - RESTful  Protocol Buffers
JavaOne 2009 - TS-5276 - RESTful Protocol Buffers
 
LAJUG Napster REST API
LAJUG Napster REST APILAJUG Napster REST API
LAJUG Napster REST API
 
APEX, restful services and STRIPE
APEX, restful services and STRIPEAPEX, restful services and STRIPE
APEX, restful services and STRIPE
 
REST full API Design
REST full API DesignREST full API Design
REST full API Design
 

More from ColdFusionConference

More from ColdFusionConference (20)

Api manager preconference
Api manager preconferenceApi manager preconference
Api manager preconference
 
Cf ppt vsr
Cf ppt vsrCf ppt vsr
Cf ppt vsr
 
Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server Databases
 
API Economy, Realizing the Business Value of APIs
API Economy, Realizing the Business Value of APIsAPI Economy, Realizing the Business Value of APIs
API Economy, Realizing the Business Value of APIs
 
Don't just pdf, Smart PDF
Don't just pdf, Smart PDFDon't just pdf, Smart PDF
Don't just pdf, Smart PDF
 
Crafting ColdFusion Applications like an Architect
Crafting ColdFusion Applications like an ArchitectCrafting ColdFusion Applications like an Architect
Crafting ColdFusion Applications like an Architect
 
Security And Access Control For APIS using CF API Manager
Security And Access Control For APIS using CF API ManagerSecurity And Access Control For APIS using CF API Manager
Security And Access Control For APIS using CF API Manager
 
Monetizing Business Models: ColdFusion and APIS
Monetizing Business Models: ColdFusion and APISMonetizing Business Models: ColdFusion and APIS
Monetizing Business Models: ColdFusion and APIS
 
Become a Security Rockstar with ColdFusion 2016
Become a Security Rockstar with ColdFusion 2016Become a Security Rockstar with ColdFusion 2016
Become a Security Rockstar with ColdFusion 2016
 
ColdFusion in Transit action
ColdFusion in Transit actionColdFusion in Transit action
ColdFusion in Transit action
 
Developer Insights for Application Upgrade to ColdFusion 2016
Developer Insights for Application Upgrade to ColdFusion 2016Developer Insights for Application Upgrade to ColdFusion 2016
Developer Insights for Application Upgrade to ColdFusion 2016
 
Where is cold fusion headed
Where is cold fusion headedWhere is cold fusion headed
Where is cold fusion headed
 
ColdFusion Keynote: Building the Agile Web Since 1995
ColdFusion Keynote: Building the Agile Web Since 1995ColdFusion Keynote: Building the Agile Web Since 1995
ColdFusion Keynote: Building the Agile Web Since 1995
 
Instant ColdFusion with Vagrant
Instant ColdFusion with VagrantInstant ColdFusion with Vagrant
Instant ColdFusion with Vagrant
 
Super Fast Application development with Mura CMS
Super Fast Application development with Mura CMSSuper Fast Application development with Mura CMS
Super Fast Application development with Mura CMS
 
Build your own secure and real-time dashboard for mobile and web
Build your own secure and real-time dashboard for mobile and webBuild your own secure and real-time dashboard for mobile and web
Build your own secure and real-time dashboard for mobile and web
 
Why Everyone else writes bad code
Why Everyone else writes bad codeWhy Everyone else writes bad code
Why Everyone else writes bad code
 
Securing applications
Securing applicationsSecuring applications
Securing applications
 
Testing automaton
Testing automatonTesting automaton
Testing automaton
 
Rest ful tools for lazy experts
Rest ful tools for lazy expertsRest ful tools for lazy experts
Rest ful tools for lazy experts
 

Recently uploaded

Recently uploaded (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Restful API's with ColdFusion

  • 1. Powerpoint TemplatesPowerpoint Templates RESTful API’s with ColdFusion Kevin Schmidt kevins@adobe.com @kevpocalypse
  • 2. Powerpoint Templates Who am I? Kevin Schmidt Solution Engineer Email: kevins@adobe.com Twitter: @kevpocalypse Blog: www.underprise.com
  • 3. Powerpoint Templates About REST What is REST? REST (REpresentational State Transfer) is an architectural style, and an approach to communications that is often used in the development of Web services. Why REST? The use of REST is often preferred over the more heavyweight SOAP (Simple Object Access Protocol) style because REST does not leverage as much bandwidth, which makes it a better fit for use over the Internet. The SOAP approach requires writing or using a provided server program (to serve data) and a client program (to request data).
  • 4. Powerpoint Templates REST Details REST Contraints:  Decouples consumers from producers  Stateless existence  Able to leverage a cache  Leverages a layered system  Leverages a uniform interface REST Verbs: •POST - Create •GET - Read •PUT - Update •DELETE – Delete Want to Geek Out? Roy Fielding’s Dissertation: http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.html
  • 5. Powerpoint Templates ColdFusion and REST You can create REST services by defining certain attributes in the tags cfcomponent, cffunction, and cfargument and publish as REST resources. •Follows HTTP request-response model: Beyond having HTTP as a medium, the service lets you follow all HTTP norms. The components published as REST services can be consumed over HTTP/HTTPS request. The REST services are identified with URI (Uniform Resource Identifier) and can be accessed from a web page as well as by specifying the URI in the browser's address bar. •Supports all HTTP methods : The REST enabled CFCs support the following HTTP methods: GET, POST, PUT, DELETE, HEAD, and OPTIONS. •Implicit handling of serialization/deserialization: ColdFusion natively supports JSON and XML serialization/deserialization. So client applications can consume REST services by issuing HTTP/HTTPS request. The response can either be serialized to XML or JSON format. •Publish web service as both REST service and WSDL service: You can create and publish the same ColdFusion component as a REST service and WSDL service.
  • 6. Powerpoint Templates ColdFusion and REST Creating the REST web service You can create and publish a ColdFusion component or any functions in a component as REST resource. To create a CFC as REST web service, specify either of the following in the tag cfcomponent: restPath or rest. In cffunction, set the attribute access to remote for the functions that you have to expose as REST resource. Example: <cfcomponent rest="true" restpath="/person"> <cffunction name="getAll” returntype="string” access="remote” httpmethod="GET” produces="application/json”> <cfset var response = Application['PersonGateway'].getAll() /> <cfreturn serializeJSON(response) /> </cffunction> </cfcomponent>
  • 7. Powerpoint Templates ColdFusion and REST Registering an application with the REST service After you create the CFC you want to REST-enable, specify the folder for registering as web service either using the autoRegister Application setting, the function restInitAplication() or in the ColdFusion Administrator or using the ColdFusion Admin API. If you are in a shared environment: <cfset this.restsettings.autoregister = true /> restInitApplication(rootPath[,serviceMapping[,options]]) These options not require administrator privileges.
  • 8. Powerpoint Templates ColdFusion and REST Sample URI: http://localhost:8500/rest/restTest/restService URL Component Description http://localhost:8500 Base URL which includes the IP address and port of the ColdFusion server.If you deploy ColdFusion as a JEE application, the URL will contain a context root, for example, http://localhost:8500*/cfusion* rest Implies that the request sent is a REST request.This default value can be renamed by revising the context path in web.xml available at cfusion/wwroot/WEB-INF and update the same mapping in uriworkermap.properties file found at configwsconfig1. restTest Application name or service mapping that you have used while registering the service in ColdFusion Administrator. If you do not specify a service mapping in the ColdFusion Administrator, then the application name is taken from Application.cfc. restService Rest path you defined in the service. That is, the value of the attribute restPath in the tag cfcomponent.
  • 9. Powerpoint Templates ColdFusion and REST Default Response Description 200 OK Sent if the response has a body. 204 No Content Sent if the response doesn’t have a body. Default Response Description 404 Not Found Request URL is not valid 406 Not Acceptable No function in the REST service can produce the MIME type requested by the client 415 Unsupported Media Type A resource is unable to consume the MIME type of the client request 405 Method not allowed If the client invokes an HTTP method on a valid URI to which the request HTTP method is not bound. Custom responses can be created using the restSetResponse method for success or <cfthrow type=“RestError”> for errors.