tags:

views:

47

answers:

3

I am having an issue similar to this question: Problem with WCF and Multiple Namespaces

The major difference I am having is that I don't control both ends of the wire. My setup is similar to this:

My.Objects My.LoginService My.Service1 My.Service2

The first thing you do is login via the login service and receive a security ticket. The ticket object is located in the My.Objects namespace. For each subsequent call in My.Service1 and My.Service2 you have to pass in the security ticket to authenticate the call. The issue I am having is that instead of the client (a .net one for now but Java and others in the future) seeing one My.Objects.Ticket the references are resolving as My.LoginService.Ticket, My.Service1.Ticket, and My.Service2.Ticket. When the client tries to pass the object retrieved during login to any other function it is receiving an object mismatch error.

How can I make each service resolve objects to the My.Objects namespace?

A: 

Have a look at the NetDataContractSerializer, might be what you're looking for. It's different from the DataContractSerializer in that it includes the CLR type information in the serialized XML which allows you to share your type but forces both ends of the wire to use the same type.

Have a look at a blog post I put together and an attribute (from another blog I stumbled across) to inject it on operations that needs to use it:

http://theburningmonk.com/2010/08/wcf-using-the-netdatacontractserializer-to-share-your-type/

theburningmonk
I just added everything to the same Service with seperate endpoints and this fixed my issue. Investigating your solution it appears that it would have worked but you need to have control of both ends which I don't.
bechbd
A: 

Create an assembly referencing one of the services with a ticket type and then reference this assembly from your main project.

Konstantin Oznobihin
A: 

There is an easy way to share types between client and service, just by adding reference to shared type assembly to your client BEFORE adding the service reference.

You can find the detailed scenario and sample project there:

http://blog.walteralmeida.com/2010/08/wcf-tips-and-tricks-share-types-between-server-and-client.html

Walter Almeida