This is a migrated thread and some comments may be shown as answers.

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

3 Answers 72 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tom
Top achievements
Rank 1
Tom asked on 22 Jan 2013, 03:02 PM

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: http://www.telerik.com/help/openaccess-orm/developer-guide-wcfservices-plain-service-update-service.html

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. 

3 Answers, 1 is accepted

Sort by
0
Accepted
Hristo Marinov
Telerik team
answered on 24 Jan 2013, 08:59 AM
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.
 

Greetings,
Hristo Marinov
the Telerik team
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
0
Tom
Top achievements
Rank 1
answered on 24 Jan 2013, 01:38 PM

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.

 

0
Damyan Bogoev
Telerik team
answered on 28 Jan 2013, 04:50 PM
Hello Tom,

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


<system.serviceModel>
    <services>
      <service
          name="YourServiceFullName"
          behaviorConfiguration="YourServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress=YourServiceBaseAddress"/>
          </baseAddresses>
        </host>
        <endpoint address=""
                  binding="webHttpBinding"
                  contract="NewInterfaceFullName" />
 
      </service>
    </services>
    ...
</system.serviceModel>

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.
Tags
Development (API, general questions)
Asked by
Tom
Top achievements
Rank 1
Answers by
Hristo Marinov
Telerik team
Tom
Top achievements
Rank 1
Damyan Bogoev
Telerik team
Share this question
or