I think you should consider a slightly different design, we also had a similar problem, but we developed the following solution.
Primitive Arguments Only
Define only primitive types in web service method arguments (string, int), etc.
For example, you have a class,
class Person{
long PersonID;
long MembershipID;
string Name;
}
And you want to change the "Name" property to a backend, however, you should not trust your Frontend, you should refer to the fact that the interface can easily be hacked and send incorrect data, for example, MemberhipID in this case the field should not be changed using the interface.
, , - WSDL .
, .
[WebMethod]
public void SavePerson(Person p){
p.Save(); <-- this is dangerous
}
[WebMethod]
public void SavePersonName(long personID, string name){
Person p = GetPersonByID(personID);
p.Name = name;
p.Save();
}
, , , , , Wrapper.
Wrapper
class PersonAddressWrapper{
long PersonAddressID;
string AddressLine1;
string AddressLine2;
string ZipCode;
string City;
string Country;
}
class PersonWrapper{
long PersonID;
string Name;
PersonAddressWrapper[] Addresses;
}
[WebMethod]
public void SavePerson(PersonWrapper pw){
Person p = GetPersonByID(pw.PersonID);
p.Name = pw.Name;
p.Save();
foreach(PersonAddressWrapper paw in pw.Addresses){
PersonAddress pa = GetPersonAddressByID(paw.PersonAddressID);
Copy(pa,paw);
pa.Save();
}
}
, , - / , .
, , , .