none
Value type(int, decimal etc.) is not getting serialized when WCF service is consumed as web reference RRS feed

  • Question

  • Value type(int, decimal etc.) is not getting serialized when WCF service is consumed as web reference. Is thre any way , except making the DataMember as IsRequired = true ?
    Tuesday, January 11, 2011 5:54 PM

Answers

  • let's say the client does not want to send this value. how would in your mind the client instruct the proxy to do it?

    if the proxy would generate property instead of field, possibly in the setter it could automatically set XSpecified to true. But this would make a non consistent model since setting the value to false would still need to be explicit.

    In short - this is a client model issue with asmx clients.


    http://webservices20.blogspot.com/
    WCF Security, Interoperability And Performance Blog
    • Marked as answer by memukesh Sunday, January 16, 2011 11:22 PM
    Tuesday, January 11, 2011 8:36 PM

All replies

  • probably on the client side foe each field

    int X;

    you also have a field:

    bool XSpecified;

    make sure XSpecified is true.

    http://webservices20.blogspot.com/
    WCF Security, Interoperability And Performance Blog
    Tuesday, January 11, 2011 5:59 PM
  • Thanks Yaron for quick reply. I know it. But I donot want to enforce the client to set an extra field. Also What impact does it have if its a JAVA or any other client? Can it serialize it properly without this IsRequired = true
    Mukesh
    Tuesday, January 11, 2011 6:09 PM
  • If you do not set a data member as required, than it is optional.
    The only way for a c# client to treat this field as optional is to have the flag property, and so do some java frameworks behave.

    http://webservices20.blogspot.com/
    WCF Security, Interoperability And Performance Blog
    Tuesday, January 11, 2011 6:23 PM
  • Making the field as required or optional is fine. But my only concern is why it is not serializing the value even if client is sending it. Why do the client need an extra field(XSpecified) to serialize the property unlike service reference.

     


    Mukesh
    Tuesday, January 11, 2011 7:32 PM
  • let's say the client does not want to send this value. how would in your mind the client instruct the proxy to do it?

    if the proxy would generate property instead of field, possibly in the setter it could automatically set XSpecified to true. But this would make a non consistent model since setting the value to false would still need to be explicit.

    In short - this is a client model issue with asmx clients.


    http://webservices20.blogspot.com/
    WCF Security, Interoperability And Performance Blog
    • Marked as answer by memukesh Sunday, January 16, 2011 11:22 PM
    Tuesday, January 11, 2011 8:36 PM
  • Thank you Yaron! 8.5 years later this helped me solve some failing unit tests!
    Tuesday, October 15, 2019 2:56 PM