This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I am trying to return an entity using a wcf service and i get this error.. 'Data.Member.facebookUid' is not marked with OptionalFieldAttribute, thus indicating that it must be serialized. However, 'Data.Member' derives from a class marked with DataContractAttribute and an IsReference setting of 'True'. It is not possible to have required data members on IsReference classes. Either decorate 'Data.Member.facebookUid' with OptionalFieldAttribute, or disable the IsReference setting on the appropriate parent class. Is there an easy fix for this? since Its not really possible to do what has been suggested in the error message as any decoration of fields get overwritten when the IsModel file gets re-generated Any ideas? |
|
|
Yes, you need to ensure you have a [DataContract] member (and associated [DataMember] attributes) applied to your entity. LightSpeed will automatically apply these as part of the designer generated code if you are referencing System.ServiceModel and System.Runtime.Serialization in the project where your model is defined.
|
|
|
Hi again, Ok i have managed to fix this error now.. however when the entity is returned i get a empty string.. No object or properties.. just completely blank.. any ideas? |
|
|
Are you saying that the response from your service call is an empty string or that the property values on the returned object are null? If you could post a code snippet that would be useful :)
|
|
|
Yes, the entire response is just blank. not even {} I'm getting just an empty string the code is as simple as this (but I'm getting it in all the other methods too)
|
|
|
Hi Lawrence, It sounds like you may be seeing a 400 response from the server - you can check this by reviewing the HTTP status code in something like Fiddler or the Chrome Web Inspector / Network. If you are getting back a 400 error then that indicates that WCF is throwing an exception, this is usually due to configuration issues so its best to enable tracing and then review what the issue is. I have set up a little test example here using the WebAPI and your code snippet and that happily returns a response, so if you are not seeing a problem such as the above and you are able to send through a small repro project for this we can have more of a look for you.
|
|
|
Hi Jeremy, Im getting a 200 OK response from the server... how strange.. maybe you can send me your project and ill integrate my code and see where it breaks? Lawrence |
|
|
No problem, have attached for you. |
|
|
thanks for this.. is it possible that I dont have the adequate references in my project? I see you have lots of exotics ones in there that i dont currently have |
|
|
Yes - you will need to make sure you include the WebApi references - easiest way to add that in is by using NuGet, from the package manager shell you can run Install-Package WebApi.All to have it add the associated references :) Other than that it is a vanilla Mvc3 project as created by Visual Studio. |
|