Share via


Getting a NullReference Exception Generating WSDL for your Remoted Object?

Maybe you didn’t know, but you can generate a WSDL document for your remote object fairly easily. You can generate the contract XML directly or you can use soapsuds.exe to generate a proxy dll that you can share with your consumers. All you have to do is make a request to your remote object URI and append ?WSDL and you’re done.

So let’s say I was hosing a remote object called RemOBj on my local machine on port 8081 and I specified it’s URI as RemOBJ.rem. To activate this object I’d make remote requests to: https://localhost:8081/RemoOBJ.rem. If I wanted to get the WSDL for this I’d request https://localhost:8081/RemoOBJ.rem?wsdl. You can make this request in IE for your remote object to see the output.

There are some cases however where this will fail and in IE you’ll see the following information:

System.NullReferenceException: Object reference not set to an instance of an object. at System.Runtime.Remoting.MetadataServices.RealSchemaType.Resolve(StringBuilder sb) at System.Runtime.Remoting.MetadataServices.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()

If you tried to create a proxy with soapsuds you’d see this exeception:

Error: Unable to retrieve schema from url: https://localhost:8081/RemOBJ.rem?wsdl, The remote server returned an error: (500) Internal Server Error.

If you are seeing either of these and your remote object implementation and remote object interface are defined in separate assemblies you can try one of the following:

1. Place the interface definition and implementation in the same assembly.

2. Ensure that the interface and implementation are rooted in different namespaces.

Comments

  • Anonymous
    January 10, 2005
    duh... didn't everyone know that?