THis may be more of a webservice related issue than NAV, but if anyone had any ideas I would love to hear them. I am using the method explained here to upload a file by FTP:
viewtopic.php?f=32&t=51988
It gives the below error:
This message is for C/AL programmers: A call to System.Net.FtpWebRequest.GetRequestStream failed with this message: The requested FTP command is not supported when using HTTP proxy.
I have tried what other forums recommend which is using one of either of the below two commands, but these don't seem to be supported params (none / nothing)
request.Proxy := None;
request.Proxy := Nothing;
Comments
Bruce Anderson
here is some more in depth insight on the Proxy attribute: http://msdn.microsoft.com/en-us/library ... xy(v=vs.90).aspx
apparently your system has a proxy preset. If you want to ignore those settings you need to define a new variable to call GloblaProxySelection: which has a method called "GetEmptyWebProxy".
This hopefully does the trick. I haven't tested it on my system.
Many thanks for the info! I wil give that a try.
Bruce Anderson
I was taking a look into this. Unfortunately your link seems broken?
If I add the dotnet, I can call:
DefaultProxy.GetEmptyWebProxy,
but I am not sure what to do with it.
I tried adding this:
FTPRequest.Proxy := DefaultProxy.GetEmptyWebProxy;
Then I get this:
This message is for C/AL programmers: A DotNet variable has not been instantiated. Attempting to call System.Net.FtpWebRequest.Proxy in CodeUnit FTP Transfer: Testdotnetftp
I didn't know we had to instantiate a dotnet variable.. (new to dotnet in NAV suffice it to say). I tried CREATE(DefaultProxy), but that gives an error that dotnet variables cannot be used with create. ](*,)
Bruce Anderson
You do this like this:
<VariableName> := <VariableName>.<ClassName>(<parameter1>,<parameter2>);
If you hit F5 you will get a list of constructors in the Symbol Menu. You will find in this exmaple that only the default constructor with empty parameters is available.
The call would look like this:
btw here is the correct link: http://msdn.microsoft.com/de-ch/library/system.net.globalproxyselection.aspx
But you can always type the class name in google and 99% of the times the msdn reference about it will come up as first result
With your info I was able to get it to work. Much appreciated.
Bruce Anderson
After logging into the server with this:
defaultProxy := DefaultProxy.GlobalProxySelection;
URL := 'ftp://myserver.com/test/testfile.txt';
FTPRequest := WebRequest.Create(URL);
Credentials := Credentials.NetworkCredential('***', '***');
FTPRequest.Proxy := defaultProxy.GetEmptyWebProxy;
FTPRequest.Credentials := Credentials;
FTPRequest.KeepAlive := FALSE;
FTPRequest.UseBinary := TRUE;
FTPRequest.Method := 'STOR';
FTPRequest.UsePassive := TRUE;
FileStream := FileA.OpenRead('c:\testfile.txt');
I tried this then to retrieve from ftp (Changing FileA.OpenRead to FileA.OpenWrite - OK yes I am guessing here)
----
FileStream := FileA.OpenWrite('c:\testfile.txt');
FTPRequest.GetRequestStream.Write(FileA.ReadAllBytes('c:\testfile.txt'), 0, FileStream.Length);
----
But it seems to trip over itself with the error:
"A call to System.IO.File.ReadAllBytes failed with this message: The process cannot access the file 'c:\testfile.txt' because it is being used by another process."
Bruce Anderson