1

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?

Kwan Cheng
  • 696
  • 3
  • 12
  • 16
  • Do you have a boolean property called NameOfYourLongFieldSpecified in your generated proxy class? – Darin Dimitrov Apr 09 '09 at 14:38
  • I have the same issue as described above. The de-serialization was working fine until I added the WebAPI framework to the existing ASP.NET Web Forms application. The API methods internally calls the WCF methods which is in the service layer. The other parts of the application calls upon the WCF methods for data retrieval and have a lot of primitive value types. Once the WebAPI framework was added, the deserialization failed (traced the requests with TraceViewer and the params were having defaults - 0). Removed the WebAPI framework and everything went back to normal. Anyone faced such issues? – Nakash Hsakan Dec 29 '16 at 06:10
  • @Kwan Cheng. Did you find a solution to your problem. Nothing seems to work for mine and I had to use the WCF REST framework (webHttpBinding) to suit my needs which is like moving a step back. – Nakash Hsakan Dec 29 '16 at 06:14

3 Answers3

2

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
  • 22,205
  • 9
  • 65
  • 83
1

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 WCF service proxy not setting "FieldSpecified" property.

Community
  • 1
  • 1
jonsb
  • 2,016
  • 3
  • 21
  • 24
0

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

Ta01
  • 31,040
  • 13
  • 70
  • 99
  • I agree, was going to mention issues with known types but didn't because of the types involved. – Tanner Apr 09 '09 at 15:17