|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Unable to invoke method of COM object
I am just abt 3 days old to Cold Fusion programming and I am encountering a rather frustrating error
: I am unable to invoke a method of a COM object. The code segment is :<CFSET objContact = objBOContact.NewContact(objuser,true)> <CFSET objContact.FirstName = #FORM.txtFirstName#> <CFSET objContact.LastName = #FORM.txtLastName#> <!--- ERROR OCCURS ON THE FOLLOWING LINE ---> <CFSET objAddress = objContact.GetAddressByPurpose('Address')> Error Message : The selected method GetAddressByPurpose was not found Details : Either there are no methods with the specified method name and argument types, or the method GetAddressByPurpose is overloaded with arguments types that ColdFusion can't decipher reliably. If this is a Java object and you verified that the method exists, you may need to use the javacast function to reduce ambiguity. I am able to access attributes of teh object but not the method. Strange!! I tried passing the parameter to teh call with single quotes, double quotes, without quotes etc to no avail. The method exists and the parameter info is also correct. I verified it by developing a .net client. Any help on this will be appreciated. I am running Cold Fusion MX 6.1 on Windows 2000 Pro, if this is of any help. Thanks in advance Pramod |
|
#2
|
|||
|
|||
|
Are you actually creating an instance of the object with CFOBJECT or createObject()?
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
No I am not using CFOBJECT of createObject(). If u observe the code above, i am getting a reference to the object objContact by calling the method NewContact(...) which works fine.
|
|
#4
|
|||
|
|||
|
Yes, but where are you defining what "objBOContact" is? How does CF know what object you are referring to? Is this a static method?
|
|
#5
|
|||
|
|||
|
Full code segment
Appended below is the segment of code that is using the objects. Hope this will help with suggestions, Sorry for not publishing the full segment before.
Pramod <cftry> <CFOBJECT ACTION="CREATE" CLASS="iboUserSecurity.CUser" NAME="objUser" TYPE="COM"> <CFSET OBJUser.DBID = "ODBC:myDSN"> <!--- <CFSET usrUser.UserID = "ibo"> ---> <CFOBJECT ACTION="CREATE" CLASS="iboContactManagement.CContactsBOAdmin" NAME="objBOContact" TYPE="COM"> <CFSET objContact = objBOContact.NewContact(objuser,true)> <!--- <cfset errErrors = objContact.Errors> <CFINCLUDE TEMPLATE="iBOHandleErrors.cfm"> <CFIF errMessage GT " "> <CFEXIT> </CFIF> ---> <CFSET objContact.Prefix = #FORM.cmbPrefix#> <CFSET objContact.FirstName = #FORM.txtFirstName#> <CFSET objContact.LastName = #FORM.txtLastName#> <CFSET objContact.BirthDate = #FORM.cmbDate# & #FORM.cmbMonth# & #FORM.txtYear#> <CFSET objContact.Gender = #FORM.cmbGender#> <CFSET objContact.MemberType = "ENSB"> <CFSET objContact.Status = "A"> <CFSET objContact.Email = #FORM.txtEMail#> <CFSET objContact.HomePhone = #FORM.txtHomePhone#> <CFSET objContact.WorkPhone = #FORM.txtWorkPhone#> <CFSET objContact.TollFreePhone = #FORM.txtMobilePhone#> <CFSET objContact.Suffix = #FORM.optPreference#> <!--- ERROR OCCURS ON THE FOLLOWING LINE ---> <CFSET objAddress = objContact.GetAddressByPurpose('Address')> <CFSET objAddress.Purpose = "Address"> <CFSET objAddress.AddrLine1 = #FORM.txtAddress1#> <CFSET objAddress.AddrLine2 = #FORM.txtAddress2#> <CFSET objAddress.City = #FORM.txtCity#> <CFSET objAddress.PostalCode = #FORM.txtPostCode#> <CFSET objAddress.StateProvince = #FORM.cmbState#> <CFSET objAddress.Country = #FORM.cmbCountry#> all well 3 <CFSET objContact.Errors.ClearErrors()> <CFSET objContact.SubmitChanges()> <cfset errErrors = objContact.Errors> <CFINCLUDE TEMPLATE="iBOHandleErrors.cfm"> <CFIF errMessage GT " "> <CFEXIT> </CFIF> <cfcatch> <CFOUTPUT> <CFLOCATION url = "ApplicationError.cfm?Path=adduserSubscribe&Type=#cfcatch.type#&Source=#cfcatch.Detail#&Message=#cfcatch.Message#"> </CFOUTPUT> <!--- <CFOUTPUT><BR> Message : #cfcatch.message# <br> Details : #cfcatch.detail# Type : #cfcatch.type# </CFOUTPUT> <cfabort> ---> </cfcatch> </cftry> </CFIF> |
|
#6
|
|||
|
|||
|
Can you do a CFDUMP of the object once you've created it? According to the error, you are either calling a method that doesn't exist or you are passing incorrect arguments to the method. The fact that you are able to create the object without an error seems to mean that the problem is in the name of the method or the arguments.
|
|
#7
|
|||
|
|||
|
Tried a CFDUMP
About your thought that the method name could be wrong, I have tried using the same component throught a .net client -works perfectly fine with the same method name, same parameters.
CFDUMP tells me that the object is undefined. <CFSET objContact = objBOContact.NewContact(objuser,true)> <CFDUMP var = "#objContact#" expand = "Yes" label = "OBJCONTACT"> A CFDUMP on objBOContact gives me all the methods available in the object, so i guess the call to the NewContact method is returning nothing. It isnt the desired output from the method, what i am wondering is if my way passing the parameters objUser and the boolean value true are correct?? |
|
#8
|
|||
|
|||
|
It definitely seems then that something is not right with the arguments that you're passing. Remember that CF is typeless and (for example) has no real concept of a type, like Boolean. It does *sort of* when it comes to things like return types from CFCs, etc, but this could easily be where the problem is. This is where the JavaCast() function comes into play when calling methods on Java classes. Whether that would work for a COM object I don't know (I doubt it). Is the boolean argument required? Would it work if you omitted that argument?
|
|
#9
|
|||
|
|||
|
problem Solved
Uninstalled and reinstalled Cold Fusion MX Server and i can invoke the method without any problem. Frustrating ......... but solved the problem. Nevertheless, Thanx Kiteless.
Cheers Pramod |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Unable to invoke method of COM object |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|