Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / September 2004

Tip: Looking for answers? Try searching our database.

Using WSE 2.0 in a Windows Service - looking for an example

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rob Hindman - 15 Sep 2004 22:55 GMT
I'm looking for an example of a simple Windows Service that uses WSE
2.0 (WSE 2.0 sp1).

Specifically, I would like to implement a Windows Service in C# as
follows:

  public class MyWindowsService : System.ServiceProcess.ServiceBase
  {
  ...
  }

I would like to use the soap:tcp protocol as well. All of the examples
that I have seen use HTTP in some form...

I would be very grateful if someone could point me to an example...
Thanks!! -Rob.
SA - 20 Sep 2004 18:26 GMT
Here's some code I use:

Protected Overrides Sub OnStart(ByVal args() As String)

Dim ServiceUri As Uri

' This is your Service (inherits from SoapService)

Dim Service As New GenericService

Try

ServiceUri = GetUri()

SoapReceivers.Add(New EndpointReference(ServiceUri), Service)

Catch ex As Exception

Tracing.Instance.Trace(Tracing.ts.TraceError, ex.Message)

' Throw the exception to stop the service from starting

Throw ex

End Try

End Sub

Protected Overrides Sub OnStop()

Dim ThisEPR As New EndpointReference(Me.GetUri())

Try

If (SoapReceivers.Contains(ThisEPR)) Then

SoapReceivers.Remove(ThisEPR)

Tracing.Instance.Trace(Tracing.ts.TraceVerbose, "Removed EndPointReference
from the SoapReceivers collection")

Else

Tracing.Instance.Trace(Tracing.ts.TraceVerbose, "EndPointReference not found
in the SoapReceivers collection.")

End If

Catch ex As Exception

Tracing.Instance.Trace(Tracing.ts.TraceError, ex.Message)

End Try

End Sub

Write your web service just as you normally would. WSE 2 is very powerful in
this way: you can use the same client and the same service for SOAP over TCP
and HTTP.

HTH,

Signature

Sven

> I'm looking for an example of a simple Windows Service that uses WSE
> 2.0 (WSE 2.0 sp1).
[quoted text clipped - 12 lines]
> I would be very grateful if someone could point me to an example...
> Thanks!! -Rob.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.