:::: MENU ::::

Rick Groenewegen · Senior Coldfusion, SQL, NodeJS and Mobile developer

Senior Coldfusion, SQL, NodeJS and Mobile developer

Blog

  • Oct 15 / 2015
  • 0
debug
Coldfusion

ColdFusion Bugsnag notifier

Since recently we have been experimenting with BugSnag, a tool that collects exceptions from your application and displays them in a very neat dashboard. It supports a lot of languages already and my colleagues were already implementing the various available libraries (PHP, Node, Angular). However a complete ColdFusion integration wasn’t available yet. So I decided I would write one.
Continue Reading

  • Jul 16 / 2015
  • 0
Screen Shot 2015-07-16 at 09.56.47
Coldfusion

Consuming complex webservices in Railo

I love Railo (And since recently: Lucee). However, recently I’ve ran into some problems with webservices that either required a complex object to be passed as an argument, or webservices that return a complex object. Most notorious are the .NET webservice which cause a lot of trouble when trying to access them using ColdFusion.

In the 4.2 release Railo fixed most of these bugs:

[RAILO-2976] – webservice Complex Objects as arguments don’t get accessible data.

[RAILO-2978] – Soap webservices Complex type composed of an array of complex types, throws exception

[RAILO-3003] – webservice with component argument breaks

But for one of our biggest projects these fixes didn’t seem to do the trick. I’ve got a Java background, and since ColdFusion is Java based I decided to give the WSDL2JAVA tool a go. WSDL2JAVA is a tool that reads a WSDL and converts it to Java classes (Stubs, skeletons etc.). You can then use these classes to access your web service. I guess Railo / ACF both use this tool internally to generate stubs etc, but probably not in the way I wanted them too, since using it manually magically solved all our problems 😉

This blog will show you how to do this, package everything into a single JAR and show you how to access the webservice.

First off you start out by downloading eclipse:

https://www.eclipse.org

After it’s downloaded and installed we can begin the process of generating our JAR:

  1. Create a new Java project in Eclipse.
  2. Create a new folder in your project called ‘lib’.
  3. Go to your railo/lib folder and copy all the .jar files to the ‘lib’ folder in your project.
  4. Right-click on your project project and go to: Properties -> Java Build Path -> Libraries.
  5. Choose ‘Add jars’ and add all the .jar files from the ‘lib’ directory.
  6. Create a new ‘Run configuration’ (Little arrow next  to the green play button on top).
  7. Choose ‘Java Application’ and change the main class to: org.apache.axis.wsdl.WSDL2Java
  8. Open the ‘arguments’ tab and add the address of the WSDL of the webservice.
  9. Click ‘Apply’ and then ‘Run’.
  10. Refresh your project folder.
  11. New folders will be generated (‘com’ and ‘Framework’). Copy those to the ‘src’ folder.
  12. Click File -> Export -> JAR file.
  13. Expand your project in the left pane and uncheck ‘lib’.
  14. Export the JAR to the location of your choice.

You will now have a JAR file which you can use to access your web service. The next step would be to copy the JAR file to your class path. For example: [drive]:\railo\lib and restart your Railo server. It can probably also be loaded using a Java classloader, but that falls outside the scope of this article.

Before using the JAR I usually like to take a look at the Java packages it contains, to that I know the exact packages / classes to use in my ColdFusion code. The easiest way is to create a copy of your JAR file and rename the extention to ‘.zip’ and unpack this ZIP file. You will see a folder structure that indicate the package / class structure. This will be different for any webservice you consume, but for this example we are using the following package structure:

com -> companyname -> xml -> Services -> WebServices -> MyWebService.V1_0.MyWebServiceLocator

To create the webservice component use the following ColdFusion code:

<cfset endPointURL = "http://www.myserver.com/mywebservice.asmx"/>

<cfset myURL = createObject("java","java.net.URL").init(endPointURL)/>

<cfset webservice = CreateObject("java", "com.companyname.xml.Services.WebServices.MyWebService.V1_0.MyWebServiceLocator").getWebServiceSoap(url)/>

<cfdump var="#webservice#"/>

The <cfdump> will expose the webservice object and al it’s methods you can now use in your ColdFusion project!

Off course the way these methods work will be different for every webservice you consume. So if you run into any problems setting this up: Let me know!

  • Sep 06 / 2013
  • 0
pushmessage
Android, Coldfusion, iOS

Notifications to Android and iOS using ColdFusion

When I was developing our mobile multiplayer game ‘Drop It!’ I wanted to send notifications to the devices (Both Android and iOS) whenever a new move was made, or a random opponent was found. There are services online that offer you this kind of functionality (Like Urban Airship), but most of these services charge a monthly fee. Being Dutch I was looking for a way to implement this for free 😉 I found it, wrote a ColdFusion component called pusher.cfc and decided to share it with the community. Continue Reading

  • Sep 06 / 2013
  • 0
bender
Coldfusion

Removing duplicates from an array

Last week I was looking for a way to remove duplicate items from an array in ColdFusion without having to loop over every element. Turns out it was really simple using:

<cfset myArray = [1,2,2,5,9,9,7,8,8,8]/>
<cfset myArray = createObject("java", "java.util.HashSet").init(myArray).toArray()

<!--- Result: [1,2,5,9,7,8] --->
<cfdump var="#myArray#"/>

  • Sep 05 / 2013
  • 1
Welcome-Mat (1)
Uncategorized

Hi there!

Hi there, and welcome to my blog. I’ve been on the web since 1996, and decided that after 16 years it was time to start my first blog. Also: My colleagues at Aan Zee communicatie keep writing these great blogs, so I couldn’t stay behind 😉

I’ll use my blog to write about all the cool technologies I come across, and how I implemented them in my daily projects.

Don’t hesitate to ask questions, and I hope you enjoy my blog!

Need to know more? Contact me!