Create a WCF using existing code and replacing COM+ RRS feed

  • Question

  • So I've been asked to learn how to build services.  I've done some sample WCF Services and am starting to understand it a bit more but still feel a little lost.  I have to take a process that currently gets kicked off using COM+ (which I have no experience in) in a .NET website and have it be kicked off using WCF instead.  

    So the sub below is the report code that is already existing and basically does what is commented below:

    Public Sub CreateReport(Byval parameterName as String) 
       'Code here pulls data
       'code here creates an Excel file
       'code here sends an email to the user saying their file is ready for pick up
    End Sub

    Which I have now made into an interface and class like this:

    Public Interface ICreateReportService
        <OperationContract()> _
        Sub CreateReport(ByVal parameter As String)
    End Interface
    Public Class CreateReportService
        Implements ICreateReportService
        Public Sub CreateReport(parameter as String) Implements ICreateReportService.CreateReport
        'code to pull data
        'code to generate Excel file
        'Code to email user to say file is ready for pickup!
        End Sub
    End Class

    For my service project I have this:

    Imports System.ComponentModel
    Imports System.ServiceModel
    Imports System.ServiceProcess
    Imports System.Configuration
    Imports System.Configuration.Install
    Public Class Service1
        Public Class OurWindowsService
            Inherits ServiceBase
            Public serviceHost As ServiceHost = Nothing
            Public Sub New()
                ServiceName = "ReportService"
            End Sub
            Public Shared Sub Main()
                ServiceBase.Run(New OurWindowsService())
            End Sub
            Protected Overrides Sub OnStart(args() As String)
                If serviceHost IsNot Nothing Then
                End If
                serviceHost = New ServiceHost(GetType(REPORTPROJECT.CreateReportService))
            End Sub
            Protected Overrides Sub OnStop()
                If serviceHost IsNot Nothing Then
                    serviceHost = Nothing
                End If
            End Sub
        End Class
    End Class

    1.  Am I on the right track here?  We don't have any implemented WCF services in our code so this is all new to us and the example projects have given me a better idea of what WCF is, but I'm not sure if I'm on the right track so far.  Do I add a new windows service project into the solution that houses the report application?  Or where would the service code go?  Right now Service1 is a new windows service project inside the same solution as the report project.  I know I have to add a service reference to the website code, I just didn't know if there was an accepted idea of where the service project should be.

    2.  Right now our COM+ call in the website code looks like this:

            Dim o As Object = Marshal.BindToMoniker("queue:/new:REPORTPROJECT.CreateReport")

    How do I execute the new service from the website layer?  I saw where someone said to create an object for the ServiceController and then use the ServiceController.ExecuteCustomCommand but how does that link up with the create report?  ExecuteCustomCommand only accepts integers and our report call expects a string. 


    Wednesday, April 6, 2016 12:46 PM


  • Resolved using this reference:

    • Marked as answer by Azraeana Thursday, April 7, 2016 4:12 PM
    Thursday, April 7, 2016 4:12 PM

All replies

  • Update: 

    So a coworker thinks that the create report code should should be in a WCF library, which I have done.  Then he said we can use a windows service to connect to the WCF.  But I still don't know how to pass information to the WCF Library in the format of a string since the windows service only accepts an integer.  

    Basically it's this:

    Website  -------   Windows Service   ---------   WCF Library with Create Report in it

    I just don't know how to connect them or what should be in the windows service.  

    Thursday, April 7, 2016 1:10 PM
  • Resolved using this reference:

    • Marked as answer by Azraeana Thursday, April 7, 2016 4:12 PM
    Thursday, April 7, 2016 4:12 PM
  • WCF is about communications. It provides a means for the client and service to communication with each other using protocols, such a TCP/IP, HTTP, Named Pipe, MSMQ and even Com+.


    SOA or Service oriented architecture is an architecture style for building business applications by means of services. Application comprises collection of services which communicate through messages.


     Creating a report via WCF is kind of questionable, because the normal usage of WCF is send messages between the WCF service and client, like data for CRUD operations with a DB where the WCF service has reference to a DAL, as an example.

    You can look at WCF is a communications pass-through mechanism allowing the WCF client and service to pass messages between them.

    The report should be created on the client side code,  and WCF should have nothing to do it, IMHO.

    Thursday, April 7, 2016 4:19 PM