Two for the Road


We've just done interop with a product from IBM; now let's continue down the path by creating test clients for two other major players, Oracle and Sun Microsystems. From a technology perspective, we'll be revisiting what we've done earlier in the chapter. So why include this in the book? To underscore the value that standardsand a tool such as WCF that is built on standardsprovide to the Enterprise. The SvcUtil.exe utility reads platform-agnostic WSDL files, and we're up and interoperating in minutes.

Create a WCF Client to Test Interop with Sun Microsystems

Sun Microsystems has a public-facing Web service that can be used for interoperability testing. This service is provided solely for interoperability tests, so its operations are limited to "echoes." These operations will receive a value of a particular type, such as a string, and will return that same value to the caller:

  1. Create a new Windows Console project in C:\WCFHandsOn\Chapter7\PartIV\Before\SunClient\.

  2. Add a Reference to System.ServiceModel.

  3. Add using System.ServiceModel; to the top of the Program.cs file:

    using System; using System.Collections.Generic; using System.Text; using System.ServiceModel;

  4. Open Visual Studio.NET Command Window.

  5. Execute the SvcUtil.exe utility with a reference to the service to create a proxy and configuration file to be used by the client.

    [View full width]

    "c:\Program Files\Microsoft SDKs\Windows\v1.0\Bin\SvcUtil.exe " http://soapinterop.java .sun.com/round2/base?WSDL /out:proxy.cs

  6. Using Solution Explorer, add proxy.cs to the SunClient project.

  7. Using Solution Explorer, add output.config to the SunClient project.

  8. Rename output.config to App.config.

    Open App.config and add a name for the endpoint. Add the text name="SunInterop" to the endpoint element in the client section of the config file:

    <client>     <endpoint name="SunInterop" address="http://soapinterop.java.sun.com:80/round2/base"     bindingConfiguration="RIBaseBinding" binding="customBinding"     contract="RIBaseIF" /> </client>

  9. Place the following code in the Main method in the Program.cs file:

    static void Main(string[] args) {   RIBaseIFProxy proxy = new RIBaseIFProxy("SunInterop");   System.Console.WriteLine("Enter in the phrase to tell Sun");   String repeatText = System.Console.ReadLine();   System.Console.WriteLine();   System.Console.WriteLine("Sun  if you can understand me, repeat after me:" + repeatText);   System.Console.WriteLine("Sun says:" + proxy.echoString(repeatText));   System.Console.ReadKey(); }

  10. In Solution Explorer, right-click the project and select Debug, Start New Instance.

The client will prompt you for some text to send to Sun. It will then contact the Sun Web service, which will return that same text.

Create a WCF Client to Test Interop with Oracle Application Server

Oracle has a public-facing website and services for its Oracle Application Server 10g. There is a public-facing Web service attached to the product. This service has several username and password controlled services; however, we're interested only in testing interop. In this exercise, we'll create a client that tests the GetVersion operation, which does not require a username or password:

  1. Create a new Windows Console project in C:\WCFHandsOn\Chapter7\PartIV\Before\OracleClient\.

  2. Add a Reference to System.ServiceModel.

  3. Add using System.ServiceModel; to the top of the Program.cs file:

    using System; using System.Collections.Generic; using System.Text; using System.ServiceModel;

  4. Open Visual Studio.NET Command Window.

  5. Execute the SvcUtil.exe utility with a reference to the service to create a proxy and configuration file to be used by the client.

    [View full width]

    "C:\Program Files\Microsoft SDKs\Windows\v1.0\Bin\Svcutil.exe " /out:proxy.cs http:/ /messenger.oracle.com/xms/webservices?WSDL

  6. Using Solution Explorer, add proxy.cs to the OracleClient project.

  7. Using Solution Explorer, add output.config to the OracleClient project.

  8. Rename output.config to App.config

    Open App.config and add a name for the endpoint. Add the text name="OracleInterop" to the endpoint element in the client section of the config file:

    <client>     <endpoint name="OracleInterop" address= "http://notify.multimodeinc.com/xms/webservices"     bindingConfiguration="XMSServerBinding" binding="customBinding"     contract="XMSServerPortType" /> </client>

  9. Place the following code in the Main method in the Program.cs file:

    static void Main(string[] args) {    //ORACLE    XMSServerPortTypeProxy proxy = new XMSServerPortTypeProxy("OracleInterop");    string version = proxy.getVersion();    System.Console.WriteLine("The version of Oracle currently running is:" + version);    System.Console.ReadLine(); }

  10. In Solution Explorer, right-click the project and select Debug, Start New Instance.

The client will connect to the Oracle service, return the current version, and display it in the console.




Presenting Microsoft Communication Foundation. Hands-on.
Microsoft Windows Communication Foundation: Hands-on
ISBN: 0672328771
EAN: 2147483647
Year: 2006
Pages: 132

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