tag:blogger.com,1999:blog-31425501.post115677420986891456..comments2008-01-31T19:52:10.013-06:00Comments on aftergeek: Netsuite, ColdFusion, Java, and a lot of gray hair...Jeremy "King Skidz" Gibbensnoreply@blogger.comBlogger5125tag:blogger.com,1999:blog-31425501.post-1090158375098009052008-01-30T01:57:00.000-06:002008-01-30T01:57:00.000-06:00I was wondering if you are still working with CF a...I was wondering if you are still working with CF and Netsuite in any way? <BR/><BR/>I too am pulling my hair out - however I know little to nothing about java classes so your examples are fairly gibberish to me. <BR/><BR/>Any chance you could point me in the right direction ot simply login and then be able to pull a list of products from Netsuite?clukshahttp://openid.aol.com/clukshanoreply@blogger.comtag:blogger.com,1999:blog-31425501.post-16809642159160815792006-11-15T14:07:00.000-06:002006-11-15T14:07:00.000-06:00If you are viewing the above, and lines are gettin...If you are viewing the above, and lines are getting cut off, <a href="http://aftergeek.blogspot.com/2006/08/netsuite-coldfusion-java-and-lot-of.html">click here</a>. I haven't quite got a good way to do the posting of code yet.Jeremyhttp://www.blogger.com/profile/05975135981872593591noreply@blogger.comtag:blogger.com,1999:blog-31425501.post-59946150311587131472006-11-15T14:05:00.001-06:002006-11-15T14:05:00.001-06:00// this is all in cfscript....sorry, but the java ...// this is all in cfscript....sorry, but the java classes and methods are fairly specific to Netsuite, but hopefully points in the right direction<br />RecordRef1 = CreateObject("java", "com.netsuite.webservices.platform.core_2_5.RecordRef"); // 2nd param is the fully qualified java class name<br />RecordRef2 = CreateObject("java", "com.netsuite.webservices.platform.core_2_5.RecordRef"); // 2nd param is the fully qualified java class name<br />RecordRef3 = CreateObject("java", "com.netsuite.webservices.platform.core_2_5.RecordRef"); // 2nd param is the fully qualified java class name<br />RecordType = CreateObject("java", "com.netsuite.webservices.platform.core_2_5.types.Recordtype");<br /><br />aRecordRef = ArrayNew(1);<br /><br />RecordRef1.setInternalId("1");<br />RecordRef2.setInternalId("2");<br />RecordRef3.setInternalId("3");<br /><br />RecordRef1.setType(RecordType.customer);<br />RecordRef2.setType(RecordType.customer);<br />RecordRef3.setType(RecordType.customer);<br /><br />ArrayAppend(aRecordRef, RecordRef1);<br />ArrayAppend(aRecordRef, RecordRef2);<br />ArrayAppend(aRecordRef, RecordRef3);<br /><br />SearchMultiSelectField = CreateObject("java", "com.netsuite.webservices.platform.core_2_5.SearchMultiSelectField");<br />SearchMultiSelectFieldOperator = CreateObject("java", "com.netsuite.webservices.platform.core_2_5.types.SearchMultiSelectFieldOperator");<br /><br />CustomerSearchBasic = CreateObject("java", "com.netsuite.webservices.platform.common_2_5.CustomerSearchBasic");<br /><br />SearchMultiSelectField.setSearchValue(getJavaArray(aRecordRef));<br />SearchMultiSelectField.setOperator(SearchMultiSelectFieldOperator.anyOf);<br /><br />CustomerSearchBasic.setInternalId(SearchMultiSelectField);<br /><br />customerSearchBasic.setInternalId(new SearchMultiSelectField(rr, SearchMultiSelectFieldOperator.anyOf));<br /><br />function getJavaArray(aArray) {<br /> // Given a populated coldfusion array, return the equivalent java array of oJavaClass elements. The elements contained <br /> // in aArray must be of the same java class as oJavaClass.<br /> // PARAMETERS: <br /> // aArray - Required. Array of any valid datatype. Convert this array to a java array.<br /> // oJavaClass - Optional. Object of the datatype of which you want to convert aArray. If not passed, then the first element.<br /> // of aArray will be used to determine the datatype.<br /> // RETURNS: java.lang.reflect.Array<br /> var i = 0;<br /> var javaArray = CreateObject("java", "java.lang.reflect.Array");<br /> var returnArray = "";<br /> <br /> if (ArrayLen(Arguments) eq 2) { // Check if optional oJavaClass argument exists.<br /> oJavaClass = Arguments[2];<br /> }<br /> else { // if optional oJavaClass not passed, use the first element of aArray.<br /> oJavaClass = aArray[1];<br /> }<br /> returnArray = javaArray.newInstance(oJavaClass.getClass(), ArrayLen(aArray)); // create the java array of the same class as the object oJavaClass of the same length as aArray<br /> for (i=1; i lte ArrayLen(aArray); i=i+1) { // create the java equivalent of the array<br /> javaArray.set(returnArray, JavaCast("int", i-1), aArray[i]);<br /> } // End for<br /> <br /> return returnArray;<br />} // End function getJavaArrayJeremyhttp://www.blogger.com/profile/05975135981872593591noreply@blogger.comtag:blogger.com,1999:blog-31425501.post-28894640332923624372006-11-15T14:05:00.000-06:002006-11-15T14:05:00.000-06:00Steven, I will post some sample code that replicat...Steven, I will post some sample code that replicates the above as best as possible. Also see my later post about manually running wsdl2java and compiling the stub classes instead of relying on ColdFusion to do it. I ran into issues with certain methods expecting datatypes other than what was documented. Also check out <a href="http://bennadel.com/blog/206-Finding-Available-Java-Constructors-Methods-For-ColdFusion-Objects.htm">Ben Nadel's GetJavaClassMethods udf</a>. It has been a lifesaver when it comes to debugging (I also posted a cfscript equivalent with error handling in the comments on his original post). This is how I finally figured out that the wsdl methods were screwed up and needed to be recompiled by hand. I passed the web service object to GetJavaClassMethods and dumped the results to see what datatype each method expected.<br /><br />The key for the ColdFusion equivalent of these calls is using the CreateObject function.<br /><br />For the above code, here is how I would recreate it (see next comment)...Jeremyhttp://www.blogger.com/profile/05975135981872593591noreply@blogger.comtag:blogger.com,1999:blog-31425501.post-85265943627345021662006-11-15T13:29:00.000-06:002006-11-15T13:29:00.000-06:00What would these calls actually look like in ColdF...What would these calls actually look like in ColdFusion? I'm having some issues invoking web services with complex types, and it sounds like you've got this all figured out...Steven Klotzwww.NOVICA.COMnoreply@blogger.com