Call another WCF Data Service from WCF Data Service

Answered Call another WCF Data Service from WCF Data Service

  • Monday, August 20, 2012 11:21 AM
     
     

    I have this scenario:

    1- WCF Data Service #1 with a custom entity (no entity framework)

    2- WCF Data Service #2 with entities by entity framework.

    My client should call just the WCF Data Service #2 the expose more then functions with own entities  also function with entity from the WCF Data Service #1.

    In other words, I call a service operation on WCF Data Service #2 that return an entity on WCF Data Service #1, but unfortunally it fail.

    Any suggestion?

     

All Replies

  • Monday, August 20, 2012 12:18 PM
    Moderator
     
     Answered

    Hi,

    If you already have code and a failure, it helps to post it here so that we can suggest possible fixes.

    In any case, if you want the service #2 to expose (as a proxy) entities from #1, then this is currently not possible. Service using the EF provider can only expose entities which are defined in the EF model. This is currently a limitation of the EF provider.

    There are possible other approaches:

    A) Use a custom provider instead of EF provider. This is lot of work, and if the custom provider would be layered on top of EF, this is somewhat tricky to get to work correctly. On the other hand it would give you complete freedom in what entities you expose and how.

    B) Let the client access the service #1 directly. I don't know what the service operation on service #2 would do, but maybe it would be possible to not have that and let the client access the service #1 directly.

    C) Similar to the B... let the client access #1 directly and if you need to do some logic in the service operation on service #2, return just the ID of the entity instead of the entire entity. The client would then run the service operation and then query service #1 for the entity with the returned ID. You could even return the URL of the entity...

    Thanks,


    Vitek Karas [MSFT]