How do you provide a type defined in a web service to another web service (share types)?

I have 2 WCF services. Service A contains a definition of type MyEntity. Service B contains a service link to service A and therefore can use a type for MyEntity. So I have a method that looks like this:

protected void Update (ServiceA.MyEntity entity)
{
    //Do stuff
}

Now I want to use this method in service A, so I added a service reference for service B and tried:

protected UpdateServiceB(MyEntity entity)
{
    using(ServiceB.ServiceClient client =  new ServiceB.ServiceClient())
    {
        client.Update(entity);
    }
}

This did not work and complained that the types did not match, although Service B uses the type defined in Service A. How can I solve this?

UPDATE

I avoided the issue due to time limitations and instead passed the MyEntity guide from service A to service B. Then I used the existing “GetMyEntity (Guid entityId)” method in service A to retrieve the object in service B:

protected void Update (Guid entityId)
{
    MyEntity entity = new MyEntity();        

    using (ServiceAClient client = new ServiceAClient())
    {
        entity = client.GetMyEntity(entityId);
    }

    //Do stuff
}
+4
1

, Visual Studio . , , -:

  • , ( ).

  • , , , - 1. - .

.

:

  • A.Contracts.dll - A
  • B.Contracts.dll - B
  • Common.Contracts.dll. A B , . ( )
  • A.Service.dll - .
  • B.Serivce.dll - B
  • ClientProxies.dll - - .

. , , - ClientProxies.dll, , .

+3

All Articles