CodeSmith Community
Your Code. Your Way. Faster!

WCF integration with .netTiers

Latest post 05-20-2008 11:06 PM by SuperJeffe. 26 replies.
  • 01-23-2007 3:55 AM

    • Lex
    • Top 50 Contributor
    • Joined on 09-28-2006
    • Posts 72
    • Points 1,945

    WCF integration with .netTiers

    Hi,

    Here is the final version of my WCF integration. Attached :

    - The patch for the latest SVN release
    - A short documentation

    Please give me your comments.

    Next steps:
    - Better exception handling
    - Use host factories
    - Server as Windows Service
    - Debugging :-)

    I hope this thread will be more successful as the previous one !

    -------------------------------------------------------------------------------------------

    1         WCF Server

    The WCF server is supposed to be hosted in IIS. It is composed of *.svc files that enable to expose the “Service” layer of .netTiers to WCF and a Web.config file that enables to configure the service.

     

    The configuration files are samples and are meant to be customized, but they work “out-of-the-box” for a simple un-secure WCF integration.

     

    <service name="NameSpace.Services.ItemService" behaviorConfiguration="MyServiceTypeBehaviors">

            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BindingConf" contract=" NameSpace.Services.IItemService" />

          </service>

     

    In order to retrieve large objects from WCF, the following had to be activated:

     

    <basicHttpBinding>

    <binding name="BindingConf" maxReceivedMessageSize="67108864" />      </basicHttpBinding>

     

    The endpoints need interfaces to expose the services. As a consequence, .netTiers templates for the Service (eg: Component) layer are customized to add the proper interfaces on generation.

     

    If you want to expose a new method, then you must declare it in the interface, with a unique name. Sample:

     

    [OperationContract(Name="HelloWorld")]

    string HelloWorld();

    2         WCF Client

    The WCF client is composed of:

    -          Sample configuration files (App/Web.config and entlib.config)

    -          A proxy factory

     

    The proxy factory enables to connect either using WCF of directly to the database, by changing the parameter communicationPlatform in the *.config file. When using Direct mode, the classic .netTiers configuration must be added.

    3         Testing

    1. Run NetTiers templates and activate WCF library generation.
    2. Open generate solution in Visual Studio.
    3. Compile and check for errors (hopefully none).
    4. Server
      1. Create a new virtual host in IIS
      2. Point the directory to the Namespace.WCF/ folder
      3. Activate ASP.NET 2.0 (does not work with 1.1)
      4. Go to the URL of a service and check the wsdl is valid.
    5. Client
      1. Create a new Console Application project
      2. Copy Web.App.sample.config from the WCFClient project and name it App.config
      3. Copy entlib.sample.config from the WCFClient project and name it entlib.config. Check “copy always” in the file properties
      4. Add references to the .netTiers projects and to the EntLib dlls.
      5. Add some simple code to check your WCF service is working. Sample:

     

    try

                {

                    NameSpace.Services.IItemService service = NameSpace.WCFClient.ProxyFactory.ItemServiceProxyInstance();

                    foreach (NameSpace.Entities.Item Item in service.GetAll())

                    {

                        Console.WriteLine(Item.ToString());

                    }

                }

                catch (Exception ex)

                {

                    Console.WriteLine(ex.ToString());

                }

                Console.ReadLine();

     

    Filed under:
    • Post Points: 150
  • 01-23-2007 7:48 AM In reply to

    • Lampous
    • Not Ranked
    • Joined on 12-08-2006
    • Posts 7
    • Points 275

    Re: WCF integration with .netTiers

    Great work!  I have been watching the WCF stuff develop on here recently.  Unfortunately I don't have much time to contribute...  :-(

    There are 3 files that will not patch; each is listed twice in the patch: (I think they haven't been committed??)

    1. WCFProxyFactory.cst
    2. WCFEntityService.cst
    3. WCFWeb.config.cst


     

    • Post Points: 35
  • 01-23-2007 9:04 AM In reply to

    • Lex
    • Top 50 Contributor
    • Joined on 09-28-2006
    • Posts 72
    • Points 1,945

    Re: WCF integration with .netTiers

    Hi,

    Can you please try the new file of the 1st post ?

    • Post Points: 35
  • 01-23-2007 9:55 AM In reply to

    • Lampous
    • Not Ranked
    • Joined on 12-08-2006
    • Posts 7
    • Points 275

    Re: WCF integration with .netTiers

    That fixed it, I just copied the WCF folder into where my repository resides, and then ran the patch.

    Any plans in the future to implement the WS-AT on the services?

    Again, Great work!  Thank you very much.  

    • Post Points: 35
  • 01-23-2007 10:23 AM In reply to

    • Lex
    • Top 50 Contributor
    • Joined on 09-28-2006
    • Posts 72
    • Points 1,945

    Re: WCF integration with .netTiers

    Hi,

    I guess it should support it out-of-the-box (though untested) by customizing the bindings in the configuration file. So far my default configuration files are very simple, but I could enhance them if there are standard practices on this.

    • Post Points: 5
  • 01-23-2007 10:28 AM In reply to

    Re: WCF integration with .netTiers

    I had applied the first patch to my local version, but haven't had a chance to check it in.  VCIF and I are working on almost done with n-level undo support, and my local version is in flux.  So, do this patch completely replace the first one?  Or is it a secondary patch?  if the former, I wonder if there's a way to rollback a patch.

    Robert Hinojosa
    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams
    http://www.nettiers.com
    -------------------------------------
    • Post Points: 35
  • 01-23-2007 10:49 AM In reply to

    • Lex
    • Top 50 Contributor
    • Joined on 09-28-2006
    • Posts 72
    • Points 1,945

    Re: WCF integration with .netTiers

    It is a replacement of the previous patch. Hopefully, it will merge successfully with the previous one on your local version ...

    I think there is no way to revert a patch wth TortoiseSVN, if you have not committed the changes to the SVN server.

    • Post Points: 5
  • 01-23-2007 12:57 PM In reply to

    Re: WCF integration with .netTiers

    Hi: I have just taken a look at the files in the patch and found the following in "WCFProxyFactory.cst"

     #region <%=serviceClass%>
            /// <summary>
            /// <%=serviceClass%> Channel Factory
            /// </summary>
            static ChannelFactory<<%=NameSpace%>.I<%=serviceClass%>> factory<%=serviceClass%> = null;

    should this be the following:

     #region <%=serviceClass%>
            /// <summary>
            /// <%=serviceClass%> Channel Factory
            /// </summary>
            static ChannelFactory< <%=NameSpace%>.I<%=serviceClass%> > factory<%=serviceClass%> = null;

    with the extra " <" space inserted into "ChannelFactory<<%=NameSpace%>." or is it a problem with the syntax highlighter in Codesmith?

    I am behind a firewall that makes the Great wall of China look like a 2 inch high cardboard picket fence, so cannot get to the SVN to get the latest version here... is there another way to get the reference netiers version to run the included patch file on? Geeked 

    • Post Points: 35
  • 01-24-2007 8:40 AM In reply to

    • Lex
    • Top 50 Contributor
    • Joined on 09-28-2006
    • Posts 72
    • Points 1,945

    Re: WCF integration with .netTiers

    Hi,

    No extra space is required, it's a problem with the syntax highlighter in Codesmith.

    However, I found other bugs, I'll submit a new patch later when the first one is committed to SVN. Especially, DeepLoad() is not working because System.Type is not serializable ! So I need to find a workaround.

    • Post Points: 5
  • 01-24-2007 12:57 PM In reply to

    • Lex
    • Top 50 Contributor
    • Joined on 09-28-2006
    • Posts 72
    • Points 1,945

    Re: WCF integration with .netTiers

    Apart from the DeepLoad() issue, there seem to be some serious serialization problems on Entities properties.

    Robert,
    I really need your help on this : why are sometimes some fields not serialized ?

    • Post Points: 35
  • 01-29-2007 3:03 PM In reply to

    • needbrew
    • Top 150 Contributor
    • Joined on 03-20-2006
    • Posts 38
    • Points 1,180

    Re: WCF integration with .netTiers

    Hi All,

     I am not able to patch my existing source.  I have the latest from SVN but the patch does not apply correctly.  Any assistance appreciated.

     Thanks

    Mike

    Filed under:
    • Post Points: 35
  • 01-30-2007 10:37 AM In reply to

    Re: WCF integration with .netTiers

    Mike: Having the same problem, I got most of the code to change in the branch, but still could not generate anything I am using the 468 version from the SVN. I copied the WCF to the branch directory, and tried patching a new download from the SVN with the zip file included above... still the same problem?

     Mal.  Indifferent

    • Post Points: 35
  • 01-30-2007 3:41 PM In reply to

    • needbrew
    • Top 150 Contributor
    • Joined on 03-20-2006
    • Posts 38
    • Points 1,180

    Re: WCF integration with .netTiers

    Anyone have any luck.  I get the following error when trying to apply the patch

     

    "The patch seems outdated! the file line  <%-- 9.0 windows form Library -- %>

    and the patch line

    %@property Name="Grant User" Type="System.String" Category="08. Stored Procedures - Advanced" descriptio="Optional user or role to GRANT EXEC procedure permisision to....%

    do not match

    • Post Points: 35
  • 02-07-2007 2:56 AM In reply to

    • Lex
    • Top 50 Contributor
    • Joined on 09-28-2006
    • Posts 72
    • Points 1,945

    Re: WCF integration with .netTiers

    Hi,

     Sorry guys for that late answer, apparently email notification doesn't work !

    Please see the first post for the real files download (not a patch). For it to work, you have to copy these files onto the .netTiers v2.1.0.473 sources.

    • Post Points: 35
  • 02-08-2007 10:55 AM In reply to

    Re: WCF integration with .netTiers

    Where can one get the v2.1.0.473 sources?  The template does not compile for me with the latest SVN source.

     
    Thanks,

    Ben 

    • Post Points: 5
Page 1 of 2 (27 items) 1 2 Next > | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems