So, are you proposing an RPC style of web service or a Document / Message based style of web service? Both can be achieved with primitive types.
Arent classes that only use primitives just as interoperable as RPC style methods, except for the fact that the message contract is made clearer because of the message definition?
My personal style is to write methods like this:
[WebMethod]
public CustomerResponse FindCustomers(CustomerRequest request)
{
CustomerResponse myResponse = new CustomerResponse();
List<CustomerDto> myCustomers = new List<CustomerDto>();
CustomerCollection myCollection = MyBusinessObject.FetchCollection(request.FirstName,
request.LastName);
foreach(CustomerEntity entity in myCollection)
{
CustomerDto customerDto = new CustomerDto();
DataMapper.MapData(entity, customerDto);
myCustomers.Add(customerDto);
}
myResponse.Customers = myCustomers.ToArray();
return myResponse;
}
An alternative style would be use RPC
[WebMethod]
public string FindCustomers(string firstName, string lastName)
{
return MyBusinessObject.FetchCollection(firstName, lastName).ToXml();
}
Is my coding style along the lines of the more "preferred" approach to service implementation?