The Problem Solver

Tell me and I will forget
Show me and I will remember
Involve me and I will understand
- Confucius -

Google Ads

This Blog

Syndication

Search

Tags

News





  • View Maurice De Beijer's profile on LinkedIn

Community

Email Notifications

Explore

Archives

Hosting a web service with WSE
Web services are cool and really neat but they do suffer from one drawback and that is that the need Internet Information Server (IIS) as a host application.
 
Ok maybe it isn't that much of a drawback but would like to be able to host one without running IIS at least some of the time. Well the good news is that it isn't all that hard of you first install WSE 3.0. One of the features of WSE 3 is the ability to host web services in a service (or a console or similar application for that matter). The only requirement at runtime is that the WSE 3.0 runtime is installed on both the client and server machines.
 
To create a simple server:
  • First create a normal web service.
    This service is only used for development.
  • Next create a console application
  • Add references to:
    • Microsoft.Web.Services3
    • System.Web.Services
  • Copy the Service.vb from the web service to the console application
  • Add the following line to the HelloWorld function:
            Console.WriteLine("Request received")
  • Add the following code to the sub main:
            Dim Address As New Uri("soap.tcp://localhost/Service")
            Dim endPoint As New EndpointReference(Address)
            SoapReceivers.Add(endPoint, GetType(Service))
                Console.ReadKey()
 
Next we need to create a client application.
  • Create a second console application.
  • Add references to:
    • Microsoft.Web.Services3
    • System.Web.Services
  • Add a reference to the real web service created while developing the service.
  • Add the following code to the sub main:
                Dim ws As New localhost.ServiceWse
                ws.Url = "soap.tcp://localhost/Service"
 
                Console.WriteLine("Press escape to stop.")
                While Console.ReadKey(True).Key <> ConsoleKey.Escape
                        Console.WriteLine(ws.HelloWorld())
                End While
 
                Console.ReadKey()
  • Run the server.
  • Run the client.
 
Note that we create an object of type localhost.ServiceWse not localhost.Service. This is because adding the WSE reference added some logic to the proxy generation process resulting in two proxy objects. Using the wrong proxy object results in a "The URI prefix is not recognized." NotSupportedException. In that case just change the proxy to the Wse variant. If you don’t have the localhost.ServiceWse proxy class you probably didn’t add the Microsoft.Web.Services3 reference before adding the web service. In that case just add the Microsoft.Web.Services3, right click on the localhost icon below the Web References node in de the Project Explorer and select Update Web Reference to regenerate the proxy object.
 
Good luck in exploring WSE 3.0
 

 
Maurice de Beijer
Published Wed, Mar 15 2006 10:40 by Maurice
Filed under:

Comments

# re: Hosting a web service with WSE@ Wednesday, March 15, 2006 2:28 PM

Nice, missed the ServiceWse proxy first time round :-(

by John

# re: Hosting a web service with WSE@ Tuesday, May 27, 2008 1:25 AM

this was very helpful thanks.

by rohit

# re: Hosting a web service with WSE@ Monday, June 01, 2009 10:23 AM

What does this line do?

Dim ws As New localhost.ServiceWse

You have a class called localhost?

Is there anyway to add a reference to a "web service" if it's not currently running?

I've created a webservice, which is in the same solution as the console "server" and the client. Is there no way to add a project reference to a web service?

by Benjamin Peikes