Thursday, February 24, 2011

Netsuite and Coldfusion: compiling stub classes just got easier (or has been easier for quite some time, but I just found out about it)

UPDATE: I may have spoken too soon on this post... more to come.


As of ColdFusion 8 (and I also confirmed this in CF9), it appears that at least one portion of the once ridiculously convoluted process of getting ColdFusion to play nicely with SuiteTalk, Netsuite's web service API, is now a lot easier. In CF8, a parameter was introduced to the CreateObject() method that allows passing command line parameters for wsdl2java.

The problem with CFMX7 was that it wouldn't auto-compile all of the stub classes for SuiteTalk / Netsuite, either due to quietly timing out due to the sheer size and depth of the wsdl, or more likely because it was ignoring unreferenced elements. To cover both of these scenarios, we can simply up the timeout on wsdl2java and force it to compile classes for unreferenced elements.

<cfset ws = createobject( "webservice",
"-a -O 2000") />

"webservice" = type of object to create
"https://webservices.netsuite..." = URL of Netsuite WSDL. Replace this with the latest version or whatever version you prefer to use.
"NetSuitePort" = name of the web service port
"-a -O 2000" = -a (compile all elements, even unreferenced) -O 2000 (set timeout to 2000 seconds)