Tech Sharing

Tech Sharing

Advertisement

Posts Tagged ‘ Coldfusion ’

Using web service is one of the good solution when you try to consume 3th party or integrate your system with other system without knowing how their internal logic.

When you try to call the web service for the first time, CF actually will chace the web service by using the web service description (WSDL) that response from the target server to create a java proxy/stub based on that, than it will be reused for the following call from CF to the same web service again.

CF doing that is actually try to improve the performance for the web service calling, but it come with some disadvantage when the target web service being changed by adding a new require parameter or return an extra parameter, your script will trigger an error message, this is because your CF have no knowledge about the new changing make on the target site. It will continue to use the older cached proxy/stub.

To resolved this problem, you may need to manually refresh the cache that created by the CF in the early call to inform CF to refresh it’s cache of that proxy stub.

There are more than 1 way that you can doing that, the following are the sample 4 difference way to achieve the same result:

I. ColdFusion Administrator

CF-Admin-Web-Services-Refresh

 

II. Programatically:

In ColdFusion 8, you have two options:

i. Cfinvoke’s refreshWSDL attribute:

<cfinvoke webservice="#wsdl#" method="method" returnvariable="rv"<br />refreshWSDL="yes"><br />	<cfinvokeargument name="arg" value="1"/><br /></cfinvoke>

 

ii. Cfobject’s arguments structure

<br /><cfscript><br />    wsargs = structnew();<br />    wsargs.refreshwsdl="yes";<br />    somevar = createobject("webservice","http://[server]/webserviceurl]",wsargs);<br />    ...<br /></cfscript><br />

In ColdFusion 7, however, you can use the following solution:

<cfset wsAddress = "http://your.web/service/url.cfc?wsdl"><br /><!--- CF7 ---><br /><cfset createObject("java", "coldfusion.server.ServiceFactory").<br />XmlRpcService.refreshWebService(wsAddress) />

 

 

The most easy way to convert ColdFusion query column to array

tech.david-cheong.com

There are few ways to do the same thing, you may query out the data from the Database using query, than loop through all the row in the result set and append the item one by one. But the ColdFusion already come with the bulid-in function for the easy of programmer, the syntax is ValueList

tech.david-cheong.com

<cfset myList = ValueList(query.columnname)>

tech.david-cheong.com
As with all of the list functions, there’s an optional delimiter attribute.

<cfset myList = ValueList(query.columnname,"|")>

tech.david-cheong.com
If you need the values in the list to have double-quotes around them, use QuotedValueList.

<cfset myList = QuotedValueList(query.columnname)>

The server lockdown guide for ColdFusion 10 is now available on the Adobe website. The ColdFusion 10 Server Lockdown Guide will help server administrators secure their ColdFusion 10 installations. You will also find several tips and suggestions intended to improve the security of your ColdFusion server.

 

ColdFusion 10 Server Lockdown Guide (841)

Merging Two Structs in ColdFusion

By on November 26, 2012

The following script showing how to merge 2 ColdFusion structure into one. The following sample showing 2 difference structure which each has two keys

tech.david-cheong.com

<!--- Struct1 have 2 key: FirstName and Last time --->
<cfset struct1={firstname="Adam" ,lastname="Presley" }>

<!--- Struct 2 have 2 key: FirstName and age --->
<cfset struct2={ firstname="Michael" ,age="33" }>

<!--- Using a nifty ColdFusion method we can mash the two together in a single line of code. --->

<cfset structAppend(struct1, struct2) /> <!--- <cfset struct1.putAll(struct2) /> --->

<cfdump var="#struct1#">

tech.david-cheong.com
Notice the commented out version. That is the underlying method to do the same thing as StructAppend.

tech.david-cheong.com

The structure result after merge


ColdFusion 8 Ajax Features Overview

By on September 14, 2012

Special thanks for Scott Bennett who is the author of this article, in the article he summarize the CF8 ajax features which is pretty easy to understand the full picture of what CFAjax and provide/do for you.

 

Enjoy and happy learning.

 

ColdFusion 8 Ajax Features Overview (456)

There are always more than single methods to accomplish the same job in programming language. To loop through the letters from A to Z in ColdFusion there are also more than one way, but I personally found out the following 2 methods are simpler and strain forward.

 

Hardcode the A to Z into a list and just loop over it

<cfloop

index=”strLetter”

list=”A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z”

delimiters=”,”>

 

<cfdump var=”#strLetter#”>

 

</cfloop>

 

 

The other way to loop through the letters is using the ASCII value from A to Z. We first convert the A and Z to ASCII, than just use the number to loop through the rest and convert it back to char to get back our result.

 

<cfloop

index=”intLetter”

from=”#Asc( ‘A’ )#”

to=”#Asc( ‘Z’ )#”

step=”1″>

 

<!— Get character of the given ascii value. —>

<cfset strLetter = Chr( intLetter ) />

 

<cfdump var=”#strLetter#”>

 

</cfloop>

 

Please feel free to share the way you usually use or you may found out any other better way to do the job.

The following are the reference and sample code on how to loop over a structure without knowing its keys.

 

<cfset testStruct = structnew() />

<cfset testStruct.key1 = "test1" /> 
<cfset testStruct.key2 = "test2" /> 
<cfset testStruct.key3 = "test3" /> 
 
<cfdump var="#testStruct#" /> 
 
<cfloop list="#structKeyList(testStruct)#" index="key"> 
<cfoutput> 
Key: #key#, Value: #testStruct[key]# 
</cfoutput> 
</cfloop>

Adobe ColdFusion 10 Release

By on May 15, 2012

After few months of beta release for the Adobe ColdFusion 10, finally come to the final release version of CF10. There are a lot of blog, video, website and forum discussing about the coldfusion 10 where you can easily discover the beauty of the new ColdFusion 10. Besides that, you may also found some new video uploaded in Adobe TV regarding this few product.

tech.david-cheong.com

As usual, Adobe ColdFusion 10 come with 3 difference version which is

tech.david-cheong.com

Not too sure on which version are you looking for? Here is the buying guide that may help you to find out the difference that meet your needs or you may download the  Adobe ColdFusion 10 comparison (461) to find out the difference.

Secure Profile in ColdFusion 10

By on April 24, 2012

Installing ColdFusion is not an issue for most of the administrator, but the problem come when you try to configure the server at the release state and also secure.

tech.david-cheong.com

There are too many setting and tuning you need to secure your ColdFusion server. So with ColdFusion 10, there is a very good and useful features which call Secure Profile were introduced. It is recommended to choose this setting for production server. When the option is selected, this will enforce a lot of pre-configure security related setting.

tech.david-cheong.com

At the time of installation if secure profile is chosen, the following settings are affected:

tech.david-cheong.com

1.    Separate username and password setting is enabled for Administrator &RDS
2.    RDS service is disabled
3.    A List of IP addresses are asked which should have access to Administrator
4.    Strong and complex password for root admin user is mandatory
5.    Directory Browsing is disable in server
6.    Custom and least information error templates are used
7.    All debugging is disabled
8.    For a new data source default allowed SQL are select, insert, update, delete
9.    Below is a list of some more settings on server level which are affected –
 tech.david-cheong.com
Administrator settings affected by enabling Secure Profile –
tech.david-cheong.com
Administrator Settings
Path
Default Admin
Profile
Secure Profile
Changes to the setting
1
Use UUID for cftoken
Server Settings > Settings
Enabled
Enabled
Overwritten
2
Disable access to internal
ColdFusion Java components
Server Settings > Settings
Disabled
Enabled
Overwritten
3
Enable Global Script
Protection
Server Settings > Settings
Enabled
Enabled
Overwritten
4
Maximum size of post data
Server Settings > Settings
20MB
20MB
Overwritten
5
Missing Template Handler
Server Settings > Settings
no value
Custom missing error template
Retained if specified
6
Site-wide Error Handler
Server Settings > Settings
no value
Custom site-wide error template
Retained if specified
7
Request Queue Timeout Page
Server Settings > Request
Tuning
no value
Custom error template
Retained if specified
8
Cookie Timeout
Server Settings > Memory
Variables
15767000 minute
1440 minute
N/A
9
Disabling updating of ColdFusion internal cookies using ColdFusion tags/functions
Server Settings > Memory
Variables
Disabled
Enabled
N/A
10
Enabled WebSocket Server
Server Settings > WebSocket
Enabled
Disabled
N/A
11
Start Flash Policy Server
Server Settings > WebSocket
Enabled
Disabled
N/A
12
Allowed SQL (all settings)
Data & Services > Data Sources ><database> > Advanced Settings
Enabled
Create, Drop, Alter, Grant,Revoke, Stored Procedures are disabled
Retained if specified
13 Enable Robust Exception Information
Debugging & Logging > Debug Output Settings
Disabled
Disabled
Overwritten
14 Enable CFSTAT
Debugging & Logging > Debug Output Settings
Enabled
Disabled
Overwritten
15

Select the type of
Administrator authentication

Security > Administrator
Use a single password only
Separate user name and password authentication (allows multiple users)
N/A
16 Enable RDS Service
Security > RDS
Configurable at install time
Disabled
N/A
17

Select the type of RDS
authentication

Security > RDS
Use a single password only
Separate user name and password authentication (allows multiple users)
N/A
18 Allowed IP addresses for ColdFusion Administrator access
Security > Allowed IP Addresses
Not available at install time
Available at install time
N/A
tech.david-cheong.com

How coldfusion work

By on January 10, 2012

ColdFusion CF is a rapid application development language that allow us to build a dynamic web site and web application easily. ColdFusion application server is build on top of Java so it’s can work in multiple OS platform such as Window or Linux as well as difference web server such as IIS web server or Apache web server.

 

The major difference between Web Server and Web Application Server is that Web server only have the limited capability. It wait for the request from the user and serve the request as soon as possible.

 

Web application server actually is to extends the capabilities of a web server. With the extended functionality, the web server now able to do more work and fuction such as interacts with database, other resources, interacts with other web service, or other application.

 
How ColdFusion works:

  • Below steps explain how web server and application server work together.
  • User requests a page by typing a URL in the browser, and web server receives the request.
  • Web server looks at the file extension to determine whether a web application server must process the page.
  • If user requests a page that is simple web page like HTM or HTML extension, the web server fulfills the request and sends it back to browser.
  • If user requests a page that application server must process like CFM, CFML or CFC extensions, the web server passes the request to the application server.
  • The web application server processes the page and sends the result to the web server, which returns those results to browser.