Re: Return boolean from a CFC query -- UPDATE: Solved
On Wed, Jan 26, 2011 at 10:43 AM, Charlie Griefer charlie.grie...@gmail.com wrote: cfreturn isStudentEmployee.recordcount = 0 / Unless I'm missing something, this should be: cfreturn isStudentEmployee.recordcount eq 0 / -- Ezra Parker ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:341430 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: SQL Server question re table names - still stuck
I didn't see a mention of which version of SQL Server you're running, but it sounds to me like canadianofficespacecom is either an object owner or a schema: http://www.sqlteam.com/article/understanding-the-difference-between-owners-and-schemas-in-sql-server I'm assuming that it's most likely SQL Server 2005 or 2008, in which case the simplest fix would probably be to change the default schema for the user that you specified in your CF datasource. To do this, access the properties for the user in question and you will see a default schema field -- change the value to canadianofficespacecom and you should then be able to query the tables without the prefix. HTH, -- Ezra Parker On Fri, Dec 11, 2009 at 1:07 AM, Larry Soo l...@bc4x4.com wrote: I wrote: A client asked me to see if I could get a copy of his old web site up and running. I did a restore of the backed up database onto my PC. The problem is that all the table names have the name of the database prepended to them. When I view the tables in SQL Server Manager, the table, city, is named abc.city, where oldabc is the name of the database from which the data was backed up from. For the sake of this example, newabc is the database name I used on my own machine, to which the backup data was restored to. brad wrote: I can't say I've ever seen that one before, but you could just do a loop over the contents of INFORMATION_SCHEMA.TABLES and build/exec an ALTER statement for each one. http://technet.microsoft.com/en-us/library/ms190273.aspx How many tables are there? If there are under 75, you might be just as fast renaming them them by hand. Well, I tried renaming them by hand but it won't work. Using the SQL Server Manger, I right-clicked on the table and then clicked on RENAME. The table name, when I right-clicked on it, said something like: abc.city. But when the RENAME edit box came up, it contained only city. So the table isn't actually named abc.city. It is only presenting the table that way, and when I do a query in CF, it expects me to also refer to the table with that database name prefix. Hmm...ok, here's the exact scenario: 1) I'm imported the data from a backup file and named the database canadianofficespace. 2) When I look at the tables in SQL Server Manager, it prefixes every table name with canadianofficespacecom, which is not the name of the database. I presume it's the name of the database that it originally came from. 3) When I do a CFQuery, it won't work unless I write the table name as canadianofficespacecom.city, instead of just city. Can anyone help me out here? This is well beyond my SQL Server knowledge. ...lars ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:329080 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: SQL Server question re table names - still stuck
On Fri, Dec 11, 2009 at 2:53 PM, Larry Soo l...@bc4x4.com wrote: So would I be correct in assuming that the problem I'm having is that the default schema for dbo is master instead of canadianofficespacecom? I believe so, yes. In order to resolve this from the user side of things you're going to need to connect as a different user, as you will not be able to change the default schema of the sa user, as noted here: http://msdn.microsoft.com/en-us/library/ms176060.aspx The value of DEFAULT_SCHEMA is ignored if the user is a member of the sysadmin fixed server role. All members of the sysadmin fixed server role have a default schema of dbo. So I would suggest creating a canadianofficespacecom login to correspond to the canadianofficespacecom user in your DB, and then executing the following T-SQL script: USE canadianofficespace; ALTER USER canadianofficespacecom WITH LOGIN = canadianofficespacecom, DEFAULT_SCHEMA = canadianofficespacecom; GO (As a side note, I had thought you could change the default schema in the GUI interface, but after trying it out it appears I was mistaken about this -- sorry for the misinformation there.) If this runs successfully, then change the DSN to connect with the new user name and password and you should be good to go. The alternative option would be to change the schema for the tables to dbo, but if it were me I would prefer changing users anyway in order to avoid connecting as sa. Please post back if you run into any problems. -- Ezra Parker ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:329121 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: How is this done without evaluate()?
Some times it cannot be avoided with out a boat load of thinking and trial and error. Case in point, and I will gladly change this bit of code to not use evaluate if someone can figure out how to do this in CFscript sans the evaluate function: OK, I'll bite. It's certainly much more verbose, and cannot be done in CFScript, but this should work (totally untested, obviously, so forgive any syntax errors): First off, you would need to add a couple more var-scoped local variables: cfset var myBeanID = 0 / cfset var myReturnValue = / And then you could change the latter portion of your function to this: cfif arguments.MyAction EQ delete cfinvoke component=#myBeanObj# method=get#arguments.MyPK# returnVariable=myBeanID / cfinvoke component=#MyServiceObj# method=delete#arguments.MyTable# returnVariable=myReturnValue cfinvokeargument name=#arguments.MyPK# value=#myBeanID# / /cfinvoke cfelseif arguments.MyAction EQ Select cfinvoke component=#MygatewayObj# method=getByAttributesQuery returnVariable=myReturnValue argumentCollection=arguments.MyStruct / cfelseif arguments.MyAction EQ Upsert cfinvoke component=#MyServiceObj# method=save#arguments.MyTable# returnVariable=myReturnValue !--- Don't know the argument name here --- cfinvokeargument name=??? value=#myBeanObj# / /cfinvoke cfelse !--- Not sure what this is doing... does it need to return the evaluated numeric value 2? --- cfset myReturnValue = 1+1 / /cfif cfreturn myReturnValue / Note that you would need to supply the argument name for the Upsert action, as cfinvokeargument requires a name attribute, and you were using an unnamed argument in the original method invocation. As I said, signifcantly more verbose, so I would leave it to your sensibilities as to whether this is an improvement or not... -- Ezra Parker ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:320744 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: How do I traverse XML using ColdFusion?
This is a bit of a stab in the dark, as I believe that I am seeing an empty response due to the fact that I am not authenticated, but give this a try (continuing from the last line of your script block): response = ws.getYears(args); result = response.getYearsResult().get_any(); At this point, result will be an array containing two Java objects of the class org.apache.axis.message.MessageElement. Try dumping one or both, and investigating the methods they expose: cfdump var=#result[1]# cfdump var=#result[2]# In my case, I note that result[1].getName() returns schema (which sounds promising), result[1].getAttribute(javacast(string, id)) returns NewDataSet (sounds even more promising), and that result[1].getValue() returns NULL (therefore I think this is an empty result set). I hope that is helpful... -- Ezra Parker ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:318572 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: How do I traverse XML using ColdFusion?
You're welcome, I'm glad that helped. As far as authentication goes, it looks like this needs to be submitted as a SOAP header. I'm not too familiar with that aspect of web services, but here is my stab at it: cfscript wsurl = https://www.blackbookws.com/UsedCarWS.asmx?WSDL;; portname = UsedCarWS; ws = CreateObject(webservice, wsurl, portname); authHeader = xmlNew(); authHeader.UserCredentials = xmlElemNew(authHeader, http://localhost/webservices/UsedCarWS;, UserCredentials); authHeader.UserCredentials.userid = xmlElemNew(authHeader, userid); authHeader.UserCredentials.userid.xmlText = userid; //plug in your userid value here authHeader.UserCredentials.password = xmlElemNew(authHeader, password); authHeader.UserCredentials.password.xmlText = password; //plug in your password value here authHeader.UserCredentials.company = xmlElemNew(authHeader, company); authHeader.UserCredentials.company.xmlText = company; //plug in your company value here authHeader.UserCredentials.producttype = xmlElemNew(authHeader, producttype); authHeader.UserCredentials.producttype.xmlText = producttype; //plug in your producttype value here authHeader.UserCredentials.returncode = xmlElemNew(authHeader, returncode); authHeader.UserCredentials.returncode.xmlText = 0; //this needs to be an integer authHeader.UserCredentials.returnmessage = xmlElemNew(authHeader, returnmessage); authHeader.UserCredentials.returnmessage.xmlText = returnmessage; //can this be an empty string? addSOAPRequestHeader(ws, ignored, ignored, authHeader); body = structNew(); response = ws.getAllStates(body); /cfscript cfdump var=#response# I'm creating the header as an XML document (there may be a less verbose way of dealing with this -- if so, I'd love to hear it), and using the namespace indicated in the examples listed here: https://www.blackbookws.com/UsedCarWS.asmx?op=AllStates You will need to plug in the correct values for userid, password, etc., of course. I cannot tell if this works, as I obviously do not have the authentication credentials, but it does not thrown an error, and returns what appears to be a valid response (without any data). I'd be curious to hear if this actually works or not... -- Ezra Parker ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:318478 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: How do I traverse XML using ColdFusion?
Hi Chris, I have been following this thread out of curiosity, and I think I might be able to help in pointing you in the right direction. The key bit here is the fact that the getIPAddress method has an input parameter, identified in the dump of the stub as: localhost.webservices.UsedCarWS.IPAddress In the WSDL, this is defined as: s:element name=IPAddress s:complexType/ /s:element So it's a complex type, but has no child elements, which corresponds to an empty CF structure. Therefore, if you change your code snippet to: cfscript wsurl = https://www.blackbookws.com/UsedCarWS.asmx?WSDL;; portname = UsedCarWSSoap12; ws = CreateObject(webservice, wsurl, portname); ip = StructNew(); /cfscript cfdump var = #ws# cfdump var = #ws.getIPAddress(ip)# The second dump will display the object returned by the method call, which in turn has a getIPAddressResult() method that returns the IP of the CF server calling the web service: cfscript wsurl = https://www.blackbookws.com/UsedCarWS.asmx?WSDL;; portname = UsedCarWSSoap12; ws = CreateObject(webservice, wsurl, portname); ip = StructNew(); response = ws.getIPAddress(ip); /cfscript cfdump var = #response.getIPAddressResult()# Hope that helps. -- Ezra Parker On Fri, Jan 23, 2009 at 5:54 PM, Chris Jordan chris.s.jor...@gmail.com wrote: Brad, I tried passing the authentication stuff via the addSOAPRequestHeader, but there's something else going on here. What I've learned in the last couple of hours is that when using CreateObject to call a web service you can pass it a portname. I know from looking at the wsdl itself, that there are several portnames associated with this particular web service. The author of the web service suggested that I start by using the getIPAddress() method as it requires NO AUTHENTICATION. So I do this: cfscript wsurl = https://www.blackbookws.com/UsedCarWS.asmx?WSDL;; portname = UsedCarWSSoap12; ws = CreateObject(webservice, wsurl, portname); /cfscript cfdump var = #ws# cfdump var = #ws.getIPAddress()# Try the code above. You'll see that dumping ws *does indeed* show you the available methods. There is exactly one available method: getIPAddress(). I've verified this also using SOAPUI (http://www.soapui.org/). when I run the code above the last dump statement causes the error: *Web service operation getIPAddress with parameters *{}* cannot be found.* So, as an experiment I searched the web for some other free soap web service that wouldn't require some sort of login. I found geocoder.us ( http://geocoder.us/dist/eg/clients/GeoCoderPHP.wsdl). I looked at some sample php code, and could easily see how it translated over to ColdFusion. My code became: cfscript address = 1600 Pennsylvania Av, Washington, DC; wsurl = http://geocoder.us/dist/eg/clients/GeoCoderPHP.wsdl;; ws = CreateObject(webservice, wsurl); //I found the geocode_address() method by looking at the dump //of the ws object returned by the previous line... geo = ws.geocode_address(address); /cfscript cfdump var = #ws# cfdump var = #geo[1].getLat()# , #geo[1].get_long()# This web service worked like a champ for me! :o) So, I'm not sure what's up with the other one. As far as the dumping thing goes, I will admit that there are a few things I'm not seeing, like the UserCredentials thing (which is a complexType... maybe that has something to do with it). You're right that the Stub functions in the parent class have nothing to do with the web service itself. Those are functions that CF uses under the hood I think to deal with the web services... I think. Anyway, I'm still stumped as to why my example using geocoder.us worked while my very similar example with blackbookusa.com isn't working... I've contacted the developer at blackbook, but probably won't hear from him until Monday. I would love to figure this out this weekend if I could. Thanks for sticking with me and for continuing to offer suggestions. :o) Chris ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:318475 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4