views:

493

answers:

4

I'm not 100% sure what the correct terminologies are but..

I have a class called InParams with two fields, a string and a long and their corresponding Property accessors to the fields. These are decorated with [DataContract] and [DataMember] respectively.

I have a WCF service method called void Test(InParams inParams)

The proxy generated fine with svcutil and I was able to set the long field, however when the service method is execute the long field is always 0, even though I explicitly set the long field. I looked at the soap envelope and don't see a tag for my long field.

When I change the long field to a string field it gets serialized. This is the same for ints as well.

Am I missing an attribute or something?

+1  A: 

can you post a sample? double check to:

  • ensure class has [DataContract()] decoration
  • ensure PUBLIC properties have [DataMember()] decoration

Ensure your proxy class is up to date by removing/regenerating it. See if that makes a difference?

Tanner
Ya, im going to go with the property isnt public or something.
Mike_G
A: 

In addition to doing what Tanner mentioned, longs and ints are clearly supported by the DataContractSerializer.

.NET Framework primitive types. The following types built into the .NET Framework can all be serialized and are considered to be primitive types: Byte, SByte, Int16, Int32, Int64, UInt16, UInt32, UInt64, Single, Double, Boolean, Char, Decimal, Object, and String.Link

RandomNoob
I agree, was going to mention issues with known types but didn't because of the types involved.
Tanner
A: 

I have the same Problem, or at least very similar. I have a class with two Int32 and two Datetime attributes. The class is correctly decorated, the attr. are public and decorated, yet when i Invoke a method and send the object, these values are seted to zero or mindatetime.

I really have trouble dealing with this and i find it very weird. I'm consuming this method from win mobile PDA emulator

A: 

If you have a boolean YourPropertyNameSpacified property on the client in addition to YourPropertyName, you must set it to true on the client. This goes for all fields of value type, I believe. Also see http://stackoverflow.com/questions/1680356/wcf-service-proxy-not-setting-fieldspecified-property.

jonsb