SGekko
SGekko

Reputation: 345

Invoke cfc from cfc called by web service

I am wanting to invoke a cfc from a cfc that is consumed as a web service. The web service just returns a status notification back to the caller but I need to fire off another cfc to start some processes that opens a ftp gets a file and downloads it to our server. Currently I am getting this error. Action GetFile Cause 550 Failed to open file. Detail Error: 550 Failed to open file. . Message An error occurred during the FTP GetFile operation. open file. .

When I invoke the process cfc directly from a url or invoke from another page it works fine. Any help would be appreciated.

Web Service code:

    <cfargument name="FileName" required="yes" type="string">
    <cfargument name="BatchNumber" required="yes" type="numeric">
    <cfargument name="LOGIN_USERID" required="yes" type="string">
    <cfargument name="LOGIN_PASSWORD" required="yes" type="string">


    <cfset comparison = Compare(LOGIN_PASSWORD, "xxxxxxx")>

    <cfif (LOGIN_USERID EQ "myid") AND (comparison EQ 0)>

        <cfset xmlDoc = XmlNew()>
        <cfset xmlDoc.XMLRoot = XMLElemNew(xmlDoc,"batchfiles")>
        <cfset xmlDoc.batchfiles.XmlChildren[1] = XmlElemNew(xmlDoc,"batch")>
        <cfset arrayappend(xmlDoc.batchfiles.XmlChildren[1].xmlChildren, XmlElemNew(xmlDoc,"batchnumber"))>
        <cfset xmlDoc.batchfiles.XmlChildren[1].batchnumber.XMLText="#batchnumber#">
        <cfset arrayappend(xmlDoc.batchfiles.XmlChildren[1].xmlChildren, XmlElemNew(xmlDoc,"filename"))>
        <cfset xmlDoc.batchfiles.XmlChildren[1].filename.XMLText="#filename#">
        <cfset arrayappend(xmlDoc.batchfiles.XmlChildren[1].xmlChildren, XmlElemNew(xmlDoc,"status"))>
        <cfset xmlDoc.batchfiles.XmlChildren[1].status.XMLText="Notification Received OK">



        <cfinvoke component="ImportRCMOrders" method="GetRCMOrderFiles">
            <cfinvokeargument name="FileName" value="#filename#">
            <cfinvokeargument name="BatchNumber" value="#batchnumber#">
        </cfinvoke>


        <cfreturn xmlDoc>   


    <cfelse>

        <cfoutput>Unauthorized Access. Please check username / password and ty again.</cfoutput>
        <cfabort>

    </cfif>

Entire Error: Action GetFile Cause 550 Failed to open file. Detail Error: 550 Failed to open file. . Message An error occurred during the FTP GetFile operation. StackTrace coldfusion.tagext.net.FtpHandler$FtpOperationException: An error occurred during the FTP GetFile operation. at coldfusion.tagext.net.FtpHandler.checkError(FtpHandler.java:189) at coldfusion.tagext.net.FtpHandler.getFile(FtpHandler.java:682) at coldfusion.tagext.net.FtpTag.doStartTag(FtpTag.java:763) at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2991) at cfImportRCMOrders2ecfc184096832$funcGETRCMORDERFILES.runFunction(C:\inetpub\wwwroot\imarkwebservice\rcm\dynamic\ImportRCMOrders.cfc:56) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:487) at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:420) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:383) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:334) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:533) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:648) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:457) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2424) at coldfusion.tagext.lang.InvokeTag.doEndTag(InvokeTag.java:399) at cfcfc_init2ecfm454010022.runPage(C:\inetpub\wwwroot\imarkwebservice\rcm\dynamic\cfc_init.cfm:14) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:246) at coldfusion.tagext.lang.IncludeTag.handlePageInvoke(IncludeTag.java:736) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:572) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.IpFilter.invoke(IpFilter.java:45) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:487) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:42) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:142) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:94) at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:78) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:58) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62) at coldfusion.CfmServlet.service(CfmServlet.java:219) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:422) at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:199) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source)

GetRCMOrderFiles:

    <!--- Open FTP connection --->
    <cfftp connection ="FTPRequest"
        action ="OPEN"
        username ="xxxxxx"
        password ="xxxx"
        server ="ftp.server.com"
        stopOnError ="Yes" 
        timeout="36000">


    <!--- List directories --->
    <cfftp connection = "FTPRequest"
        action = "LISTDIR"
        stopOnError = "Yes"
        name = "ftpQuery"            
        directory = "#arguments.ftpOrdersDir#"> 


    <!--- Download ftp files --->
    <cfif ftpQuery.recordcount GT 0>
        <cfif ftpQuery.Name EQ  arguments.filename>
            <cfset extension = LCase(listLast(arguments.filename,".")) >
            <cfif extension EQ 'csv'>

                <cftry>
                    <!--- Download ftp files --->
                    <cfftp connection = "FTPRequest"
                        action = "GetFile"
                        name = "dlFiles" 
                        remotefile="#ftpOrdersDir##arguments.filename#" 
                        localfile="#ExpandPath('/mydir/dynamic/orders/'& arguments.filename)#" 
                        failifexists="no" 
                        stoponerror="yes"> 

                    <!--- Rename files in ftp processed dir --->
                    <cfftp connection = "FTPRequest"
                        action = "RENAME"
                        existing="#arguments.ftpOrdersDir##arguments.filename#"
                        new="#arguments.ftpOrdersDir##arguments.filename#.#DateFormat(Now(), 'mmddyyyy')##Hour(Now())##Minute(Now())##Second(Now())#"
                        stopOnError = "Yes">

                <cfcatch type="any">
                    <cfmail type="html" 
                        to="[email protected]" 
                        from="[email protected]" 
                        subject="FTP Error"> 
                        <p> An error occurred on #DateFormat( Now(), "mmm d, yyyy" )# at #TimeFormat( Now(), "hh:mm TT" )# </p> 
                        Error Message: #cfcatch.message#<br> 
                        Error Detail: #cfcatch.detail#<br> 
                        Error Location: #GetBaseTemplatePath()#<br>
                        <cfdump var="#cfcatch#">
                        </cfmail>
                    <cfabort>
                </cfcatch>
                </cftry>
            </cfif>

This is from the first function that is called as the web service. struct: BATCHNUMBER 35506 FILENAME batchfile_35506.csv LOGIN_PASSWORD password LOGIN_USERID userid

struct BATCHNUMBER 35506 FILENAME batchfile_35506.csv FTPORDERSDIR /Dir/35506/

Upvotes: 1

Views: 175

Answers (1)

Robert Bailey
Robert Bailey

Reputation: 11

A 550 from the FTP client means that the file or directory does not exist. Check that your path is correct and that the file does exist at that path and that the user you are logging in as (on the FTP call) has permissions to this file.

I am assuming that the GetRCMOrderFiles() function is trying to retrieve a file from FTP?

You should be catching these as exceptions as well and possibly checking that the file exists before doing a get.

Upvotes: 1

Related Questions