When a drupal application is consuming a WCF service that we inherited, it sends an xml that should result in an entity framework parameter. After some schema changes, we updated the entity framework model (edmx file). The problem is that when the client calls the service (with the same code as before) the usageritem parameter is not properly deserialized. The call send to the method is the following:
<UpdateUsager xmlns="http://tempuri.org/">
<usageritem xmlns:a="http://schemas.datacontract.org/2004/07/CNVGestion.Domain" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" z:Id="i1">
<EntityKey xmlns="http://schemas.datacontract.org/2004/07/System.Data.Objects.DataClasses" xmlns:b="http://schemas.datacontract.org/2004/07/System.Data" i:nil="true"/><a:ADR1>7 rue Diffonty</a:ADR1> ....
The method that receives this call has the following header:
public string UpdateUsager(fUsagerItem usageritem, bool checkonly){
The edmx where the entity is declared has the following header
<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
<!-- EF Runtime content -->
<edmx:Runtime>
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="FRONT.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
I wanted to know if there could not be a problem between the fact that this edmx was generated before using sql server 2005 and we are using sql server 2012 now to update it and we only changed the ProviderManifestToken="2005".. Thank you for your help
Your question is a bit ambiguous - does the call to your service fails before entering your method or, if not, do you mean the parameter is null or some of its properties are null?
If the latter, I can only guess that updating the Entity Framework model from the database, changed the property order in fUsagerItem
class. You can manually inspect the .xsd file referenced by service's WSDL and see how WCF expects the XML to be. Change the serialization order of properties with [DataMember(Order = ?)]
attribute, though you'll have to put those in designer-generated classes (which is a bad idea).
It is generally considered that you shouldn't directly use entity framework objects in web service, especially when you consume the service from other frameworks like PHP. You have more control over the serialization process when you create your own Data Transport Objects: you can hide some properties or introduce new ones that don't exist in your database. If you can persuade your client to change their implementation, I'd recommend using DTO classes in your sevice (AutoMapper can help a lot mapping DTO objects to entities and vice-versa).