Entries for month: “June 2012”
I am pleased to be able to make the announcement that I've just rejoined Adobe and the ColdFusion team as the new Solution Consultant and product Evangelist. I'm extremely excited for this opportunity and can't wait to get started. I'll most likely be meeting many of you at any of the upcoming events or customer meetings if I don't know you already. Thank you for the warm welcomes I've received from so many of you already!
Adobe ColdFusion 10 | Adobe ColdFusion Builder 2.0.1 | Rapid Application Development | web application development | web programming | Adobe ColdFusion | CFBuilder | Announcements
We have had some valuable contributions to the ColdFusion 10 and ColdFusion Builder 2.0.1 pre-release. The participants showed a lot of interest in ensuring that they give maximum feedback to the product team. This just goes on to the show passion that you have for the product. Thanks to each and everyone one of you who participated in the pre-release program for ColdFusion 10. The product team values every contribution that was made. We will look forward to your contributions as we move towards building the next major version of ColdFusion.
Now to reward the top contributors of the pre-release.The top three contributors each will get a license for ColdFusion 10 Enteprise. The other two contributors following the three contributors will get a license for ColdFusion Builder.
Both the pre-release forum participation and the bugs filed were considered to identify the top contributions.
Here are the top three contributors who will get a license for ColdFusion 10 Enterprise.
Adam Cameron, Aaron Neff and Raymond Camden
The other two contributors who will get a license for ColdFusion Builder are:
David McGuigan and Charlie Arehart
Congratulations to all of you!
And thanks once again to everyone who took time to participate in the pre-release.
Convert a html document to PDF using ColdFusion <cfdocument> and REST power.
If you are not sure about how to start with REST, you can read my blogs here.
So let's write a CFC which will be exposed as pdf service using REST api.
Over here we have exposed a ColdFusion component as a REST resource - pdf, which will accept an html body and will return a pdf file in binary.
In the only function present, I am accepting POST request and will produce the content in "application/xml" format. POST request will be accepted because my httpmethod attribute in the function is POST and produces attribute is "application/xml" so it will produce xml content.
There is a point to note that even though I am producing xml content but still the produced string will not contain any xml tags. That is because ColdFusion only serializes the return variable in xml/json if it is complex variable like an Array, a Struct, a CFC etc.. As we are producing a binary which is a simple data type, so it will not be serialized rather will be returned as it is.
For consuming the data I am looking for argument in body of the request. Generally you will find the restargsource attribute present in <cfargument> tag to tell you where to look for the data. But if it's absent ColdFusion looks for the argument in the body of request.
Inside the function I am using <cfdocument> tag to convert the HTML body passed from client into PDF file. This PDF file will be saved in a variable name "pdffile" in binary format. And then returning this pdffile as it is in binary format back to the client.
Client side can be written in any language but here I will write an exmaple in ColdFusion itself.
All we need to do in client side is to call this service with POST http request and pass the HTML content in the body of the request.
In this example I am reading a html file from local directory and passing it's content to the service we just exposed.
And finally we are saving the result we have got back to sample.pdf
That's it. We are done.
ColdFusion | Zeus
check complete tutorial here
Tutorial on REST: First REST Resource(cfc)
In first part we saw a simple example on REST to start off the things. So moving forward I will give another very simple example and will explain it.
<cfcomponent restpath="HelloWorld" httpmethod="post" rest="true">
<cffunction name="World" access="remote" output="false" returntype="string" httpmethod="get">
<cfreturn "Hello World!">
<cffunction name="HiWorld" access="remote" output="false" returntype="string" httpmethod="get" restpath="HiWorld">
<cfreturn "Hi World!">
<cfhttp url="http://127.0.0.1:8500/rest/IIT/HelloWorld" method="get" result="res">
<cfhttp url="http://127.0.0.1:8500/rest/IIT/HelloWorld/HiWorld" method="get" result="res">
- Every component and every function acts as a REST resource(if you are publishing them).
- A new attribute in cfcomponent 'restpath' OR 'rest' defines if a component can be published as a REST resource. Either of these should be present.
- Attribute 'httpmethod' should be there in cffunction tag or cfcomponent tag. 'httpmethod' in cffunction tag overrides the one in cffcomponent tag. To publish/expose a function as resource, this attribute is necessary. Valid values for this are 'GET', 'POST', 'PUT', 'DELETE', 'OPTION', 'HEAD'.
- Similar to 'httpmethod', 'restpath' can also be used in cffunction tag but it doesn't overrides the value of 'restpath' in cffcomponent tag , instead it appends to it. So if you want to call this function(resource), you need to give both the restpath's in URL. Check helloWorld.cfm's second http call for clearer picture
- Keeping other things simple like 'access=remote'(required for REST/WEB services) and 'returntype=string', lets see how can we call this service.
Note: After writing a cfc(at-least one) in webroot, you need to register the folder(in which that REST cfc is present) as REST application, otherwise you will not be able to call any resource. Please check previous chapter for that.
- Considering that you registered this application with name 'IIT', the URL to access first resource(function HelloWorld) will be: http://127.0.0.1:8500/rest/IIT/HelloWorld
- So to access that resource all you need to do is, use cfhttp tag and call this URL. Keep in mind that method in cfhttp tag will match to the httpmethod present in function.
- Similarly to call the second Resource in cfc(function HiWorld), the URL will be: http://127.0.0.1:8500/rest/IIT/HelloWorld/HiWorld
- To call this from a cfm you need to call this URL using cfhttp tag with httpmethod as get.
how the URL works:
Breaking the URL for better understading
- http://127.0.0.1:8500/ - protocol//ip:port/
- rest/ - Compulsary string to call a REST resource. You can change this 'rest' string in server.xml and restart the server for changes to take effect.
- Examples/ - Mapping name you give to register an application using Administrator or restInitApplication method(Check next example for this) .
- HelloWorld/ - RestPath to call a resource. This was given as 'restpath' attribute in cfcomponent level.
- HiWorld/ - If your function also has a restpath then after giving a restpath for your component you need to give restpath for function also to call that function.
check complete tutorial here
Rapid Application Development | creating a website | web application security | productivity | scripting language | Adobe ColdFusion | Announcements | HTML5
I have posted the Adobe ColdFusion Mobile and HTML5 survey here. Please spare a few minutes to help Adobe take the right steps to build the future of the product that you love - Adobe ColdFusion!