Programming with .NET - Generalhttp://forums.silverlight.net//17.aspx/1?Programming+with+NET+GeneralGeneral discussions around authoring Silverlight .NET applications.Mon, 01 Jan 0001 00:00:00 -05001736964http://forums.silverlight.net//p/11574/36964.aspx/1?Calling+WCF+service+problemCalling WCF service problem <p>&nbsp;I have a simple WCF service looks like this:</p> <p>&nbsp;</p> <blockquote><i>public class FileUploadService : IFileUploadService</i><br> <i>&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</i><br> <i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #region IFileUploadService Members</i><br> <br> <i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public string DoUpload(string FileName, string Content)</i><br> <i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</i><br> <i>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.Threading.Thread.Sleep(3000);</i><br> <i>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return FileName;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</i><br> <i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</i><br> <br> <i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #endregion</i><br> <i>&nbsp;&nbsp;&nbsp; }</i></blockquote> <p>&nbsp;</p> <p>I have code to call this service in my silverlight control:</p> <blockquote> <p><i>string fileName = &quot;somestring&quot;; </i><br> </p> <p><i>string <b>content</b> = &quot;somerandomstring&quot;; <br> </i></p> <p><i>var fs = new FileUploadService.FileUploadServiceClient();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br> fs.DoUploadCompleted &#43;=new EventHandler&lt;FileUploadService.DoUploadCompletedEventArgs&gt;(fs_DoUploadCompleted);<br> fs.DoUploadAsync(</i><i>fileName</i><i>, <b>content</b>); </i></p> <p><i>&nbsp;void fs_DoUploadCompleted(object sender, FileUploadService.DoUploadCompletedEventArgs e)<br> &nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (e.Error == null)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;</i></p> <p><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //do something with the e.Result<br> </i></p> <p><i>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } </i></p> <p><i>} </i></p> </blockquote> <p>It works fine until I put a longer string in the <b>content</b> variable. I would get an error in the following generated code in Reference.cs:<br> </p> <blockquote> <p>&nbsp;<i>public string EndDoUpload(System.IAsyncResult result)</i></p> <p><i>{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object[] _args = new object[0];<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b> string _result = ((string)(base.EndInvoke(&quot;DoUpload&quot;, _args, result)));</b>&nbsp; //Error here<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return _result;<br> } </i></p> </blockquote> <p>The error message is:</p> <blockquote> <p><i>An exception of type 'System.ServiceModel.ProtocolException' occurred in System.ServiceModel.dll but was not handled in user code<br> <br> Additional information: [UnexpectedHttpResponseCode]<br> Arguments:Not Found</i></p> </blockquote> <p>I did all tests to see how long I can set the <b>content</b> string variable without getting error. The magic number is<b> 8192</b>. If the string length is greater than 8192, I would get the error. But works fine for shorter string. </p> <p>Is this a bug? <br> </p> <p>&nbsp;</p> 2008-03-14T01:35:28-04:0036968http://forums.silverlight.net//p/11574/36968.aspx/1?Re+Calling+WCF+service+problemRe: Calling WCF service problem <p>I think&nbsp;you've hit the limit for the default max size on a web service request.&nbsp;This thread might help you:</p> <p><a href="http://silverlight.net/forums/t/11313.aspx">http://silverlight.net/forums/t/11313.aspx</a></p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>sladapter</h4> <i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public string DoUpload(string FileName, string Content)</i><br> <i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</i><br> <i>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.Threading.Thread.Sleep(3000);</i><br> <i>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return FileName;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</i><br> <i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</i></blockquote> <p></p> <p>On a side note, I'm curious, why do you have a Sleep statement there?<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p> 2008-03-14T01:55:28-04:0037141http://forums.silverlight.net//p/11574/37141.aspx/1?Re+Calling+WCF+service+problemRe: Calling WCF service problem <p>&nbsp;Thanks jackbond!</p> <p>The solution in the link you provided solved problem. </p> <p>By the way, the Thread.Sleep statement is there for testing purpose. It will be replaced with real code.&nbsp;</p> 2008-03-14T14:00:25-04:00