Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

Process stops while validating ftp

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?

  • Daniel Mora Profile Picture
    Daniel Mora 148 on at
    RE: Process stops while validating ftp

    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.

  • ergun sahin Profile Picture
    ergun sahin 8,812 Super User on at
    RE: Process stops while validating ftp

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

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 225,549 Super User on at
    RE: Process stops while validating ftp

    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");

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,914 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,549 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans