The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

WCF serialization

Last post 02-18-2008, 9:05 AM by msyoung. 13 replies.
Sort Posts: Previous Next
  •  06-04-2007, 5:45 AM 3026

    WCF serialization

    We have used dOOdads for a good while.  We are implementing a project using WCF and decided to switch to EntitySpaces because of the serialization.  However, we have not been able to get the deserialization to occcur.  Do you have any clients who have successfully used EntitySpaces with WCF? 

    Filed under:
  •  06-04-2007, 8:31 AM 3029 in reply to 3026

    Re: WCF serialization

    Can you send a little test app to support@entityspaces.net, create one that uses SQL's northwind database, just something demonstrating the problem and well fix or show how it should work.
    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  06-04-2007, 9:24 PM 3032 in reply to 3029

    Re: WCF serialization

    Okay, I think we fixed this tonight. Are you using and EntitySpaces object on the ServiceHost side and then a dummy object with just the properties on the client side?  We just did full WCF serialization back and forth, there was a bug on this but it's fixed, a new build isn't up yet but will be soon, let me talk to the team.

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  06-05-2007, 6:47 PM 3057 in reply to 3032

    Re: WCF serialization

    It appears WCF is running along the lines of some other poor offerings Microsoft has put out of late. WCF Serialization uses total 100% reflection and offers you zero customization abilities via XmlIgnore or anything else for that matter (even though the documentation states it should work). The blog-o-sphere is full of folks disappointed in this. This is incredibly frustrating and means we basically get to either create proxy classes or wrappers around our real objects or we hand code the XML returned by the service hosts. Honestly, and I'm sorry to say this, but Microsoft really doesn't have a clue on how we need to use this stuff and I fear a lot of this "core" code is being written by less than experienced architects.

    Search in Google for this and you'll see what I mean: XmlSerializerFormat WCF

    Anyway, we're still working on this but very disappointed in the lack of thought put into WCF.
     


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  06-05-2007, 6:58 PM 3058 in reply to 3057

    Re: WCF serialization

    We created a test that used a binary formatter and serialized an object, sent it to the client, changed it, re-serialized it, sent it back, deserialized it, and saved it.  Not what we wanted, but it might work until we come up with another solution.  It was a single object, not a collection.
  •  06-05-2007, 10:12 PM 3059 in reply to 3058

    Re: WCF serialization

    I sent a message to your email account, let me know if you receive it. Sorry for the poor quality of the email I use spam arrest which is good for spam but probably the worse html email system in the world, well, not the worst, there's always squirrel mail.

    To return data from the server to the client you do this:

    Code:
    Employees employee = new Employees(); 
    employee.LoadByPrimaryKey(Convert.ToInt32(id));

    return new EmployeesWCFProxyStub(employee);


    On the client side you can use the same class to deserialize like this: 

     

    Code:
    EmployeesWCFProxyStub proxy = response.GetBody<EmployeesWCFProxyStub>(); 
    BusinessObjects.Employees emp = proxy.Entity;
     
    There is a new template attached that generates the proxy/stub wrapper which is very lightweight, you generate it and put it in your custom folder, we don't consider this a generated class (yet). I'm curious as to what you think of it. If the WCF just obeyed the [XmlIgnore] attribute we wouldn't have to do anything of this extra stuff, uggh ...

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  06-06-2007, 6:27 AM 3066 in reply to 3059

    Re: WCF serialization

    The idea of a proxy/stub made me toss and turn all night, I think we are going to implement IXmlSerializable and take control of all our XML serialization. This will make the fix perfectly seemless. We plan on providing you a test build in a few days.
    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  06-06-2007, 7:56 AM 3067 in reply to 3059

    Re: WCF serialization

    We received the message.  If I understand it correctly, we are only passing back and forth the generated proxy stub, creating it on the sending side and recreating the base object on the receiving side, so only the properties representing contents of the table row(s) are going back and forth.  I will try it and see if it is gong to work for us.
     

  •  06-06-2007, 10:12 AM 3069 in reply to 3067

    Re: WCF serialization

    Actually, you are not really passing the proxy / stub, they are just ensuring the right "things" are serialized. What we really need is a sample app, is there any chance you guys can send us a very simple, one table example of using WCF to do what you guys want, honestly, if you do that we'll get you a fix right away, we want out WCF to be seamless, I'm just not a WCF expert, if you send me an app to support@entityspaces.net will make sure you have killer WCF serialization (and EntitySpaces then will do). Can you guys get us such an app?

     - Mike


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  06-07-2007, 9:16 AM 3099 in reply to 3069

    Re: WCF serialization

    Any news on this, did the proxy / stub do the trick? We're going to make sure we have this correct before any minor release to ES2007 goes out. I though you guys might find this interesting, WCF serialization is far from trivial, why? I have no idea. Our Soap serialization works fine.

    http://pluralsight.com/blogs/aaron/archive/2006/05/13/23467.aspx

    http://blogs.msdn.com/sowmy/archive/2006/02/22/536747.aspx

     


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  06-08-2007, 6:22 AM 3115 in reply to 3099

    Re: WCF serialization

    Okay, some very good news. Our plan is to release a minor maintenance release to ES2007 mainly for the WCF stuff over the June 16/17 weekend. We will have full support for both binary and XML serialization in the WCF scenario. There is a new tab on the generated template specifically for WCF. If you check it you get a tiny proxy/stub for both entities and collections, they will be located in your single file during the generation. The really cool thing is that state is maintained (added/deleted/modified) as you pass your entities around in XML. Here is the naming convention:

    For the Northwind Employees table you will have:

    • EmpoyeesProxyStub
    • EmployeesCollectionProxySub

    They are very lightweight and can be used for any XML serialization needs, of course, you don't need these to do web services but they are very handy to have around. For those of you working with WCF now we can make a beta available before the official release if you email us at support@entityspaces.net, but this will not be a public beta.

     


     


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  06-09-2007, 10:28 AM 3132 in reply to 3115

    Re: WCF serialization

    See this blog POST

     


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  07-05-2007, 12:26 PM 3605 in reply to 3132

    Re: WCF serialization

    Does anyone have a working full example of WCF and ES that they can share?

    Here's what I have, based on Generated/Custom classes called VisibilityType:

    ServiceContract/Implementation:

    Code:
        [ServiceContract(Namespace="http://MyNamespace", SessionMode=SessionMode.Allowed)]
        public interface IVisibilityTypeService
        {
            [OperationContract]
            MyNamespace.VisibilityTypeProxyStub Get(System.Int32 request);
        }
    
        public class VisibilityTypeService : IVisibilityTypeService
        {
            #region IVisibilityTypeService Members
    
            public MyNamespace.VisibilityTypeProxyStub Get(int request)
            {
                VisibilityType thisType = new VisibilityType();
                thisType.LoadByPrimaryKey(request);
                return new VisibilityTypeProxyStub(thisType);
            }
    

    Exposed by a host project containing VisibilityTypeService.svc.

    I am using the Patterns & Practices Service Factory, so when I generate the service reference I get this VisibilityTypeService.cs:

    Code:
    namespace MyNamespace
    {
        using System.Runtime.Serialization;
        using System;
    
    
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
        [System.Runtime.Serialization.DataContractAttribute(Namespace="http://MyNamespace/")]
        [System.SerializableAttribute()]
        public partial class VisibilityType : object, System.Runtime.Serialization.IExtensibleDataObject
        {
    
            [System.NonSerializedAttribute()]
            private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
    
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private System.Nullable<int> VisibilityTypeIDField;
    
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private string VisibilityTypeDescriptionField;
    
            [System.Runtime.Serialization.OptionalFieldAttribute()]
            private string esRowStateField;
    
            public System.Runtime.Serialization.ExtensionDataObject ExtensionData
            {
                get
                {
                    return this.extensionDataField;
                }
                set
                {
                    this.extensionDataField = value;
                }
            }
    
            [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false)]
            public System.Nullable<int> VisibilityTypeID
            {
                get
                {
                    return this.VisibilityTypeIDField;
                }
                set
                {
                    this.VisibilityTypeIDField = value;
                }
            }
    
            [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=1)]
            public string VisibilityTypeDescription
            {
                get
                {
                    return this.VisibilityTypeDescriptionField;
                }
                set
                {
                    this.VisibilityTypeDescriptionField = value;
                }
            }
    
            [System.Runtime.Serialization.DataMemberAttribute(Order=2)]
            public string esRowState
            {
                get
                {
                    return this.esRowStateField;
                }
                set
                {
                    this.esRowStateField = value;
                }
            }
        }
    
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
        [System.ServiceModel.ServiceContractAttribute(Namespace="http://MyNamespace", ConfigurationName="MyNamespace.IVisibilityTypeService")]
        public interface IVisibilityTypeService
        {
    
            [System.ServiceModel.OperationContractAttribute(Action="http://MyNamespace/IVisibilityTypeService/Get", ReplyAction="http://MyNamespace/IVisibilityTypeService/GetResponse")]
            MyNamespace.VisibilityType Get(int request);
        }
    
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
        public interface IVisibilityTypeServiceChannel : MyNamespace.IVisibilityTypeService, System.ServiceModel.IClientChannel
        {
        }
    
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
        public partial class VisibilityTypeServiceClient : System.ServiceModel.ClientBase, MyNamespace.IVisibilityTypeService
        {
    
            public VisibilityTypeServiceClient()
            {
            }
    
            public VisibilityTypeServiceClient(string endpointConfigurationName)
                :
                    base(endpointConfigurationName)
            {
            }
    
            public VisibilityTypeServiceClient(string endpointConfigurationName, string remoteAddress)
                :
                    base(endpointConfigurationName, remoteAddress)
            {
            }
    
            public VisibilityTypeServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress)
                :
                    base(endpointConfigurationName, remoteAddress)
            {
            }
    
            public VisibilityTypeServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress)
                :
                    base(binding, remoteAddress)
            {
            }
    
            public MyNamespace.VisibilityType Get(int request)
            {
                return base.Channel.Get(request);
            }
        }
    }
    
    On my test form, I have a button and a listbox and added this to the button click:
    Code:
    MyNamespace.VisibilityTypeServiceClient thisClient = new MyNamespace.VisibilityTypeServiceClient();
    MyNamespace.VisibilityTyp thisType = thisClient.Get(1);
    listBox1.Items.Add(thisType.VisibilityTypeDescription);
    
     

    When I run it it hangs at the "Get". The Get does not show as returning a VisibilityTypeProxyStub, but a VisibilityType. I thought maybe the guidance package was doing something funny so I just used svcutil to generate the client class and it still didn't come back with the ProxySub.

    How do you get it to return the proxy? Anything obviously wrong with what I'm doing?

    Thanks,
    - Robert Paquette
    ITIQ Solutions

  •  02-18-2008, 9:05 AM 8113 in reply to 3605

    Re: WCF serialization

    What I found is that the "proxystub" IS being returned, it just looks like the entity to the client app.
View as RSS news feed in XML