web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Process stops while validating ftp

(1) ShareShare
ReportReport
Posted on by 148

Hi,

While generating a retention receipt inside of an invoice journal the process stops in a method that validates the FTP

protected void validateFtp()
{
    object                          ftpo = null;
    System.Net.FtpWebRequest        request = null;
    System.Net.NetworkCredential    credential = null;
    System.Net.FtpWebResponse       response;
    ElectronicFTP                   electronicFTP = ElectronicFTP::find();
    ;
    try
    {
        ftpo = System.Net.WebRequest::Create(@"ftp://"   electronicFTP.FtpAddress);
        request = ftpo;
        credential = new System.Net.NetworkCredential(electronicFTP.UserName, electronicFTP.Passwd);
        request.set_Credentials(credential);
        request.set_Method("NLST");
        request.set_Proxy(System.Net.GlobalProxySelection::GetEmptyWebProxy());
        response = request.GetResponse(); //HERE IT STOPS
        request.Abort();
        response.Close();

    }
    catch
    {
        infolog.add(Exception::Error, "No se encuentra disponible el sitio Ftp");
        throw Exception::Error;
    }
}

If there is no response, why it didnt catch the error if it is inside a try catch. It doesn't pop any error message but it doesn't generate any retention receipt, it just doesn't do anything. What could be the problem here?

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,892 Most Valuable Professional on at

    Are you saying that it doesn't get into the catch block at all?

    I would expect it does, you just don't do anything useful there. If you want to see the actual error, do something like this:

    rotected void validateFtp()
    {
        System.Net.WebRequest        	request;
        System.Net.NetworkCredential    credential;
        System.Net.FtpWebResponse       response;
        ElectronicFTP                   electronicFTP = ElectronicFTP::find();
        
        try
        {
            request = System.Net.WebRequest::Create(@"ftp://"   electronicFTP.FtpAddress);
            credential = new System.Net.NetworkCredential(electronicFTP.UserName, electronicFTP.Passwd);
            request.set_Credentials(credential);
            request.set_Method("NLST");
            request.set_Proxy(System.Net.GlobalProxySelection::GetEmptyWebProxy());
            response = request.GetResponse();
            response.Close();
        }
        catch (Exception::CLRError) 
        {
            throw error(AifUtil::getClrErrorMessage());
        }
    }

    By the way, your code

    infolog.add(Exception::Error, "No se encuentra disponible el sitio Ftp");
    throw Exception::Error;

    can  be simplified to mere

    throw error("No se encuentra disponible el sitio Ftp");

  • ergun sahin Profile Picture
    8,826 Moderator on at

    Do you have ttsBegin/Commit (at caller, etc)

  • Daniel Mora Profile Picture
    148 on at

    I do not have a ttsbegin / ttscommit where im callling the method validateFtp( ). I have the ttsbegin / ttscommit where I'm doing the query to select the specific document that I'm generating the retention.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans