10.3. Using Web Services from .NET Remoting

To get the best of both worlds—that is, cross-platform compatibility and performance—you can access web services from .NET remoting. Imagine a scenario in which a service is not only provided to the world at large, but internally—within the company providing it. There is no reason why the internal clients should suffer from potential performance problems and implementation limitations because the objects they need are web services.

Achieving this compatibility takes little effort. Just add an additional attribute to the web method to let it know that RPC-encoding is needed. The attribute is called SoapRpcMethodAttribute, and it is applied like this:

<SoapRpcMethod( ), _
 WebService(Namespace:="http://www.mydomainhere.com/")> _
Public Class ZipService : Inherits MarshalByRefObject

Additionally, the class needs to derive from MarshalByRefObject. If not, SoapSuds generates the wrong type of proxy.

10.3.1. Configuration

A Web.config file must be provided for the web service (placed into the ZipService virtual directory) to register any channels that might be needed and to define well-known object entries. In Example 10-4, a TCP channel is configured to listen on port 1969 and a Singleton that is accessible at ZipService.soap is specified for ZipService.

Example 10-4. Web.config for ZipService
<configuration> <system.runtime.remoting> <application> <channels> <channel ref="tcp" port="1969" /> </channels> <service> <wellknown mode="Singleton" ...

Get Object-Oriented Programming with Visual Basic .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.