Exforsys

Ads


Home arrow Reviews arrow SOA Web Services

SOA Web Services - Developing the Test Client

Author: Packt Publishing     Published on: 1st Aug 2008

Developing the Test Client

We will now develop a C# console application for consuming the previously created web services. Use the project wizard in VS.NET to create a console application.

Ads

Follow the default while creating the application. I used TestClient as the name for my project. The wizard generates the skeleton code for a console application. You will need to add code to this skeleton to invoke the two web services. Before you do so, you will need to add web references to the two services. The IDE provides a menu for adding these references. Use the WSDL URLs specified earlier for locating the web services. Once you complete adding the web reference, you can modify the client code. The intelli-sense feature in the IDE will now resolve the references correctly.

The modified code is shown in the following listing.

Sample Code
  1. using System
  2. using System.Collections.Generic
  3. using System.Text
  4. namespace TestClient
  5. {
  6. class Program
  7. {
  8.  static void Main(string[] args)
  9. {
  10. String str =
  11. "Testing .NET, Java Web Services Integration"
  12. NetService.Service service1 = new NetService.Service()
  13. str += service1.SayHello()
  14. JavaService.HelloService service2 =
  15. new JavaService.HelloService()
  16. str += service2.SayHello()
  17. Console.WriteLine(str)
  18. Console.ReadKey()
  19.  }
  20. }
  21. }
Copyright exforsys.com


The application obtains the reference to the NetService by instantiating the Service class. The code then calls the service method on the obtained object reference. Similarly, a reference to the JavaService is obtained by instantiating the HelloService class. The SayHello method is invoked on the obtained object reference. Finally, the application prints the two greeting messages on the user console. Note that when you invoke the service method, the binary method call gets converted into a SOAP call. Similarly, the response from the web service is returned to the application as a SOAP response. The underlying runtime transforms the binary call to SOAP and the SOAP response to the C# return type as defined by the method.

Summary

SOA has become a buzz world in today's IT industry. From the component-oriented approach, we have now moved into the service-oriented approach. Businesses publish the offered services rather than the interfaces to their components. While designing SOA for an enterprise application, the study of patterns plays a vital role in the success of SOA implementation. In this chapter, the various SOA patterns and guidelines for applying those in real-life situations were covered.

The web services technology perfectly complements the creation of SOA. The chapter discussed the architecture of web services and its benefits. The chapter covered in depth the various patterns that can be applied while creating SOA using web services.

Web services may be used in both EAI and B2B problem spaces. The chapter covered the essential differences between EAI and B2B and how to apply SOA integration techniques in these spaces.

Merely exposing your application as a web service is not sufficient. Any client should be able to use your service with ease. Web services are inherently interoperable. However, due the varying implementations of the web service specifications, usually these are not interoperable. To make web services interoperable, a consortium called the Web Services Interoperability (WS-I) organization was formed. The working group of WS-I created several documents for defining the requirements of creating interoperable secured web services. This chapter discussed these specifications. If you create a web service that is BP (Basic Profile) compliant, it will be interoperable with other services.

Ads

The chapter also discussed several guidelines for creating interoperable web services. Finally, a complete trivial example of creating web services on two popular platforms, .NET and Java EE, was discussed. We demonstrated by writing a .NET client that these services are interoperable.

 
This tutorial is part of a SOA Web Services tutorial series. Read it from the beginning and learn yourself.

SOA Web Services

 

Comments