Interface generation in WCF Plain Services (VB.NET) SDK

4 posts, 1 answers
  1. Tom
    Tom avatar
    2 posts
    Member since:
    Mar 2006

    Posted 22 Jan 2013 Link to this post

    I am starting a new project and using OpenAccess ORM for the first time.  I began to explore the example in the SDK that matched my goal design - the WCF Plain Service (VB.NET). 

    Of particular interest to me is the generation of the business logic in the SofiaCarRentalService layer.  I understand the need to create partial classes to extend this layer and add custom domain logic.  However, I am trying to understand how / when the interfaces for these partial classes are generated (i.e. 'Add OpenAccess Service Wizard ...', modification of the auto-generated interface class, or customized T4 templates (?)).

    The reason it is unclear is that, in attempting to reproduce the steps to create the SofiaCarRentalService layer, I used the 'Add OpenAccess Service Wizard ...' to overwrite the existing service as described here:

    Once this completed however, an error appears: 'SaveRentalOrders' cannot implement 'SaveRentalOrders' because there is no matching sub on inteface 'ISofiaCarRentalEntityDiagramsService'.  I can't seem to move forward from here.

    I clearly must be missing a step, but I am at a loss from the product and sample documentation.  Any insight into how the sample was generated would be appreciated. 

  2. Answer
    Hristo Marinov
    Hristo Marinov avatar
    13 posts

    Posted 24 Jan 2013 Link to this post

    Hello Tom,

    The WCF Plain Services in the OpenAccess SDK are generated with the Add OpenAccess Service wizard using the default T4 templates. The definition of the method you mention - SaveRentalOrders is added manually in the generated interface.

    The reason for the exception is that when the interface is overridden, the implementation of the SaveRentalOrders method remains in a partial class which is not replaced during the code re-generation. A solution for this scenario is to add the definition of the SaveRentalOrders in the interface.

    In the C# version of the sample we use partial interfaces to add the custom business logic, but this scenario cannot be achieved in VB.NET because of the specifics of the language. 

    To separate the custom business logic from the generated code, you can create custom interfaces that inherit the auto-generated interfaces to extend the logic. In that way after "Updating" the service, no additional configuration will be needed and no information will be lost. But bear in mind that for this scenario the web.config file of the service project needs to be configured appropriately - let us know if you would like further details on that.

    Basically the scenario for which the Add OpenAccess Service wizard is used is to add services, and then since there is no automated code generation apart from the wizard itself, you are free to make changes and extend your service in any possible way. In case you would rather prefer an automated update logic, we will appreciate if you could specify a use case for this scenario and what are your expectations for the end result of the "Update" process, so that we can enter it into our backlog.

    I am looking forward to hearing from you.

    Hristo Marinov
    the Telerik team
    Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
  3. DevCraft banner
  4. Tom
    Tom avatar
    2 posts
    Member since:
    Mar 2006

    Posted 24 Jan 2013 Link to this post

    Thanks for the response.  Just so I am clear, I have several options from here.

    1. Switch to C# and use partial interfaces.  Everything I read about interfaces in VB.NET pointed me to partial interfaces in C#.
    2. Manually add the interfaces as you mentioned.  This was the only way I could get the existing example to work.  It makes sense and is not too painful.
    3. Inherit the interfaces with a setting in web.config.  I am in interested in this option.  If you could elaborate here this would be preferred.


    As for automation ideas, I had found a hidden file (ISofiaCarRentalService.vb) in WCF Plain Services (VB.NET) solution of the SDK which contained a reference to the SaveRentalOrders interface.  I am not sure if this was a hint file or an artifact.  But, perhaps a file like this could be called upon for the auto-generation of the VB.NET interfaces (and C# interfaces I presume) via the Add OpenAccess Wizard.  This would probably improve the automation results and require less attention from a development standpoint.


  5. Damyan Bogoev
    Damyan Bogoev avatar
    581 posts

    Posted 28 Jan 2013 Link to this post

    Hello Tom,

    In order to modify the endpoint contract you need to slightly modify the web.config file in following way:

                <add baseAddress=YourServiceBaseAddress"/>
            <endpoint address=""
                      contract="NewInterfaceFullName" />

    The auto-generated ISofiaCarRentalService.vb is a proxy for the WCF plain service. You need to update the service reference and it will be re-generated.

    Hope that helps.

    All the best,
    Damyan Bogoev
    the Telerik team
    Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
Back to Top