Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a custom workflow in SharePoint 2010 and at one stage in the workflow I will be uploading an xml to file to an FTP site from within the SharePoint workflow. (I am not uploading anything to the SharePoint site).

However, I have been having some difficulties. On some machines it works fine, on other machines it does not. Is there any special proxies that SharePoint is behind or any special settings inside Windows Firewall that might be preventing this uploading from occurring? Or any settings at all in SharePoint that might be causing these FTP issues? Typically I will get a return code of 500 from the machines that the upload does not work on.

Again, I am not uploading to a SharePoint site, but from a SharePoint site to an FTP site.

Also, I can create a basic Console Application and upload the xml file to the ftp site just fine from one of that machines that the workflow ftp upload fails on, but when I copy and paste that same code into the SharePoint workflow, it fails. Here is the code:

    try
    {
        FileInfo fi = new FileInfo(DocumentState.TipAndLeadPath);            

        // Get the object used to communicate with the server.
        FtpWebRequest request = (FtpWebRequest)WebRequest.Create(@"ftp://999.999.999/" + fi.Name);
        request.Method = WebRequestMethods.Ftp.UploadFile;

        // This example assumes the FTP site uses anonymous logon.
        request.Credentials = new NetworkCredential(SharepointState.FTPUserName, SharepointState.FTPPassword);
        request.UsePassive = false;

        state.Request = request;
        state.FileName = fi.FullName;

        // Copy the contents of the file to the request stream.
        StreamReader sourceStream = new StreamReader(DocumentState.TipAndLeadPath);
        byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
        sourceStream.Close();
        request.ContentLength = fileContents.Length;

        Stream requestStream = request.GetRequestStream();
        requestStream.Write(fileContents, 0, fileContents.Length);
        requestStream.Close();

        FtpWebResponse response = (FtpWebResponse)request.GetResponse();

        state.StatusDescription = response.StatusDescription;
        // Signal the main application thread that 
        // the operation is complete.
        state.OperationComplete.Set();
        //Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);

        response.Close();

        return state;
    }
    catch (Exception ex)
    {
        ListErrorLogger.WriteError("FTP UPLOAD", ex.Message, ex.StackTrace);
    }

    return state;
share|improve this question
    
Could you add some further logging info, like relevant ULS log entries? –  Anders Rask Jul 18 '11 at 17:07
    
When you say it doesnt work on "some machines" do you mean client machines? The workflow executes on the server in system user context, so there really shouldnt be differences between client machines... –  Anders Rask Jul 18 '11 at 17:10
    
When I go home and try it out on my home computer, I will get a response error code of 500 during the FTP upload. But here at work, on the machine I developed on, it works just fine. By machines, I mean other computers or virtual machines that I use to test the product on –  Meyer Denney Jul 18 '11 at 17:13
    
When I return home (where the computer that was having the FTP Upload issues) I will post the relevant ULS logs. Unfortunately, I don't have them with me right now since the FTP upload works just fine on the computer I am on here at work. –  Meyer Denney Jul 18 '11 at 17:14
    
How do you reach this server from home? Is it a WCM solution or are you connecting to work using VPN of some kind? –  Anders Rask Jul 18 '11 at 17:20

3 Answers 3

You will need to give us the ULS logs with stack trace of the error to help you further.

My best guess is that you do some kind of file transfer from your client, and it is this file upload that fails. But this is only a guess since you havent dug out the error from the logs yet...

share|improve this answer

I finally figure it out. You need to create a custom inbound traffic rule in Windows Firewall around the w3p process. Here is a walkthrough.

  1. Create a new Rule in Inbound traffic
  2. Select Custom

  3. Select “This Program Path”

  4. Find the w3wp.exe service (usually in Windows\System32 folder)

  5. Click Customize

  6. Select “Apply to services only”

  7. Change the Protocol Type to TCP

  8. Set local and remote ports to “All Ports” (you can try to narrow it down to only port 21, but that doesn't always work, especially with asynchronous uploads)

  9. Select any IP address for local IP addresses (or a range if you know the local IP address range)

  10. Select “These IP addresses” for remote IP addresses and click Add.
  11. Enter the IP address of the FTP site you will be uploading too

  12. Click OK once you have added the FTP IP address, then click Next

  13. Select Allow the Connection

  14. Apply rule to Domain, Private and Public

  15. Name is “Allow incoming TCP w3wp.exe traffic from port 21”

  16. Click finish

share|improve this answer

It is quite possible and probable your company firewall is blocking FTP access. What happens when you do a direct FTP:// access to your FTP site from home?

share|improve this answer
    
I can access the FTP site just fine from and at work using Windows Explorer, FileZilla, Chrome etc. The issue is when I throw that code into the SharePoint workflow, it won't work from my home computer (Windows Firewall Disabled). But if I put that exact code into a Console Application at home, it works just fine. Which makes me suspect SharePoint has something extra to it, preventing the file upload to the FTP site –  Meyer Denney Jul 18 '11 at 19:29
    
As i said in comments, the FTP will run between the server running SharePoint to the server running FTP, so this should not change based on location –  Anders Rask Jul 18 '11 at 19:40
    
Sorry I am new to SharePoint and am not quite familiar with all the terminology yet :). I am running this workflow from a local SharePoint server that is only hosted on my machine (both at work and the one at home). They are two different SharePoint servers and have no other site collections/farms attached to them. –  Meyer Denney Jul 19 '11 at 16:41
    
ah ok i assumed from the answer on the comments on question that there were one SharePoint install and multiple clients. I agree that it is probably something that blocks the request from your home dev environment. –  Anders Rask Jul 20 '11 at 7:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.