Remoting or Web Services, How Do I Decide?

Consulting is at times enlightening and at other times torturous. It is enlightening when I meet smart people and get to work on a diverse and interesting range of problems. It is torture when my participation comes long after painful decisions have already been made or sound advice has been ignored because of groupthink. This is the same kind of torture parents must feel when their kids make mistakes—experimenting with drugs, neglecting their studies, or forgetting to look both ways when crossing a street—that they have tried to help them avoid.

This is a main reason I write year after year. As a writer, I like to imagine that adoring readers follow most, if not all, of the advice in my columns and consequently steer clear of trouble. In that advisory spirit, I intended this article to help you decide when to use XML Web services versus when to use .NET remoting. The choice is actually quite easy: Choose XML Web services almost all of the time. That’s it. What? Don’t believe me? Need justification? Okay, read on.

Understanding Your Choice

XML Web services are an implementation of .NET remoting. This means when you use XML Web services, you are really using .NET remoting. In fact, XML Web services are an easy way to use marshal-by-value .NET remoting.

XML Web services also are perfectly suited for many purposes because they are easy to produce, configure, deploy, and consume. I suspect this functionality will motivate Microsoft to bury remoting permanently.

When to Use .NET Remoting

Occasionally, using remoting directly makes sense. The following basic guidelines specify when it is the right choice:

  • Your distributed solution will be used by an internal customer.
  • You need two-way communications between client and server.
  • You have to work with large amounts of data, and serialization and transporting these large objects would result in terrible performance.
  • You need to work with resources that reside on the server, and a copied object would not provide access to those resources.

You can’t do much to avoid remoting when resources are on the server or events raised on the server need to be handled by clients, but you can mitigate the large data problem by defining Web services that are more selective about the data they return.

This means that you need remoting only when you have server-side resources or server events. I suspect that if Microsoft solves these problems with XML Web services, Web services will work 100 percent of the time.

Choose Web Services

XML Web services are .NET remoting lite. Most of the time, when you want to build distributed applications, you should use XML Web services. In increasingly rare circumstances, you may need to program against the remoting namespace itself, but try to use Web services first.

For an example of .NET remoting, see my article “.NET Remoting and Event Handling” on www.codeguru.com or www.developer.com.

Biography

Paul Kimmel is the VB Today columnist for www.codeguru.com and has written several books on object-oriented programming and .NET. Check out his book, Visual Basic .NET Power Coding, from Addison-Wesley and his upcoming book, UML DeMystified, from McGraw-Hill/Osborne (Spring 2005). Paul is also the founder and chief architect for Software Conceptions, Inc, founded 1990. He is available to help design and build software worldwide. You may contact him for consulting opportunities or technology questions at pkimmel@softconcepts.com.

If you are interested in joining or sponsoring a .NET Users Group, check out www.glugnet.org.

Copyright © 2004 by Paul Kimmel. All Rights Reserved.

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read