Search code examples
c#.netclient-serverremoting

How can I generate the WSDL file from a Remoting server?


I am a newbie in developing web services and client server applications, and I am having troubles in understanding how is the WSDL file generated from a c# web service. I need the WSDL file in order to generate a proxy class and reference it to the correspondent client.

class my_server
{
    private static HttpChannel channel;
    private static int port = 3000;
    private static string serverUri = "myservice";

    static void Main(string[] args)
    {

        Console.WriteLine("Sample server");
        StartSoapServer(port);
        Console.ReadLine();

        StopSoapServer();
    }
    private static bool Start(int p)
    {
        try
        {
            port = p;
            channel = new HttpChannel(port);
            ChannelServices.RegisterChannel(channel, false);
             RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(server), serverUri, WellKnownObjectMode.Singleton);
            IServerChannelSink sinkChain = channel.ChannelSinkChain;

            Console.WriteLine("server created");
        }
        catch (Exception e)
        {

            return false;
        }
        return true;
    }

    private static void Stop()
    {
        string[] urls = channel.GetUrlsForUri(serverUri);
        if (urls.Length > 0)
        {
            string objectUrl = urls[0];
            string objectUri;
            string channelUri = channel.Parse(objectUrl, out objectUri);
            ChannelServices.UnregisterChannel(channel);
            Console.WriteLine("Server stopped");
        }
    }

    public class server : MarshalByRefObject
    {
        public server()
        { 
        }

        public override object InitializeLifetimeService()
        {
            return null;
        }
        public bool initialise()
        {
            Console.WriteLine("initialise()");
            return true;
        }
        public bool ping()
        {
            Console.WriteLine("ping");
            return true;
        }   
    }
}

Apparently the server is created, and stays on until it is stopped...however when testing it with Storm(http://storm.codeplex.com/): by adding http://localhost:3000/myserviceuri it fails...how else can I check that the service works, without implementing a client? how can I generate the WSDL file from this server? I have tried to use http://wsdlgenerator.codeplex.com/ but apparently it is only for WCF services...


Solution

  • You can genarate a wsdl with the wsdl.exe for a .svc or .asmx services in .net as far as I am concerned. For remoting, this is what microsoft says "The Remoting object can provide a WSDL (see the Web Services Description Language (WSDL) 1.1) file that describes the object and its methods. Any client that can read and generate SOAP requests corresponding to the WSDL file can invoke this object and communicate to it using SOAP. .NET Remoting Server objects can use the SOAPSUDS.EXE tool, which ships with the .NET SDK, to generate WSDL files that can serve as metadata. This is useful when an organization wants to provide a public service that any client can access and use."