Conceptual Question about Translators

Topics: General Discussion Forum
Sep 27, 2007 at 6:25 PM
Good afternoon,

I apologize in advance if I am posting in the incorrect forum or improper venue. My question is a conceptual one related to contract-to/from-business entity translators generated from the WCF web service software factory. I really need a business entity returned from a web service service call, or at least the ability to translate a data contract in the response message object into a business entity after the client receives it. How can I leverage the translator code to do this? It seems since that since there isn't a reference to the BusinessEntities project in the ServiceContract project, it would be a big faux-pas to do the reference and return the business entity in the message contract. But how does one usually translate from a contract to business entity (and vice versa) when on the client? For instance, this is what i would like to do:

Code on the client:

SomeService.ISomeService service = new SomeService.SomeServiceClient();
SomeService.GetSomeDataRequest request = new SomeService.GetSomeDataRequest();
request.ID = 1234;
SomeService.GetSomeDataResponse response = service.GetSomeData(request);

Okay so now I have a response object (message contract) with a data contract in it (response.SomeData) on the client. I would like to have this translated into a business entity so I can use in my client this:

Customer myCustomer = TranslateFromDataContractToCustomer(response.SomeData);

Consequently, when updating, it would be nice to have a translator from my customer object to the request.SomeData contract.

But all of the translation generators only seem to happen in the service layer.

Assumptions I have:
- It's wrong to receive business entities in request message contracts and also incorrect to return business entities in response message contracts.

Thanks for the help. If I am totally off the mark or posting in the totally wrong forum, guidance on a particular forum I could better post in would be greatly appreciated. Thanks.
Oct 4, 2007 at 3:05 PM
Why do you need the business entity in the client? The properties you need in your client should be available to you in your data type class. Just so I understand your example, your response is a message type and SomeData (response.SomeData) is a DataType, correct? So, in your service, you should have translated your SomeData business entity to that SomeData DataType (and then stuffed that SomeData DataType into the response and returned it).