Hope developers team wouldn't miss my message. NullValueHandling must be an optional parameter for the JsonFormatter attribute because there are a lot of cases when properties of the object required on client side independently of their value.
And I personally got some troubles trying to identify why my object doesn't have half of it properties.
By the way limitation for DbConext and entity namespace to make the entity observerable on client side is not good too.
Thanks.
Breeze currently sets NullValueHandling to 'Ignore', so as to minimize payloads by not sending any 'null' values. We did not think that this would be an issue because the json serialized objects are materialized into 'breeze' entities on the client and breeze has metadata to determine what the valid properties for each entity are.
What is the use case for actually sending 'nulls' to the client? This is an relatively easy enhancement to make if we have a good use case. The only one that comes to mind is with anonymous objects queried from the server for which metadata will not exist. Is this what you are encountering?
Related
In our BizTalk application we would like all internal messages to have the same structure, with a Header element with routing and logging information (this header is the same for all messages), all properties of which are promoted, and a Body element which is different for each specific message. When I create a new message based on the above (by setting the schema's DataStructure or BaseType), I would like the promotions to be kept as well.
I tried getting this to work by creating a Header message with the required fields and promotions, and also by creating a "complete" BaseMessage with a Header and Body element (again with all properties in the header promoted), but either way in a schema using this DataStructure the property promotions are not kept (which I guess makes sense; the XPaths indicated in the PropertySchema are different, because the BaseMessage namespace is different from the derived message).
Is there a way to have a shared schema including property promotions? Or can you copy the structure in a derived message, but you always have to redo the promotions?
Thanks for any insights!
We have a similar header structure that is imported and always have to redo the promotions.
My recommendation would be to solve this problem by not doing what you're describing. While it sounds good in theory, you will find eventually that it's over-engineering with little practical benefit.
What will matter is the routing information, meaning, the Properties, not the Header section. So, it's fine to have shared Property Schemas (deployed separately) but don't try to shoehorn the messages into a 'common' wrapper.
How do I control which fields get serialized in Axis2? I have some fields (really getter/setter pairs) that I don't want exposed to the client. Also, some are coming across as nullable (e.g. someIntSpecified properties are created) where I want them.
I think there is unfortunately no annotation to exclude attributes from getting serialized.
I think you will need to create Data Transport Objects (DTOs). Otherwise you won't have a clean separation between your core business objects and the objects that you expose as API.
I am creating a brand new application, including the database, and I'm going to use Entity Framework Code First. This will also use WCF for services which also opens it up for multiple UI's for different devices, as well as making the services API usable from other unknown apps.
I have seen this batted around in several posts here on SO but I don't see direct questions or answers pertaining to Code First, although there are a few mentioning POCOs. I am going to ask the question again so here it goes - do I really need DTOs with Entity Framework Code First or can I use the model as a set of common entities for all boundaries? I am really trying to follow the YAGNI train of thought so while I have a clean sheet of paper I figured that I would get this out of the way first.
Thanks,
Paul Speranza
There is no definite answer to this problem and it is also the reason why you didn't find any.
Are you going to build services providing CRUD operations? It generally means that your services will be able to return, insert, update and delete entities as they are = you will always expose whole entity or single exactly defined serializable part of the entity to all clients. But once you do this it probably worth to check WCF Data Services.
Are you going to expose business facade working with entities? The facade will provide real business methods instead of just CRUD operations. These buisness methods will get some data object and decompose it to multiple entities in wrapped business logic. Here it makes sense to use specific DTO for every operation. DTO will transfer only data needed for the operation and return only date allowed to the client.
Very simple example. Suppose that your entities keep information like LastModifiedBy. This is probably information you want to pass back to the client. In the first scenario you have single serializable set so you will pass it back to the client and client pass it modified back to the service. Now you must verify that client didn't change the field because he probably didn't have permissions to do that. You must do it with every single field which client didn't have permission to change. In the second scenario your DTO with updated data will simply not include this property (= specialized DTO for your operation) so client will not be able to send you a new value at all.
It can be somehow related to the way how you want to work with data and where your real logic will be applied. Will it be on the service or on the client? How will you ensure that client will not post invalid data? Do you want to restrict passing invalid data by logic or by specific transferred objects?
I strongly recommend a dedicated view model.
Doing this means:
You can design the UI (and iterate on it) without having to wait to design the data model first.
There is less friction when you want to change the UI.
You can avoid security problems with auto-mapping/model binding "accidentally" updating fields which shouldn't be editable by the user -- just don't put them in the view model.
However, with a WCF Data Service, it's hard to ignore the advantage of being able to write the service in essentially one line when you expose entities directly. So that might make the most sense for the WCF/server side.
But when it comes to UI, you're "gonna need it."
do I really need DTOs with Entity Framework Code First or can I use the model as a set of common entities for all boundaries?
Yes, the same set of POCOs / entities can be used for all boundaries.
But a set of mappers / converters / configurators will be needed to adapt entities to some generic structures of each layer.
For example, when entities are configured with DataContract and DataMember attributes, WCF is able to transfer domain objects' state without creating any special classes.
Similarly, when entities are mapped using Entity Framework fluent mapping api, EF is able to persist domain objects' state in database without creating any special classes.
The same way, entities can be configured to be used in any layer by means of the layer infrastructure without creating any special classes.
I have a WCF service method that takes a complex parameter, which in turn has complex properties. The problem is that this parameter once it arrives at the server contains null for some of the properties.
I have checked using WCF tracing and Fiddler and the data is definitely going over the wire. Seems to be when the XML is deserialized into .net objects something goes wrong and some properties get set to null.
I've tried rebuilding the proxy in case some mismatch there.
EDIT: OK all fixed now. The data objects were POCO's generated from the EF T4 template and which have a separate field for the foreign key id's. I was forgetting to set this on the client, as soon as I did I started to get the complex properties returned on the server. Not exactly sure why though.
Have you used DataMember on these properties? and if the type is class, you should use DataContract on these types too.
Actually, when you use WCF tracing, you can see the xml.
If I have an object that holds the parameters for my method. I need to change the Object to have an additional property. I have full control over the server, but not over all of the clients. Will this change make those clients break?
I am using a self-hosted service with a binary endpoint.
I am new to WCF so my apologies if this is a silly question.
I guess you are asking about a class that represents your DataContract.
Learn about DataContract versioning and how various changes in your DataContract affect the compatibility in MSDN
In short the answer is No, it will not break the client code. The serialized graph of the data contract will deserialize to the available data members matching by their names and assigned through the property setter method. Obviously in this case, your newly added data member will not have value. Since you have full control on the server side code, you just have to make sure this newly added member need to be dealt in such a way that it is meaningful in the new implementation and allow for default/unassigned value.