Solved

How to get WSDL from a web service that uses .NET Remoting

Posted on 2006-06-08
2
2,739 Views
Last Modified: 2008-03-03
I own a server application that provides an RPC API based on HTTP/XML. Essentially, it's a poorman's web service. The server accepts HTTP requests itself directly rather than using a webserver stack. Requests and responses use a simple, but proprietary, XML schema. Whenever new methods or parameters are added, I have to make changes in several places to define the methods, and do the custom serialization/deserialization. Furthermore, I have to update interface documentation by hand, hope that I can get it distributed to the various people who are maintaining clients, and then they have to update their custom serialization layers. All of this is a pain.

So I'm trying to convert the RPC layer to use a standardized web service protocol stack that can do modern things like automatically serialize the types to/from the wire protocol, generate client stubs automatically for many languages/platforms, and provide a standardized interface description using something like WSDL. Currently I'm trying to use .NET remoting with some success. I don't want to rely on ASP.NET because my app doesn't typically have access to IIS.

I'm new to this stuff, and I'm just doing simple toy things right now, but so far, I've written a server and client that basically do the job. They get their type information from a shared assembly which has the definitions (metadata) for the server-side objects.

Here's the server code (C#)
<code>
        public void StartServer()
        {
            HttpChannel chan = new HttpChannel(8085);
            ChannelServices.RegisterChannel(chan, false);
            RemotingConfiguration.RegisterWellKnownServiceType
            (typeof(MixedMode.CRemoteSimpleMath),
            "SimpleMath", WellKnownObjectMode.Singleton);                  
        }

    public class CRemoteSimpleMath : MarshalByRefObject, ISimpleMath
    {        
        public CRemoteSimpleMath()
        {
            Console.WriteLine("CRemoteSimpleMath created.");
        }

        public int Add(int x, int y)
        {
            return x+y;
        }
    }
</code>
And the client code (managed C++):
<code>
HttpChannel^ chan = gcnew HttpChannel();
ChannelServices::RegisterChannel(chan, false);
Type^ proxytype = CRemoteSimpleMath::typeid;
CRemoteSimpleMath^ obj =
    (CRemoteSimpleMath^)Activator::GetObject(proxytype,
    "Http://localhost:8085/SimpleMath");                    
Console::WriteLine(obj->Add(2, 3));    
</code>

But I'm concerned about non-.NET clients. I have users that will need to code on other platforms to a common spec. I understand that I need to keep the types simple and not use any .NET framework types in the API, but that's no problem for me. I just don't know how to return a WSDL file to a client. What's the right technique for this?

I saw somewhere that I could just append "?WSDL" to the url for the service, which sounds good, but doesn't seem to work. I get an exception (below) if I request it in my browser. I think 've verified that the server object is alive at the time - it's a Singleton object, and if I call it with my client, the call works fine and the debugger shows the constructor isn't being called again. Anyone know what's wrong?

System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Runtime.Remoting.MetadataServices.WsdlGenerator.RealSchemaType.Resolve(StringBuilder sb)
   at System.Runtime.Remoting.MetadataServices.WsdlGenerator.XMLNamespace.Resolve()
   at System.Runtime.Remoting.MetadataServices.WsdlGenerator.Resolve()
   at System.Runtime.Remoting.MetadataServices.WsdlGenerator.Generate()
   at System.Runtime.Remoting.MetadataServices.SUDSGenerator.Generate()
   at System.Runtime.Remoting.MetadataServices.MetaData.ConvertTypesToSchemaToStream(ServiceType[] serviceTypes, SdlType sdlType, Stream outputStream)
   at System.Runtime.Remoting.MetadataServices.SdlChannelSink.GenerateSdl(SdlType sdlType, IServerResponseChannelSinkStack sinkStack, ITransportHeaders requestHeaders, ITransportHeaders responseHeaders, Stream& outputStream)
   at System.Runtime.Remoting.MetadataServices.SdlChannelSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
   at System.Runtime.Remoting.Channels.Http.HttpServerTransportSink.ServiceRequest(Object state)
   at System.Runtime.Remoting.Channels.SocketHandler.ProcessRequestNow()

0
Comment
Question by:solublefish
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
MySt1k earned 500 total points
ID: 16867384
you could give a try to the wsdl.exe command line utility.
ex.: wsdl http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL

i also found this post where the guy says it is caused by the wsdl generator to fail to determine the namespace to be used.
presumably because it was trying to determine it from the interface.

http://c.oloss.us/articles/tag/framework
0
 
LVL 3

Author Comment

by:solublefish
ID: 16882634
Thanks. I was hoping to do this without the WSDL.exe or SOAPSUDS.exe tools, since my client developers may not have those tools. But the articly you linked to looks promising. It looks like he's done basically what I want to do - implement a .NET web service without ASP.NET that's easily callable by non-.NET clients.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A short article about problems I had with the new location API and permissions in Marshmallow
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question