Modifying WSSF to reference Business Module generated by WCSF

Topics: General Discussion Forum, Service Factory Modeling Edition Forum
May 29, 2009 at 12:48 AM

Hi,

I am looking to modify the WSSF to meet some requirements.  My goal is to externalize a business service within a business module generated by the WCSF.  I want to generate a WCF service using WSSF that will reference that business service.  The way I am thinking of doing this is when the developer adds a service in the serivceDSL there should be a way for them to specify which business service to reference, maybe a new Domain Property. Then when the code gets generated, a reference to the project where the business service resides will be added to the WCF service implementation project and then there will be some code automatically put into the WCF service implmentation to instantiate and call the business service.  I know we can add the code into the text template for the WCF service implementation but I am not really sure how to have the developer select the business service type and then add the reference to the WCF service implementation project.  Does anyone know of a good way to do this or point me in the right direction?  I tried looking at the hands on lab for extending WSSF but it didnt help me out with this problem that much.  Any other examples out there that does something similar to this?

Thanks,

Matt

Developer
May 29, 2009 at 9:29 PM

Hi Matt,

If I got it right, you have a kind of service composition scenario where service A invokes service B, do something with result of service B and returns a result from service A.

In that case, I would rather separate both models so you may simply use service A implementation project as client B (serivce B consumer) and move the app.config file generated in your implementation project to your host config file.

That way you can keep both contracts and implementation separate and you don;t need to update WSSF. Notice that the central idea behind WSSF is for designing the servicecontract and datacontract for a specific service implementation and the close the scenario with a host and client as the service consumer.

Regards,

Hernan

May 29, 2009 at 10:15 PM

Hi Hernan, Thanks for your response.

Thats not exactly what I am trying to do.  When I said business service I didnt mean a web service, rather an internal class of a web application. 

So my scenario is that a developer will generate a web application using the WCSF and then generate a business module using the WCSF for the web app.  The business module will contain a class that does some functionality for the web application which also may be useful for third party applications.  So I want to make that business class available for external applications.  I wanted to have the WSSF automatically generate a WCF service that consumes this business class to make it available to external apps.  Does that make sense? 

Thanks,

Matt

Developer
May 30, 2009 at 12:36 AM

Yes, makes perfect sense, so you can make this class a separate library (dll) and expose its functionality thorugh a WS "facade-like". That scenario may also define a DataContract if your BC require to publish some kind of public data for passing parameters to operations and also define a servicecontract where you may expose all or part of your BC functionality.

Jun 1, 2009 at 4:38 PM

So, I want to make the modification to the WSSF so that this process can be automated to make it easy for our developers.  Im still having trouble trying to figure out a way to allow the developer to select the class when generating the WCF service class from the DSL and then adding the appropriate reference to the Service Implementation project.   Do you know of a way to to this?

Thanks,

Matt

Developer
Jun 1, 2009 at 7:50 PM

Matt,

I just posted on a similar thread one way to accomplish this: http://servicefactory.codeplex.com/Thread/View.aspx?ThreadId=58018

Basically you may create your SC and DC decoupled from your external libraries and have a translator class in your service implementation project that maps your DC types to your external types and back.

Jun 2, 2009 at 4:50 PM

Thats not really what im looking for.  Do you know if there is a way to extend WSSF so that a project reference gets added to the ServiceImplementation project when the WCF Service class is generated from the service contract model?

Thanks,

Matt

Developer
Jun 2, 2009 at 7:07 PM

If you want to add a binary reference (.dll) you can do that by adding an "AssemblyReference" attribute to the artifact link that handle the code generation for your target project, in this case the "ServiceContractLink" class in the WCF extender library (Microsoft.Practices.ServiceFactory.Extenders.ServiceContract.Wcf). You may only update this class with the attrubute as in the following example and re build this project, copy del dll to the package folder and you're done.

[AssemblyReference("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public sealed class ServiceContractLink : ArtifactLink
{
}

On the other hand if you want to add a project reference to the service implementation project, you can update the PMT (Project Mapping Table) and add your project with some Role.

You have two options to update the project mapping table file.
1) Update the PMT (project mapping table) using the recipe "Populate Project Mapping Table" right cliking on the root solution folder of your services structure and that recipe will populate the PMT with all the projects within that node using a simple heuristic for roles based on project name prefixes.
2) Update the PMT by hand so you can add new project elements by getting the project GUID from each project file and settng the role with the intellisense provided by the PMT schema.