Consuming webservices in Coldfusion

Tagged Under : ,

We all know how to consume webservices in CF, using the CFINVOKE or using CreateObject(). However, using the above, its relatively hard to consume complex webservices, specially with complex datatypes. I normally use CFHTTP to the rescue which eliminates the need for any datatype mappings.

Here is an example. Lets try to consume the dateservices webservice available at http://webservices.daelab.net/datesservice/datesservice.wso?WSDL .

First of all, we need to identify the method we need to call and prepare its SOAP request manually. There are several ways of generating SOAP request including XML editors like XMLSpy etc. However, there are some SOAP services online that do this as well. Here is one, www.soapclient.com.

In this case, lets consume the DayName method of the service. The Request XML for that looks like this -. Sample SOAP request

Now, we need to submit this to the endpoint using CFHTTP. Here is how we do it.

The output of that looks like this.

Next step would be parse the response XML to get the desired values and can be done in several different way, ofcourse.

CF Application and Session Scopes

Tagged Under :

Accessing Application and Session Scope in Coldfusion is generally straightforward but here is a rather smart way of doing it.The first step is to acces the CF runtime objects like below :-

And this is how you get all the existing applications in CF runtime.

To access a particular Application scope :-

Similarly, to get all existing Session keys :-

To get a Session Collection for a particular application :-

To programmatically clear an application scope :-