I assume you found this page:
http://www.axaptapedia.com/FTP_from_Axapta
Part of what this code is doing is registering a dll so it can be used within
x++.
Anyways, I found this previous post - and am reposting it since it seems to
include an xpo file:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Fra: [email protected]
[mailto:[EMAIL PROTECTED] På vegne af Mayle, Michael
Sendt: 9. januar 2006 23:03
Til: [email protected]
Emne: RE: [development-axapta] Re: How to send file to FTP
Here is a copy of the XPO of all of Jan's wonderful tips here. I have also added
my own ftpCreateDirectory, ftpDeleteFile, ftpRemoveDirectory, and ftpRenameFile,
and I as well as have attempted ftpCommand and ftpGetCurrentDirectory, but gave
up. Please share any solutions that you may have added to the class (FTP-wise).
I am especially interested in getting the ftpCommand to work (no luck so far.)
Enjoy!
--Mike
Exportfile for AOT version 1.0 or later
Formatversion: 1
***Element: CLS
; Axapta Class: WinInet unloaded at Monday 1/9/2006
;
--------------------------------------------------------------------------------
CLSVERSION 1
CLASS #WinInet
PROPERTIES
Name #WinInet
Extends #
RunOn #Client
ENDPROPERTIES
METHODS
Version: 3
SOURCE #classDeclaration
#final class WinInet
#{
# DLL _winInet;
# DLLFunction _internetOpen;
# DLLFunction _internetCloseHandle;
# DLLFunction _internetOpenUrl;
# DLLFunction _internetReadFile;
#
# int _handle;
# int _result;
#
# DLLFunction _internetConnect;
# DLLFunction _ftpGetFile;
# DLLFunction _ftpPutFile;
# DLLFunction _ftpSetCurrentDirectory;
# DLLFunction _ftpCommand;
# DLLFunction _ftpFindFirstFile;
# DLLFunction _ftpDeleteFile;
# DLLFunction _ftpRenameFile;
# DLLFunction _ftpCreateDirectory;
# DLLFunction _ftpRemoveDirectory;
# DLLFunction _ftpGetCurrentDirectory;
#
#
# #define.FTP_TRANSFER_TYPE_BINARY(2)
# #define.FTP_TRANSFER_TYPE_UNKNOWN(0)
# #define.FTP_TRANSFER_TYPE_ASCII(1)
#
#}
ENDSOURCE
SOURCE #finalize
#void finalize()
#{
# this.internetCloseHandle(_handle);
#}
ENDSOURCE
SOURCE #ftpCommand
#int ftpCommand(int _handler, boolean _expectResponseIn, str 255
_command)
#{
# int _handlerOut;
# int _expectResponse;
# ;
#
# if (_expectResponseIn)
# _expectResponse = 1;
# else
# _expectResponse = 0;
#
# if(_ftpCommand.call(_handler, _expectResponse,
#FTP_TRANSFER_TYPE_ASCII, _command, 0, _handlerOut) == 0)
# return 0;
# else
# return _handlerOut;
#}
ENDSOURCE
SOURCE #ftpCreateDirectory
#boolean ftpCreateDirectory(int _hdl, str 255 _name)
#{
# if (_ftpCreateDirectory.call(_hdl, _name) == 0)
# return false;
# else
# return true;
#}
ENDSOURCE
SOURCE #ftpDeleteFile
#boolean ftpDeleteFile(int _hdl, str 255 _file)
#{
# if (_ftpDeleteFile.call(_hdl, _file) == 0)
# return false;
# else
# return true;
#}
ENDSOURCE
SOURCE #ftpGetCurrentDirectory
#int ftpGetCurrentDirectory(int _hdl, str 255 _remoteFile, str 255
_localFile)
#{
# return
0;//_ftpGetCurrentDirectory.call(_hdl,_remoteFile,_localFile,false,0,#FTP_TRANSF\
ER_TYPE_BINARY,0);
#}
#
ENDSOURCE
SOURCE #FtpGetFile
#int ftpGetFile(int _hdl, str 255 _remoteFile, str 255 _localFile)
#{
# return
_FtpGetFile.call(_hdl,_remoteFile,_localFile,false,0,#FTP_TRANSFER_TYPE_BINARY,0\
);
#}
ENDSOURCE
SOURCE #FtpPutFile
#int ftpPutFile(int _hdl, str 255 _localFile, str 255 _remoteFile)
#{
# return
_FtpPutFile.call(_hdl,_localFile,_remoteFile,#FTP_TRANSFER_TYPE_BINARY,0);
#}
ENDSOURCE
SOURCE #ftpRemoveDirectory
#boolean ftpRemoveDirectory(int _hdl, str 255 _name)
#{
# if (_ftpRemoveDirectory.call(_hdl, _name) == 0)
# return false;
# else
# return true;
#}
ENDSOURCE
SOURCE #ftpRenameFile
#boolean ftpRenameFile(int _hdl, str 255 _fileOld, str 255 _fileNew)
#{
# if (_ftpRenameFile.call(_hdl, _fileOld, _fileNew) == 0)
# return false;
# else
# return true;
#}
ENDSOURCE
SOURCE #ftpSetCurrentDirectory
#Boolean ftpSetCurrentDirectory(int _handler, str _name)
#{
# ;
#
# if (_handler == 0)
# return false;
#
# if (_ftpSetCurrentDirectory.call(_handler, _name) == 0)
# return false;
# else
# return true;
#}
#
ENDSOURCE
SOURCE #internetCloseHandle
#boolean internetCloseHandle(int handle)
#{
# return _internetCloseHandle.call(handle);
#}
ENDSOURCE
SOURCE #internetConnect
#int internetConnect(str 60 _server, str 99 _userName, str 99 _password
)
#{
# return
_internetConnect.call(_handle,_server,0,_userName,_password,1,0,0);
#}
ENDSOURCE
SOURCE #internetOpen
#int internetOpen(str 255 agent,int accessType,str 255 proxyName,str 255
proxyByPass,int flags)
#{
#
#
#
# return
_internetOpen.call(agent,accessType,proxyName,proxyByPass,flags);
#}
ENDSOURCE
SOURCE #internetOpenUrl
#int internetOpenUrl(str 500 url,int flags = 0,int context = 0)
#{
# Binary _headers = new Binary(512);
# int hdl = _internetOpenUrl.call(_handle,url,"",-1,flags,context);
# return hdl;
#
#
#}
ENDSOURCE
SOURCE #internetReadFile
#str internetReadFile(int hdl)
#{
# Binary _buffer = new Binary(2048);
# Binary _bytesRead = new Binary(4);
# str result;
# boolean ret;
# int done = 0;
#
# while (! done)
# {
# ret = _internetReadFile.call(hdl,_buffer,2000,_bytesRead);
# if ((! _bytesRead.dWord(0)) || (! ret))
# done = 1;
# else
# {
# result += subStr(_buffer.string(0),1,_bytesRead.dWord(0));
# }
# }
# return ret ? result : "";
#}
ENDSOURCE
SOURCE #new
#void new()
#{
# try
# {
# _winInet = new DLL("WinInet");
# }
# catch(Exception::Internal)
# {
# infolog.clear();
# return;
# }
#
# _internetOpen = new DLLFunction(_winInet,"InternetOpenA");
# _internetOpen.returns(ExtTypes::DWORD);
# _internetOpen.arg(ExtTypes::STRING);
# _internetOpen.arg(ExtTypes::DWORD);
# _internetOpen.arg(ExtTypes::STRING);
# _internetOpen.arg(ExtTypes::STRING);
# _internetOpen.arg(ExtTypes::DWORD);
#
# _internetCloseHandle = new
DLLFunction(_winInet,"InternetCloseHandle");
# _internetCloseHandle.returns(ExtTypes::DWORD);
# _internetCloseHandle.arg(ExtTypes::DWORD);
#
# _internetOpenUrl = new DLLFunction(_winInet,"InternetOpenUrlA");
# _internetOpenUrl.returns(ExtTypes::DWORD);
# _internetOpenUrl.arg(ExtTypes::DWORD);
# _internetOpenUrl.arg(ExtTypes::STRING);
# _internetOpenUrl.arg(ExtTypes::STRING);
# _internetOpenUrl.arg(ExtTypes::DWORD);
# _internetOpenUrl.arg(ExtTypes::DWORD);
# _internetOpenUrl.arg(ExtTypes::DWORD);
#
# _internetReadFile = new DLLFunction(_winInet,"InternetReadFile");
# _internetReadFile.returns(ExtTypes::DWORD);
# _internetReadFile.arg(ExtTypes::DWORD);
# _internetReadFile.arg(ExtTypes::POINTER);
# _internetReadFile.arg(ExtTypes::DWORD);
# _internetReadFile.arg(ExtTypes::POINTER);
#
# _handle = this.internetOpen("Axapta",0,"","",0);
#
# _internetConnect = new DLLFunction(_winInet,"InternetConnectA");
# _internetConnect.returns(ExtTypes::DWORD);
# _internetConnect.arg(ExtTypes::DWORD);
# _internetConnect.arg(ExtTypes::STRING);
# _internetConnect.arg(ExtTypes::DWORD);
# _internetConnect.arg(ExtTypes::STRING);
# _internetConnect.arg(ExtTypes::STRING);
# _internetConnect.arg(ExtTypes::DWORD);
# _internetConnect.arg(ExtTypes::DWORD);
# _internetConnect.arg(ExtTypes::DWORD);
#
# _ftpGetFile = new DLLFunction(_winInet,"FtpGetFileA");
# _ftpGetFile.returns(ExtTypes::DWORD);
# _ftpGetFile.arg(ExtTypes::DWORD);
# _ftpGetFile.arg(ExtTypes::STRING);
# _ftpGetFile.arg(ExtTypes::STRING);
# _ftpGetFile.arg(ExtTypes::DWORD);
# _ftpGetFile.arg(ExtTypes::DWORD);
# _ftpGetFile.arg(ExtTypes::DWORD);
# _ftpGetFile.arg(ExtTypes::DWORD);
#
# _ftpPutFile = new DLLFunction(_winInet,"FtpPutFileA");
# _ftpPutFile.returns(ExtTypes::DWORD);
# _ftpPutFile.arg(ExtTypes::DWORD);
# _ftpPutFile.arg(ExtTypes::STRING);
# _ftpPutFile.arg(ExtTypes::STRING);
# _ftpPutFile.arg(ExtTypes::DWORD);
# _ftpPutFile.arg(ExtTypes::DWORD);
#
# _ftpSetCurrentDirectory = new DLLFunction(_winInet,
'FtpSetCurrentDirectoryA');
# _ftpSetCurrentDirectory.returns(ExtTypes::DWORD);
# _ftpSetCurrentDirectory.arg(ExtTypes::DWORD);
# _ftpSetCurrentDirectory.arg(ExtTypes::STRING);
#
# _ftpCommand = new DLLFunction(_winInet, 'FtpCommandA');
# _ftpCommand.returns(ExtTypes::DWORD);
# _ftpCommand.arg(ExtTypes::DWORD);
# _ftpCommand.arg(ExtTypes::DWORD);
# _ftpCommand.arg(ExtTypes::DWORD);
# _ftpCommand.arg(ExtTypes::STRING);
# _ftpCommand.arg(ExtTypes::DWORD);
# _ftpCommand.arg(ExtTypes::DWORD);
#
# _ftpDeleteFile = new DLLFunction(_winInet, 'FtpDeleteFileA');
# _ftpDeleteFile.returns(ExtTypes::DWORD);
# _ftpDeleteFile.arg(ExtTypes::DWORD);
# _ftpDeleteFile.arg(ExtTypes::STRING);
#
# _ftpRenameFile = new DLLFunction(_winInet, 'FtpRenameFileA');
# _ftpRenameFile.returns(ExtTypes::DWORD);
# _ftpRenameFile.arg(ExtTypes::DWORD);
# _ftpRenameFile.arg(ExtTypes::STRING);
# _ftpRenameFile.arg(ExtTypes::STRING);
#
# _ftpCreateDirectory = new DLLFunction(_winInet,
'FtpCreateDirectoryA');
# _ftpCreateDirectory.returns(ExtTypes::DWORD);
# _ftpCreateDirectory.arg(ExtTypes::DWORD);
# _ftpCreateDirectory.arg(ExtTypes::STRING);
#
# _ftpRemoveDirectory = new DLLFunction(_winInet,
'FtpRemoveDirectoryA');
# _ftpRemoveDirectory.returns(ExtTypes::DWORD);
# _ftpRemoveDirectory.arg(ExtTypes::DWORD);
# _ftpRemoveDirectory.arg(ExtTypes::STRING);
#
# _ftpGetCurrentDirectory = new DLLFunction(_winInet,
'FtpGetCurrentDirectoryA');
# _ftpGetCurrentDirectory.returns(ExtTypes::DWORD);
# _ftpGetCurrentDirectory.arg(ExtTypes::DWORD);
# _ftpGetCurrentDirectory.arg(ExtTypes::STRING);
# _ftpGetCurrentDirectory.arg(ExtTypes::STRING);
#
# /*_ftpFindFirstFile = new DLLFunction(_winInet,
'FtpFindFirstFileA');
# _ftpFindFirstFile.returns(ExtTypes::DWORD);
# _ftpFindFirstFile.arg(ExtTypes::DWORD);
# _ftpFindFirstFile.arg(ExtTypes::STRING);*/
#
#}
ENDSOURCE
SOURCE #ok
#boolean ok()
#{
# if (_winInet)
# return TRUE;
# else
# return FALSE;
#}
ENDSOURCE
ENDMETHODS
ENDCLASS
***Element: END
--- On Thu, 7/31/08, sjafars <[EMAIL PROTECTED]> wrote:
From: sjafars <[EMAIL PROTECTED]>
Subject: [development-axapta] FTP in Dynamics AX
To: [email protected]
Date: Thursday, July 31, 2008, 8:50 AM
Hi
I would like to do FTP a file from AX to server location using X++
code.
When i surfed, I understand that i need to use WinInet Class which is I
couldn't able to find in my AOT. Is there something I need to connect
through WinAPI. Pls advise...
Could you please send some piece of code to achive this?
I would appreciate if someone could assist me on this regard
Thanks
Jaffar
[Non-text portions of this message have been removed]