Using Web Services for Interoperability


Even though the .NET platform provides a bidirectional interoperability mechanism ” invoking .NET components in COM and invoking COM components in .NET ”Web services provide an alternative way of integrating two technologies. Whereas platform-level interoperability mechanisms typically are sufficient and efficient, Web services always provide a standards-based approach for interoperability. The idea is that COM objects can be exposed as Web services using the Microsoft SOAP Toolkit available from http://www.microsoft.com/soaptoolkit. Next, these Web services can be referenced with applications and services developed using .NET. Similarly, the SOAP Toolkit provides a mechanism for COM-based applications to interact with other Web services, which, in this case, can be a .NET Web service (see Figure 11.9).

Figure 11.9. Using SOAP Toolkit 3.0 to generate a Web service for a COM object.

After the Web service is created for the COM object, the WSDL.EXE utility (included in the .NET Framework SDK) can be used to create a Web service proxy class.

 
 wsdl http://localhost/soap/TradeAppService.wsdl 

Following is what the generated code for the Web service proxy looks like:

 
 using System.Diagnostics; ... public class TradeAppService : System.Web.Services.Protocols.SoapHttpClientProtocol { ...         public TradeAppService() {         this.Url = "http://localhost/soap/TradeAppService.WSDL";     }      ...     public short ExecTrade(string equity, string buyer, string price) {         object[] results = this.Invoke("ExecTrade", new object[] {                     equity,                     buyer,                     price});         return ((short)(results[0]));     }      ... } 

The generated Web service stub can then be utilized within the .NET Framework like any other Web service.

 
 using System; class UseTradeApp {    public static void Main() {       TradeAppService service = new TradeAppService();       int result = service.ExecTrade("MSFT","hitesh.seth","50");       Console.WriteLine(result);    } } csc UseTradeApp.cs TradeAppService.cs 

SHOP TALK : WEB SERVICES FOR INTEROPERABILITY ”IS IT WORTH IT?

Even though using the Web services as a mechanism for interoperability requires some additional work (for instance, using the SOAP Toolkit to create, test, and deploy Web service wrappers), it is well worth it. The key advantage is that of a loosely coupled architecture. Instead of focusing on interoperating binary code method calls, you are interoperating at an XML document level, which is much easier to track, diagnose, and implement. In fact, if implementing a standard SOAP/WSDL “based Web service becomes an issue because of lack of Web service toolkits for your legacy platform, a simple XML-based interchange works as well. Another benefit of Web services is that the model applies equally for synchronous and asynchronous invocations. For instance, you can create a SOAP envelope and send it to a message queue and continue processing. Queuing technology (such as Microsoft Message Queuing ”MSMQ or IBM MQ Series) adds additional messaging-based loose coupling, making it possible that a consumer and producer can be built using different architectures.


A key benefit to the Web services approach is that it can be applied to interoperate .NET components and applications not only with COM objects, but also with application components developed in other programming languages and frameworks, including Java, J2EE, and Perl (see Figure 11.10). Most of these technologies provide a Web services toolkit, which can be used to expose applications and components developed using that technology as Web services.

Figure 11.10. Using Web services for interoperability.

For instance, for interoperability with J2EE technologies, the Java Web Services Developer Pack (java.sun.com/ webservices ) can be used to expose Enterprise Java Beans and other Java objects as Web services. A key to using Web services for an interoperability mechanism is whether the Web services toolkit conforms to the WS-I (Web Services Interoperability) standards organization's framework.



Microsoft.Net Kick Start
Microsoft .NET Kick Start
ISBN: 0672325748
EAN: 2147483647
Year: 2003
Pages: 195
Authors: Hitesh Seth

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net