<- Previous | Contents | Next -> |
PART-I
Tutorial on REST: Getting Started:
Background: REST services are a kind of web services which use http protocol behind the scenes. Geeks familiar with SOAP based web services must be thinking, Is this really possible (if they don't already know about REST architecture yet)? Yes, REST services uses HTTP architecture to get the work done and same way ColdFusion10 has beautifully used its component(cfc) to publish the REST services and cfhttp tags to consume them. For more information on REST architecture please go through this link.
Note - for simpler understanding, throughout the tutorial I will consider that ColdFusion is installed at "C:\ColdFusion10\" with webroot at "C:\ColdFusion10\cfusion\wwwroot\" and is running on port "8500".
Publishing
- After installing ColdFusion10 and setting the webroot(either through standalone or using webserver like IIS or Apache), first step required to setup REST is write a REST enabled cfc in some folder in webroot.
- Create a directory named "restApp" in webroot of ColdFusion. You can name this directory whatever you want to as this is just for your reference.
- Create a cfc named as "studentHandler.cfc". You can name this cfc as anything you want. Your REST service users will not use this name untill and unless you are mentioning "restpath" at component level in your cfc. I will come to this point later
For those who prefers to stay independent of Administrator
- Just call this function from any cfm.
- First argument to "restInitApplication" function is the absolute path where you have placed your REST component(studentHandler.cfc) and second argument is the name from which you will publish your REST application. You can give your relevant Organization name in second argument.
- If you didn't got any error after running this funtion, it means your application is registered successfully. That's it, first REST application published.
For those who prefers to use ColdFusion Administrator page (http://127.0.0.1/8500/CFIDE/administrator/index.cfm)
- After saving this file go to Administrator --> REST services page
- In Path text box give the absolute path till directory "restApp". In this example it will be "C:\ColdFusion10\cfusion\wwwroot\restApp"
- In mapping text box give some logical name for the REST application you going to create, let's say "IIT". You can give your relevant Organization name. This name will be used by users in the URL
- Hit register, and there you go. First REST application published.
Behind the scenes/tricks:
(these are quick tricks to know, but will covered in later parts of tutorial)
- When you hit 'restInitApplication()' function, ColdFusion registers your application. You can also see that application later on in Administrator REST Services page.
- When you create a REST enabled component in your webroot and register that folder, ColdFusion consider that folder as one REST application.
- As many resources(cfc or functions in cfc) as you want, can be created in one application but the only thing is that restpath for these resources should not conflict with each other.
- Nested REST applications are not allowed.
- You can keep your application outside webroot too. For this you need to add a mapping for a directory in Administrator and then you can register this directory using absolute path or mapping(the name with which you added a mapping), both will work.
- Application names are case-INsensitive.
- Calling restInitApplication() for already registered application actually REFRESH that application.
- Calling restInitApplication() with different mapping name(second attribute) will update the registered application with absolute path(first argument), with new name.
- If you want to skip giving application mapping name, you can use 'default' feature, you can set an application as default and while consuming you can call a resource without giving mapping name in URL. Keep checking this area for this point. I will write separate post for this.
- While registering an application, if application mapping name is not given, then it picks the same in the directory's(one you are trying to register) Application.cfc(this.name).
As you saw it was damn easy to publish a REST service but consuming is a lot Easier than that. All you need to do is hit this URL: http://127.0.0.1:8500/rest/IIT/student
I hope you got the response as "foo", because this is what we returned from studentHandler.cfc in function "getMethod".
How URL works:
- http://127.0.0.1:8500/ - This is a equivalent to protocol://ip:port of your server in which the REST resource is present.
- /rest/ - This string 'rest' in URL is necessary to tell ColdFusion that this is a REST call. You can change this 'rest' in server.xml
- /IIT/ - this is the mapping_name from which you registered your REST application.
- /student/ - This is the restpath of the resource you defined in studentHandler.cfc
Consuming in cfm:
- For consuming REST services in cfm file you need to call the above URL using cfhttp tag.
- Run the code given below.
- Just take care that the method in cfhttp call should be 'get', as it has to match the 'httpmethod' given in cfc.
How this works
- By looking at the URL, ColdFusion gets to know that this is a REST call and it also gets to know that for which application this call has been made because of the mapping name present in URL('IIT' in this example)
- Once we know that which application it is, we can easily get to know that which resource(cfc) has been called, because a cfc has a restpath which has to be unique for every appliction and this restpath is also included in URL('student' in this example)
- Once we get to know that which cfc has been called, we match the httpmethod of cffunction with the method of the request(cfhttp). In this example for both of them we mentioned 'GET'. So by calling a get request on this resource we hit the function whose httpmethod is 'get'.
- Once we know which cffunction to call, its very easy to return the response.
- There is also a possibility to have more than one function in same resource with different httpmethod, So it's quite possible that on calling same URL with get request you might hit one function whereas calling 'put' you might hit another. Details about this will be covered later.
Note:Application name(mapping name from which you registered your REST app) is case IN-sensitive.
<- Previous | Contents | Next -> |
Thanks,
Milan.
Hello Milan,
ReplyDeleteI'm working on CF10,IIS 7.5, Windows7 64.
Under IIS I created some virtual hosts.
I tried to register REST services specifying the absolute path (which is under a virtual host dierectory outside IIS inetpub/wwwroot) but I receive every time the "Reason: The application does not contain any rest enabled CFCs" error.
The same folder is regetered well if I move it under the inetpub/wwwroot.
Cause to the cross domain restrictions I can't test the virtual host site (which use JQuery ajax calls) referencing a CF10 REST service under the inetpub/wwwroot.
I tryied to map the folder as you indicate ("Behind the scenes/tricks" - 5) anyway the directory wasn't registered by CF10.
Is there a way to work in this scenario ?
Thank you
Hi,
DeleteWell that trick should work.
Can you try one thing.
After creating a mapping for external folder,
Try to create an object of that CFC or try to invoke that CFC using mapped folder name.
That will tell if the folder is properly mapped or not.
If it is mapped, then while registering REST, either give absolute path or mapped path in "Root path", both should work.
IEEE Final Year Project centers make amazing deep learning final year projects ideas for final year students Final Year Projects for CSE to training and develop their deep learning experience and talents.
DeleteIEEE Final Year projects Project Centers in India are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation.
corporate training in chennai corporate training in chennai
corporate training companies in india corporate training companies in india
corporate training companies in chennai corporate training companies in chennai
I have read your blog its very attractive and impressive. I like it your blog. Digital Marketing Company in Chennai
Thank you very much for this webpage. It means a lot to me and it is the most beauiful.!
ReplyDeleteDealnity is the World Largest B2B Data Base Company in Delhi Offer
ReplyDeleteHi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from Node JS Online Training from India . or learn thru Javascript Online Training from India. Nowadays JavaScript has tons of job opportunities on various vertical industry. ES6 Online Training
Can this work for ColdFusion 9?
ReplyDeleteVery nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
ReplyDeleterpa training in bangalore
best rpa training in bangalore
RPA training in bangalore
rpa course in bangalore
rpa training in chennai
rpa online training
Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
ReplyDeleteAWS TRAINING IN BTM LAYOUT | AWS TRAINING IN BANGALORE
AWS Training in Marathahalli | AWS Training in Bangalore
This is a good post. This post give truly quality information. I’m definitely going to look into it. Really very useful tips are provided here. thank you so much. Keep up the good works.
ReplyDeleteonline Python training
python training in chennai
I think this is the best article today about the future technology. Thanks for taking your own time to discuss this topic, I feel happy about that curiosity has increased to learn more about this topic.Artificial Intelligence Training in Bangalore. Keep sharing your information regularly for my future reference.
ReplyDeleteAwesome article. It is so detailed and well formatted that i enjoyed reading it as well as get some new information too.
ReplyDeleteAWS Training in Bangalore
AWS training in sholinganallur
AWS training in Tambaram
AWS training in Velachery
This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.
ReplyDeleteoneplus service centre
oneplus mobile service center in chennai
Hearty thanks to you admin, your blog is awesome and helpful. Keep your blog with latest information.
ReplyDeleteRPA Training in Chennai
Robotics Process Automation Training in Chennai
Blue Prism Training in Chennai
UiPath Training in Chennai
Data Science Course in Chennai
RPA Training in Anna Nagar
RPA Training in Chennai
RPA course in Chennai
Thanks for sharing informative article… learning driving from experienced instructors help you to learn driving very fast… Learn Melbourne driving lessons from experts at Sprint driving School. Check our driving lesson prices
ReplyDeleteReally nice post. Provided a helpful information. I hope that you will post more updates like this
ReplyDeleteAWS Online Training
AI Training
Big Data Training
Awesome Post. Have been waiting for a long time. Thanks for sharing this info with us.
ReplyDeleteSpoken English Classes in Chennai Anna Nagar
Spoken English Class in Porur
Spoken English Class in Vadapalani
Spoken English Class in Thiruvanmiyur
Spoken English Class in Chennai
Best English Speaking Classes in Mumbai
English Speaking Course in Mumbai
IELTS Training in Chennai
IELTS Coaching in Chennai
IELTS Mumbai
Thanks for adding good article here...
ReplyDeletePCSO Lotto Results | PCSO Lotto Result
Really a awesome blog for the freshers. Thanks for posting the information.
ReplyDeleteGerman Classes in Chennai
German Courses in Chennai
French Language Classes in Chennai
pearson vue exam centers in chennai
Informatica MDM Training in Chennai
Hadoop Admin Training in Chennai
German Classes in Porur
German Classes in Velachery
Thanks for sharing your valuable information. If you are looking for car mechanic in south Melbourne Please Visit us: Abarth Automotive
ReplyDeleteFlying Shift - Packers & Movers in Bhopal
ReplyDeleteAwesome post. Good Post. I like your blog. You Post is very informative. Thanks for Sharing.
ReplyDelete.NET Training in Noida
Data Warehousing Training in Noida
Ethical Hacking Training in Noida
Digital Marketing course in Noida
Web Development course in Noida
Java Training in Noida
Great article! It is really helpful for my research. Do post and share more such wonderful content and keep updating. Seeing to more unique informative from the admin.
ReplyDeleteOracle Training in Chennai
best oracle training institute in chennai
Corporate Training in Chennai
Embedded System Course Chennai
Unix Training in Chennai
Job Openings in Chennai
Pega Training in Chennai
Spark Training in Chennai
Excel Training in Chennai
Soft Skills Training in Chennai
JMeter Training in Chennai
Oracle Training in Anna Nagar
Popular Fashion Blogs in Surat
ReplyDeleteFashion Blogger in Surat
Surat Blogger
Indian Fashion Blogger
Fashion Blogger in India
Thanks for excellent article. Moving Men Removals is the renowned local removalists Melbourne.
ReplyDeleteWonderful blog with great piece of information. Regards to your effort. Keep sharing more such blogs. Looking forward to learn more from you.
ReplyDeleteAWS Training in Chennai
AWS Certification in Chennai
Best AWS Training in Chennai
Cloud Computing Training in Chennai
RPA Training in Chennai
Data Science Training in Chennai
AWS training in Guindy
AWS training in Vadapalani
AWS Training in Anna nagar
AWS Training in Velachery
Thank you for sharing this blog post, it is very informative and helpful for me. building and pest inspections Melbourne.
ReplyDeleteGreat information… Domestic oven detailers are premium over cleaners in Melbourne offering affordable oven & BBQ cleaning by trained professionals.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteGreat blog thanks for sharing Instagram and Facebook have provided an amazing place for new brands to grow and flourish. We can find the perfect niche for your brand on the best social media platforms. Marketing through social media brings forth global audience without all these physical boundaries.
ReplyDeleteseo service in chennai
Nice blog thanks for sharing Tidy up your ambience by decorating them with amazing landscape plants in Chennai. Karuna Nursery Gardens is your portal to all the green that the world has to offer. Revolutionize your indoors, garden, terrace or office right now with us.
ReplyDeletecorporate gardening service in chennai
Excellent blog thanks for sharing Shopping for international cosmetics in Chennai? Look no further, the Pixies Beauty Shop has got your back with hundreds of international brands to choose from, that too with the best value.
ReplyDeletebeauty Shop in Chennai
Very useful blog thanks for sharing IndPac India the German technology Packaging and sealing machines in India is the leading manufacturer and exporter of Packing Machines in India.
ReplyDeleteOur training institute is the best place to learn foreign languages. Enroll for the best Japanese Language training center in Bangalore. Our Foreign Language School specialises in Japanese language education. Join the best foreign language classes, training institute, coaching centers, tutors, instructors in Bangalore.
ReplyDeleteJapanese Language Training in Bangalore
Japanese Training Institute in Bangalore
Japanese Institute in Bangalore
Japanese Language Institute
Indian Institute of Japanese & Japanese Language
Japanese Learning
Japanese Language Institute in Bangalore
Japanese Courses
Japanese language course in Bangalore
learn Japanese language in Bangalore
Japanese language basics learning in Bangalore
learn Japanese grammar in Bangalore
Japanese learning centres contact addresses in Bangalore
Japanese grammer tuition phone numbers in Bangalore
reviews of Japanese language learning centres in Bangalore
ratings of Japanese spoken classes in Bangalore
SAP FICO Training in Bangalore with 100% placement. We are the Best SAP FICO Training Institute in Bangalore. Our SAP FICO courses are taught by working professionals who are experts in.
ReplyDeletesap fico training in bangalore
sap fico courses in bangalore
sap fico classes in bangalore
sap fico training institute in bangalore
sap fico course syllabus
best sap fico training
sap fico training centers
ReplyDeleteData Analytics Course in Bangalore with 100% placement. We are the Best Data Analytics Course Institute in Bangalore. Our Data Analytics course and Certification courses are taught by working professionals who are experts in Data Analytics.
Data Analytics Training in Bangalore
Data Analytics course in bangalore
Data Analytics in bangalore
Data Analytics classes in bangalore
Data Analytics course institute in bangalore
Data Analytics course and Certification course syllabus
best Data Analytics course
Data Analytics course centers
Our training institute is the best place to learn foreign languages. Enroll for the best Italian Language training center in Bangalore. Our Foreign Language School specialises in Italian language education. Join the best foreign language classes, training institute, coaching centers, tutors, instructors in Bangalore.
ReplyDeleteItalian Language Training In Bangalore
Italian Training Institute in Bangalore
Italian Institute in Bangalore
Italian Language Institute
Indian Institute of Italian & Italian Language
Italian Learning
Italian Language Institute in Bangalore
Italian Courses
Italian language course in Bangalore
learn Italian language in Bangalore
Italian language basics learning in Bangalore
learn Italian grammar in Bangalore
Italian learning centres contact addresses in Bangalore
Italian grammer tuition phone numbers in Bangalore
reviews of Italian language learning centres in Bangalore
ratings of Italian spoken classes in Bangalore
Thanks for sharing the great information. Car Service Bentleigh | Mechanic Hughesdale
ReplyDeleteThis article looks great thanks for the information Car Service Clayton South | Tyres Clayton
ReplyDeleteThanks for posting the valuable information's the Blogs contains a much needed information's to enhance the knowledge..Thanks for sharing
ReplyDeletepython training in chennai | python training in annanagar | python training in omr | python training in porur | python training in tambaram | python training in velachery
Looking for best Tamil typing tool online, make use of our Tamil Virtual keyboard online to type in Tamil on web browser and share it on your social media handle. Tamil Typing Software Download
ReplyDeleteThanks for posting the valuable information's the Blogs contains a much needed information's to enhance the knowledge..Thanks for sharing
ReplyDeleteAWS training in Chennai
AWS Online Training in Chennai
AWS training in Bangalore
AWS training in Hyderabad
AWS training in Coimbatore
AWS training
Thanks for sharing informative post. We are reputed removalists in Melbourne Eastern Suburbs offer professional house removals Melbourne & furniture Removals Melbourne.
ReplyDeleteThanks for sharing informative post. We are reputed removalists in Melbourne Eastern Suburbs offer professional house removals Melbourne & furniture Removals Melbourne.
ReplyDelete