0

I've been having trouble querying a web server for information from my Windows Phone 7 app, and from my research, I've traced it back to MaxBufferSize/MaxReceivedMessageSize being too low. The problem is, I can't figure out how to change it. Every search result I find talks about the application being a WCF app, and to change the binding in ServiceReferences.ClientConfig. The solution from this post gives this example:

1. edit the ServiceReferences.ClientConfig to accept a large buffer.

 <binding name="BasicHttpBinding_MosaicService" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">  

However, I'm not using a WCF app, and I don't know what the equivalents of the above, and ServiceReferences.ClientConfig are for a regular WP7 application. Can anyone give me some help with this? I've done my best to figure it out myself but I'm getting nowhere.

For reference, in case someone else is having the problem I was (it took a really long time to figure out that this may be the problem), this is what is happening to me: I'm getting a WebException with the message: "The remote server returned an error: NotFound" thrown. And the relevant section of the stacktrace is:

at System.Net.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
404 Not Found
  • 3,635
  • 2
  • 28
  • 34

1 Answers1

1

I'm not sure how you went from the error message "The remote server returned an error: NotFound" to thinking that your client can't handle the size of the response. Much more likely, the error message is correct and the URL you are requesting can't be found. Drop a breakpoint in your code where you kick off the request. What is the RequestUri property set to on your HttpWebRequest object? Copy that URL into a browser and you'll more than likely see that you get a "page not found". Fix your incorrect URL and all will be well.

Robert Levy
  • 28,747
  • 6
  • 62
  • 94
  • No, the URL is correct. I can copy the exact URL into my browser and it works fine. Also, the query sometimes works depending on the query string; for example,"example.com/request?thing=a" works but "example.com/request?thing=b" doesn't. The reason I came to the conclusion that this was the problem was because, during all of the research into the error I performed, it was the only thing that seemed to make sense. I found it as it was the solution linked in [this post](http://forums.silverlight.net/t/53458.aspx) (also linked above). – 404 Not Found Nov 19 '11 at 04:08
  • Actually, you may be right. I feel stupid now. It looks like the server is returning a 405 error, but for some reason, I can't replicate the error in my browser. I guess I'll just have to work around it. – 404 Not Found Nov 19 '11 at 05:05