Okay, I just created three projects, a class library that houses my EntitySpaces Employees object (based on SQL Server's Northwind) and the WebService and Client which share the class library. Here is my web service, note that I'm using ES2008 and used SelectAllExcept() to avoid shipping the photo back and forth):
Code:
[WebMethod]
public int SaveEmployees(string employees)
{
XmlSerializer sf = new XmlSerializer(typeof(EmployeesCollectionProxyStub));
StringReader sr = new StringReader(employees);
EmployeesCollectionProxyStub proxy = sf.Deserialize(sr) as EmployeesCollectionProxyStub;
EmployeesCollection emps = proxy.GetCollection();
if (emps.Count > 0)
{
emps.Save();
}
return emps.Count;
}
[WebMethod]
public string GetEmployees()
{
EmployeesCollection coll = new EmployeesCollection();
coll.Query.SelectAllExcept(coll.Query.Photo);
coll.Query.es.Top = 3;
coll.Query.Load();
// The Generated Proxy class
EmployeesCollectionProxyStub proxy = new EmployeesCollectionProxyStub(coll);
// Manually Serialize into string form (we want to deserialize it on the other side)
XmlSerializer sf = new XmlSerializer(typeof(EmployeesCollectionProxyStub));
StringWriter sw = new StringWriter();
sf.Serialize(sw, proxy);
return sw.ToString();
}
I added one method in the client that calls the GetEmployees() method and then adds two more Employees to the collection and calls Save, it worked just fine.
Code:
private void button1_Click(object sender, EventArgs e)
{
ESWebService.ServiceSoapClient req = new ESWebService.ServiceSoapClient();
string emps = req.GetEmployees();
XmlSerializer xs = new XmlSerializer(typeof(BusinessObjects.EmployeesCollectionProxyStub));
StringReader sr = new StringReader(emps);
// Deserialize into our Proxy
BusinessObjects.EmployeesCollectionProxyStub proxy =
xs.Deserialize(sr) as BusinessObjects.EmployeesCollectionProxyStub;
// Ask the proxy for the true Employees object
EmployeesCollection empColl = proxy.GetCollection();
Employees emp = empColl.AddNew();
emp.FirstName = "wsMike";
emp.LastName = "wsGriffin";
emp = empColl.AddNew();
emp.FirstName = "wsMike";
emp.LastName = "wsGriffin";
proxy = new BusinessObjects.EmployeesCollectionProxyStub(empColl, true);
XmlSerializer sf = new XmlSerializer(typeof(BusinessObjects.EmployeesCollectionProxyStub));
StringWriter sw = new StringWriter();
sf.Serialize(sw, proxy);
string packet = sw.ToString();
req.SaveEmployees(packet);
}
Maybe you can compare my code against yours. I did use ES2008 but I don't think that should matter. I had the first two checkboxes checked on the "Proxy / Stub" tab when I generated the classes.
EntitySpaces |
Twitter |
BLOG | Please honor our Software License