Consuming a WCF service with a window service
Now can someone please help me, I have created a window service that consumes a WCF service. The service onStart creates a timer object that instantiates a handler to a method that periodically polls the WCF service. I am asking someone to give me some guidance as to how to consume the WCF service. The company I am working with has adviced me to process blocks of records, and then close and reopen the service, yet I have read that the WCF should be opened onStart and closed onStop. The WCF service is uploading and downloading approximately 100kb of data per record processed. Could someone also offer some advice as to the Service.model config parameters. I am using .NET Framework 3.5. Regards,
Martin
UPDATE: There has been lots of viewings, but little response, however I would like to share somethings I have learnt. First, try using largest values in you app.config for the parameters for the WCF model, don't spend time opening and closing WCF references as this takes a finite time to perform.
job lotPosted Jul 15, 2009, 3:32 AM
Martin DoddPosted Jul 6, 2009, 3:22 AM
Private tmrParse As New System.Timers.Timer(PollTimeMilliSecs)
' change PollTimeMilliSecs to the amount of seconds the timer is set for * 1000
Ie. 5 secs is 5000 millisecs
Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start and initialise your service. This method should set things
' in motion so your service can do its work.
' this adds the handler for the tick event of the newly created timer.
End Sub
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
End Sub
Private Sub tmrParse_Tick(ByVal pSender As Object, ByVal pArgs As System.Timers.ElapsedEventArgs)
'In this section create a preoxy to your service reference, and make calls to your database.
' put your code here and it will be run each time the timer event fires
End Sub
tmrParse.enabled = true
Hope this helps. Regards,
Martin
job lotPosted Jul 2, 2009, 7:40 PM
Hi Martin
I have a similar requirement as your:
I am using a third partyAPI to send messages to customers from a .net win app. Apparently the app has to be running (as it subscribes to API event) to receive delivery confirmation.
The message, mobile# along with date_sent is saved in a db table which gets updated when delivery confirmation is received.
I want to know how I can warp sms functionality as windows service so that it could run in background and is independent of the actual application.
I am new to windows service and would appreciate your help. I am confused how I would make the service recursively poll the database for new records and update when delivery confirmation is received. Would the service be persistently connected to the database?
Could you please assist me with how to create a windows service and wrap it WCF framework I would appreciate if you could send me some code.
Thanks
Martin DoddPosted Jun 29, 2009, 4:23 AM