The remote server returned an error: NotFound

The remote server returned an error: NotFound

Old forum URL: forums.lhotka.net/forums/t/10335.aspx


lds posted on Tuesday, May 03, 2011

Hi Rocky,

I have been reading your great ebooks. Using them as a guide I have been
working on a Silverlight App that follows the setup of "AzureHost" solution
in the "04-DataPortal-110426" sample folder.

I have an Editable Root abject that all works normal as long as its size
does not get too big, when the size increases and I try to save the
object I receive the Message "The remote server returned an error: NotFound.".

Next In order to eliminate all that I could be doing wrong in my solution
I took the "AzureHost" solution and made the following 3 changes to
reproduce the error;

PersonEdit.cs
// 1st Change
// Add a String Property.
public static readonly PropertyInfo<string> BigStringProperty = RegisterProperty<string>(c => c.BigString);
public string BigString
{
  get { return GetProperty(BigStringProperty); }
  set { SetProperty(BigStringProperty, value); }
}

public override void DataPortal_Create(Csla.DataPortalClient.LocalProxy<PersonEdit>.CompletedHandler handler)
{
  using (BypassPropertyChecks)
  {
    Id = -1;

    // 2nd Change
    // This will push the size to where there will be an error when the object is saved.
    BigString = new string('x', 13000);
  }
  base.DataPortal_Create(handler);
}


App.xaml.cs
private void Application_Startup(object sender, StartupEventArgs e)
{
  // 3rd Change
  // Extend the limits.
  var binding = new BasicHttpBinding();
       
  binding.MaxBufferSize = int.MaxValue;
  binding.MaxReceivedMessageSize = int.MaxValue;
  binding.ReceiveTimeout = TimeSpan.FromMinutes(10);
  binding.SendTimeout = TimeSpan.FromMinutes(10);
  binding.OpenTimeout = TimeSpan.FromMinutes(10);
       
  Csla.DataPortalClient.WcfProxy.DefaultBinding = binding;
  Csla.DataPortalClient.WcfProxy.DefaultUrl = "http://127.0.0.1:81/SlPortal.svc";

  this.RootVisual = new MainPage();
}

With these changes made when the Save Button is pressed the followin error is
returned in OnError(Exception error) of OnPersonViewModel.cs

error {: The remote server returned an error: NotFound.
   at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
   at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
   at Csla.WcfPortal.WcfPortalClient.WcfPortalClientChannel.EndUpdate(IAsyncResult result)
   at Csla.WcfPortal.WcfPortalClient.Csla.WcfPortal.IWcfPortal.EndUpdate(IAsyncResult result)
   at Csla.WcfPortal.WcfPortalClient.OnEndUpdate(IAsyncResult result)
   at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
: The remote server returned an error: NotFound.
   at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
   at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult

result)
: The remote server returned an error: NotFound.
   at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
   at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
   at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__1(Object sendState)
} System.Exception {Csla.DataPortalException}


// I also added the following to Web.Config.
<system.diagnostics>
 <sources>
   <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
     <listeners>
       <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\temp\AzureHostTraces.log"  />
     </listeners>
   </source>
 </sources>
 <trace autoflush="true" />
</system.diagnostics>

And In the Log file there is a exception with the following Message:
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter

http://ws.lhotka.net/WcfDataPortal:request. The InnerException message was 'There was an error deserializing the object of type

Csla.Server.Hosts.Silverlight.UpdateRequest. The maximum array length quota (16384) has been exceeded while reading XML data. This quota

may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line

1, position 24487.'.  Please see InnerException for more details.

Any Idea as to what it could be wrong?

Luigi

RockfordLhotka replied on Tuesday, May 03, 2011

I think the endpoint element in the web.config of the web role is incorrect. It is missing the bindingConfiguration property:

<endpoint binding="basicHttpBinding" bindingConfiguration="basicHttpBinding_IWcfPortal"
contract="Csla.Server.Hosts.Silverlight.IWcfPortal"/>

 Let me know if that helps.

RockfordLhotka replied on Tuesday, May 03, 2011

You shouldn't have to extend the limits on the client btw, the default binding created by the data portal has the values maxed out.

I added the missing bindingConfiguration property to the web.config and that appears to solve the issue.

Thank you for helping to find this - I'll fix it in the ebook and sample code.

lds replied on Tuesday, May 03, 2011

Hi Rocky,

Thank you for taking a look at this, I removed the changes from App.xaml.cs and here is the updated Web.Config section.

  <system.serviceModel>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <services>
      <service name="Csla.Server.Hosts.WcfPortal" behaviorConfiguration="returnFaults">
        <endpoint binding="wsHttpBinding" contract="Csla.Server.Hosts.IWcfPortal" bindingConfiguration="wsHttpBinding_IWcfPortal"/>
      </service>
      <service name="basicHttpBinding_IWcfPortal"  behaviorConfiguration="returnFaults" >
        <endpoint binding="basicHttpBinding"
                  contract="Csla.Server.Hosts.Silverlight.IWcfPortal"
                  bindingConfiguration="basicHttpBinding_IWcfPortal"/>
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBinding_IWcfPortal" maxReceivedMessageSize="2147483647">
          <readerQuotas maxBytesPerRead="2147483647"
                        maxArrayLength="2147483647"
                        maxStringContentLength="2147483647"
                        maxDepth="1024"/>
        </binding>
      </basicHttpBinding>
      <wsHttpBinding>
        <binding name="wsHttpBinding_IWcfPortal" maxReceivedMessageSize="2147483647">
          <readerQuotas maxBytesPerRead="2147483647"
                        maxArrayLength="2147483647"
                        maxStringContentLength="2147483647"
                        maxDepth="1024"/>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="returnFaults">
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

I'm still getting the same error.

Luigi

RockfordLhotka replied on Tuesday, May 03, 2011

Interesting. I agree that it fails. So does the IISHost project, so it isn't an Azure issue.

There must be some other configuration limit that was added to WCF in .NET 4 that's causing this issue...

RockfordLhotka replied on Tuesday, May 03, 2011

Ahh, we're missing this:

                        maxNameTableCharCount="2147483647"

So the web.config should contain:

      <basicHttpBinding>
        <binding name="basicHttpBinding_IWcfPortal"
                 maxReceivedMessageSize="2147483647">
          <readerQuotas maxBytesPerRead="2147483647"
                        maxArrayLength="2147483647"
                        maxStringContentLength="2147483647"
                        maxNameTableCharCount="2147483647"
                        maxDepth="2147483647"/>
        </binding>
      </basicHttpBinding>

 

RockfordLhotka replied on Tuesday, May 03, 2011

Hmm, that doesn't seem to help either.

I'm open to suggestions at this point - clearly we're missing some config value...

RockfordLhotka replied on Tuesday, May 03, 2011

OK, now I feel really dumb...

The problem is a copy-paste issue or something. The service name is wrong, so the entire config section we're altering is being ignored...

The service name must match the name of the service in the svc file:

      <service name="Csla.Server.Hosts.Silverlight.WcfPortal"

Doh! 

lds replied on Tuesday, May 03, 2011

All works as it should now...

Thank You Rocky... I'm looking forward to read the rest of the ebooks!!!

Luigi

Copyright (c) Marimer LLC