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)


Matt said...


Thanks for your information on NS, CF and java stubs.

I am attempting to use the login operation to persist cookies (eventually use ssologin)and obtain a sessionID from NS to use in each Soap request. When I post the login I receive a succesful response but only 2 cookes, NS_Ver and JSessionID The documentation says you are supposed to be retunred 3 cookies which I am definitely not. When I then try to make a request with the 2 cookies I receive a SESSION_TIMED_OUT fault...

Do you have any ideas/experience with using CF to login and receiving and posting with the JSessionID cookies (and others)? Any insight or code examples would be great (we are trying to not use the jars from NS on our server and just communicate via cfhttp posts).

Thanks a lot,

Jeremy Gibbens said...

Matt, I personally don't make use of a sessionID. I used to have an entire library of methods and code devoted to maintaining and sorting out sessions. All of it would be far too much to post here unfortunately. When a few versions ago, Netsuite started allowing sending the login (passport object) in the header of each soap request, it made it infinitely easier.

As for why only two cookies are being returned, are you setting the maintainSession attribute to true?

Personally I would recommend against trying to maintain and manage sessions with netsuite and send the login/passport with each request. It's possible there is a minor performance hit with that, but I couldn't give you any metrics.

Obviously since all of my code creates and references java objects, examples of that probably wouldn't make much sense for your purposes, but here is a sample soap request that includes the login passport:

<soapenv:Envelope xmlns:xsd="" xmlns:xsi="" xmlns:soapenv="">
<ns1:passport soapenv:mustUnderstand="0" soapenv:actor="" xmlns:ns1="">
<ns2:email xmlns:ns2=""></ns2:email>
<ns3:password xmlns:ns3="">**************</ns3:password>
<ns4:account xmlns:ns4="">123456</ns4:account>

Mark Gregory said...

Found this after banging my head against the wall trying to pass those cookie values back to NetSuite. Sending the Passport in the header is gorgeous! Thanks so much.