Jim Peterson

Jim Peterson

  • NA
  • 114
  • 38.8k

Standalone Webservice Namespace

Jan 1 2006 8:58 PM

A current project that I am working on, is a namespace called SWN, or standalone webservice namespcae.

The general Idea is to write a namespace to aid developers in writing stand-alone Servers, that function as web servvices. The namespace will also provide methods for "consuming" these mock-webservices.

The advantage of a standalone TCP/IP mock-Web service is that they are:

1. Very, very, portable
2. Easily Deployed
3. Free to deploy and use (no hosting fee)
4. No required knowledge of ASP.NET or Winforms, only the C# language.

Here is an example Webservice, and a client that consumes it:

Webservice:



using System;
using SWN; // My namespace

class WebService {
       SWN.WService mySWNservice = new SWN.WService();

       private static void main() {
           SWN.InitializeService(mySWNservice,"192.168.1.123",9999);
       }

       [SWNmethod]
       public string helloWorld() {
          return "Hello, World!";
       }

}


Here's the consuming client:

using System;
using SWN;

class myClient {
       private static void main() {
          Console.WriteLine("Welcome to the example Client");
          SWN.WServiceC SWNservice1 = new SWN.WServiceC();
          
          SWNservice1.IP = "192.168.1.123"; \\ the IP of the Web Service
          SWNservice1.PortNumber = 9999;
          SWNservice1.Connect();
          //We are now connected to our service

          Console.WriteLine(SWNService1.RunMethod("helloWorld"));
          
       }
}

And thats it. This client would write "Hello, World!" to the screen.

I am posting this to get any thoughts, reactions, or suggestions in regard to this idea from the C# Corner community.

Thanks, feedback would be greatly appreciated!


Answers (1)