Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Calling WCF service problem RSS

2 replies

Last post Mar 14, 2008 02:00 PM by sladapter

(0)
  • sladapter

    sladapter

    All-Star

    43609 Points

    7910 Posts

    Calling WCF service problem

    Mar 14, 2008 01:35 AM | LINK

     I have a simple WCF service looks like this:

     

    public class FileUploadService : IFileUploadService
        {        
            #region IFileUploadService Members

            public string DoUpload(string FileName, string Content)
            {
                System.Threading.Thread.Sleep(3000);
                return FileName;                       
            }

            #endregion
        }

     

    I have code to call this service in my silverlight control:

    string fileName = "somestring";

    string content = "somerandomstring";

    var fs = new FileUploadService.FileUploadServiceClient();     
    fs.DoUploadCompleted +=new EventHandler<FileUploadService.DoUploadCompletedEventArgs>(fs_DoUploadCompleted);
    fs.DoUploadAsync(
    fileName, content);

     void fs_DoUploadCompleted(object sender, FileUploadService.DoUploadCompletedEventArgs e)
     {
                if (e.Error == null)
                { 

                  //do something with the e.Result

                }

    }

    It works fine until I put a longer string in the content variable. I would get an error in the following generated code in Reference.cs:

     public string EndDoUpload(System.IAsyncResult result)

    {
                    object[] _args = new object[0];
                    string _result = ((string)(base.EndInvoke("DoUpload", _args, result)));  //Error here
                    return _result;
    }

    The error message is:

    An exception of type 'System.ServiceModel.ProtocolException' occurred in System.ServiceModel.dll but was not handled in user code

    Additional information: [UnexpectedHttpResponseCode]
    Arguments:Not Found

    I did all tests to see how long I can set the content string variable without getting error. The magic number is 8192. If the string length is greater than 8192, I would get the error. But works fine for shorter string.

    Is this a bug?

     

    Sally Xu
    Software Engineer
    Aprimo, Inc

    Please remember to mark the replies as answers if they answered your question
  • jackbond

    jackbond

    Contributor

    5812 Points

    1559 Posts

    Re: Calling WCF service problem

    Mar 14, 2008 01:55 AM | LINK

    I think you've hit the limit for the default max size on a web service request. This thread might help you:

    http://silverlight.net/forums/t/11313.aspx

    sladapter

            public string DoUpload(string FileName, string Content)
            {
                System.Threading.Thread.Sleep(3000);
                return FileName;                       
            }

    On a side note, I'm curious, why do you have a Sleep statement there?

                           

  • sladapter

    sladapter

    All-Star

    43609 Points

    7910 Posts

    Re: Calling WCF service problem

    Mar 14, 2008 02:00 PM | LINK

     Thanks jackbond!

    The solution in the link you provided solved problem.

    By the way, the Thread.Sleep statement is there for testing purpose. It will be replaced with real code. 

    Sally Xu
    Software Engineer
    Aprimo, Inc

    Please remember to mark the replies as answers if they answered your question