Hey,
I have following simple ftpService class with a method download.
When I run the class not as a web service it works fine.
But when I run the class as a web service the FtpGetFile() method
fails.
I guess the reason is that I try to save a file locally, what is maybe not
allowed with in a web service.
Has anybody an idea?
Thanks a lot.
Ahoi
Maik Thiele
code:
-----
Imports System.Web.Services
<WebService(Namespace:="http://tempuri.org/")> _
Public Class ftpService
Inherits System.Web.Services.WebService
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal HINet
As Integer) As Integer
Private Declare Function InternetOpen Lib "wininet.dll" Alias
"InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Integer, ByVal
sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Integer)
As Integer
Private Declare Function InternetConnect Lib "wininet.dll" Alias
"InternetConnectA" (ByVal hInternetSession As Integer, ByVal sServerName As
String, ByVal nServerPort As Integer, ByVal sUsername As String, ByVal
sPassword As String, ByVal lService As Integer, ByVal lFlags As Integer,
ByVal lContext As Integer) As Integer
Private Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA"
(ByVal hFtpSession As Integer, ByVal lpszRemoteFile As String, ByVal
lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal
dwFlagsAndAttributes As Integer, ByVal dwFlags As Integer, ByVal dwContext
As Integer) As Boolean
Private Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA"
(ByVal hFtpSession As Integer, ByVal lpszLocalFile As String, ByVal
lpszRemoteFile As String, ByVal dwFlags As Integer, ByVal dwContext As
Integer) As Boolean
<WebMethod()> Public Function Download(ByVal ftphost As String, ByVal
filename As String, _
ByVal port As Integer, ByVal login As String, ByVal pwd As String) As String
Dim INet, INetConn As Integer
Dim RC As Boolean
INet = InternetOpen("FTP Connection", 1, vbNullString, vbNullString, 0)
INetConn = InternetConnect(INet, ftphost, port, login, pwd, 1, 0, 0)
RC = FtpGetFile(INetConn, filename, "C:\newfile.txt", False, 1, 0, 0)
InternetCloseHandle(INetConn)
InternetCloseHandle(INet)
if RC then
Return "successful"
else
Return"failed"
end if
End Function
End Class 1 4195
This is probably a simple ACL issue. Make sure you give the user that your
IIS/ASP.NET is running as rights to write to your directory. I had this
issue once and I resolved it by doing this.
Eric
--
Eric Cherng
MCP, MCDBA, MCSD http://echerng.com
"Maik Thiele" <mt******@inf.tu-dresden.de> wrote in message
news:2o************@uni-berlin.de... Hey,
I have following simple ftpService class with a method download. When I run the class not as a web service it works fine. But when I run the class as a web service the FtpGetFile() method fails. I guess the reason is that I try to save a file locally, what is maybe not allowed with in a web service.
Has anybody an idea?
Thanks a lot.
Ahoi Maik Thiele
code: -----
Imports System.Web.Services <WebService(Namespace:="http://tempuri.org/")> _ Public Class ftpService Inherits System.Web.Services.WebService
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal HINet As Integer) As Integer
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Integer, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Integer) As Integer
Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Integer, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Integer, ByVal lFlags As Integer, ByVal lContext As Integer) As Integer
Private Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" (ByVal hFtpSession As Integer, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal dwFlagsAndAttributes As Integer, ByVal dwFlags As Integer, ByVal dwContext As Integer) As Boolean
Private Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hFtpSession As Integer, ByVal lpszLocalFile As String, ByVal lpszRemoteFile As String, ByVal dwFlags As Integer, ByVal dwContext As Integer) As Boolean
<WebMethod()> Public Function Download(ByVal ftphost As String, ByVal filename As String, _ ByVal port As Integer, ByVal login As String, ByVal pwd As String) As String
Dim INet, INetConn As Integer Dim RC As Boolean INet = InternetOpen("FTP Connection", 1, vbNullString, vbNullString, 0) INetConn = InternetConnect(INet, ftphost, port, login, pwd, 1, 0, 0) RC = FtpGetFile(INetConn, filename, "C:\newfile.txt", False, 1, 0, 0) InternetCloseHandle(INetConn) InternetCloseHandle(INet) if RC then Return "successful" else Return"failed" end if End Function End Class
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: mjcsfo |
last post by:
I can't seem to find a reference nor any helpful threads on this
topic.
I've gotten the following error in two circumstances:
1. A complex type has nested within it another complex type, in the...
|
by: Daniel Frey |
last post by:
Hello,
Maybe you know howto. I want to have an element which takes a
subelement. Depending on an attribute within this subelement, a second
subelement may have different attributes allowed:
...
|
by: savesdeday |
last post by:
In my beginnning computer science class we were asked to translate a
simple interest problem. We are expected to write an algorithm that
gets values for the starting account balance B, annual...
|
by: Derrick |
last post by:
I have the below simple class -
public class MyClass
{
protected string m_stName;
protected string m_stCode;
protected int m_iId;
public MyClass() {}
|
by: Andrew |
last post by:
Hi,
I implemented a simple WMI Provider in C#.
It is a service which expose 10 instances of a simple WMI Class.
The WMI class pnly expose 4 public properties (Value,Min,Max,StdValue) which...
|
by: Kevin Burton |
last post by:
Thist is probably very simple for many of you but I am just catching on that
a major change has taken place in the way web projects work and I cannot get
it to work so please indulge me.
First,...
|
by: heddy |
last post by:
Howdy folks. I am trying to build a web service using the following
configuration:
I have Windows 2003 Server running in VMware. I have IIS set up on it.
I installed the .NET 2.0 package on...
|
by: Phillip Taylor |
last post by:
Hi guys, I'm looking to develop a simple web service in VB.NET but I'm
having some trivial issues. In Visual Studio I create a web services
project and change the asmx.vb file to this:
Imports...
|
by: sayeo87 |
last post by:
Hi, I am quite new to JSP so please forgive me if I ask really simple things... I am trying to run system commands on the server and display the output on a webpage. This is what I've got:
<%@...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |