Criteria Not Serializing? Server Not Found?

Criteria Not Serializing? Server Not Found?

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


mosgath posted on Wednesday, January 12, 2011

I am working in CSLA 4.0 with Silverlight.  I have a created a command object derived from CommandBase that will be called to lock an order for a given user so others don't update it and returns the Order object in the proper state (ie readonly, editable).  It uses a CriteriaBase object for parameters.  If I do not use the OnGetState, OnSetState, OnGetChildren, OnSetChildren methods, the calls goes through, but the properties of the criteria object are null.  Some of the properties are of a type derived from BusinessBase.  If we call this using the aforementioned methods, we get a Server return error: Not Found in the silverlight client.  The silverlight client is able to call other DataPortal methods without any issues.  From other code samples I have seen, the logic for the on Children appear to be correct.  Below is the sample from the Command object.  The Criteria object implements the functions in a simliar manner.  The data is when the OnGetChildren is set.  The OnSetChildren creates new (blank) objects.  Any thoughts on where I should look?

        protected override void OnGetChildren(Csla.Serialization.Mobile.SerializationInfo info, Csla.Serialization.Mobile.MobileFormatter formatter)
        {
            base.OnGetChildren(info, formatter);
            if (this.CurrentOrder!= null)
            {
                var fmt = formatter.SerializeObject(this.CurrentOrder);
                info.AddChild("Order", fmt.ReferenceId);
            }
            var _criteriaFmt = formatter.SerializeObject(this.Criteria);
            info.AddChild("OrderCheckOutCriteria", _criteriaFmt.ReferenceId);
        }
        protected override void OnSetChildren(Csla.Serialization.Mobile.SerializationInfo info, Csla.Serialization.Mobile.MobileFormatter formatter)
        {
            if (info.Children.ContainsKey("Order"))
            {
                var data = info.Children["Order"];
                this.CurrentOrder = (Order)formatter.GetObject(data.ReferenceId);
            }
            var _criteriaData = info.Children["OrderCheckOutCriteria"];
            this.Criteria = (OrderCheckOutCriteria)formatter.GetObject(_criteriaData.ReferenceId);
            base.OnGetChildren(info, formatter);
       
        }

RockfordLhotka replied on Wednesday, January 12, 2011

If you are subclassing CriteriaBase why wouldn't you just use managed backing fields and let CSLA do the work for you? You shouldn't have to manually do that serialization gunk - that's what the base classes are for...

mosgath replied on Thursday, January 13, 2011

I have switched everything back over to using the managed properties and removed all the OnGetChildren and OnSetChildren.  However, I still get the Server Not Found Error.  As I mentioned before, Before making the call to this command, I am able to call into my BusinessBase objects without issues.  I did have a enum as a datatype that I switched to an Integer to see if that helped, but it didn't.

{: 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__DisplayClass2.<BeginOnUI>b__0(Object sendState)
}

RockfordLhotka replied on Thursday, January 13, 2011

Is it possible that the size of the serialized byte stream is extremely large and has blown out the size limits on WCF? That is a primary cause of the "Not Found" error.

mosgath replied on Thursday, January 13, 2011

Thanks Rocky.  That was definitely it.  We set the following in the web.config of the service project that this resolved the issue.  However, long term I am going to look at the compression option as well since we are using Silverlight.

httpRuntime maxRequestLength="8192" enable="true" executionTimeout="60"

Related Post:

http://forums.lhotka.net/forums/p/6463/31321.aspx

Copyright (c) Marimer LLC