Creating Translator for Enum Type Not Possible

Topics: Service Factory Modeling Edition Forum
Dec 20, 2007 at 10:23 AM

I have a service contract where I pass one parameter (ServiceNameRequestData) to a web service. The parameter has a DataContract which contains a DataContractEnum field called PhoneType (and holds 3 values), It also contains two other primitives.
Summarised: ServiceContract -> GetContactDetail -> Request(ContactDetailRequestData)

  • Name (string)
  • CompanyName (string)
  • PhoneType (DataContractEnum)

DataContractEnum: PhoneType:
  • Mobile
  • Home
  • Office

I also have a set of BusinessEntities which represents the DataContractTypes:
BusinessEntities.PhoneType (which is an enum with the same values)
BusinessEntities.ContactDetail.ContactDetailRequest which is a class that holds the following:
  • Name (string)
  • CompanyName (string)
  • PhoneType (Businessentities.PhoneType)

When I try to generate a Translator (by right clicking the serviceImplementation project and selecting "Create Translator") I'm unable to map all data.
I choose to make a mapping between BusinessEntities.ContactDetail.ContactDetailRequest and DataContracts. ContactDetailRequestData
Mapping the primitives gives me no problems, but mapping the PhoneType enumeration gives me the following error:
"Cannot perform mapping between PhoneType(PhoneType) and PhoneType(PhoneType). Possible reasons are incompatible types or unavailable getter/setter pairs."

What am I doing wrong? How do I solve this issue?

Awaiting your replies,
Dec 20, 2007 at 10:53 AM
The following is untested, but what I did to set up the translation is mapping the primitives, drag and drop the generated file out of the generated folder and then added following lines (in their respective methods)

to.PhoneType= (BusinessEntities.PhoneType)from.PhoneType;

to.PhoneType= (DataContracts.PhoneType)from.PhoneType;

I haven't tested it with a client yet. I'll keep you updated in any case. Still if there are other practices/solutions, don't hesitate to post them

Kind regards,
Dec 20, 2007 at 10:54 AM
Edited Dec 20, 2007 at 10:54 AM
Admin please delete the double post(s)
Dec 20, 2007 at 6:48 PM
The WSSF V3, for the moment, doesn't support Enum translators.

The workaround is to perform the translation by hand as you mentioned in your last post.


Jan 8, 2008 at 12:53 PM
yeah, I found that out, I did make a nicer implementation using a switch. I can't recommend the direct casting to anyone, it's bad coding