Skip to main content

GlassFish and Vista - Interoperable out-of-the-box

Posted by arungupta on February 13, 2007 at 7:39 AM PST

v2 M4
and Windows
were released two
weeks ago
. I installed GlassFish M4 on my machine and Vista
on a different machine. In this blog, I explain the steps
followed to invoke a Web service deployed on GlassFish by Vista client and
vice versa.

First, lets deploy a service on GlassFish and invoke it using a client on

  1. Using screencast
    , I developed a trivial Web service using NetBeans
    and deployed on GlassFish.
  2. On Vista machine, I generated the client-side artifacts using the command:

    svcutil /config:Client.exe.config
  3. Then I coded the client code to invoke the service endpoint as:

    using System;

        using System.Collections.Generic;

        using System.Text;


        namespace ConsoleApplication1


           class Program


               static void Main(string[] args)


        NewWebServiceClient client = new NewWebServiceClient();

                   string response
        = client.sayHello("Duke");

        Console.WriteLine("Response from WSIT endpoint: " + response);



  4. Next step is to compile the client code using the command:

    csc.exe /r:"C:\WINDOWS\Microsoft.NET\Framework\v3.0\Windows
        Communication Foundation\System.ServiceModel.dll"

        Communication Foundation\System.Runtime.Serialization.dll"


    I wonder if there is a way by which csc.exe compiler can be
    made smarter to recognize WCF assemblies by default. But for now, I need to
    explicitly specify the assemblies during compilation otherwise the compiler
    throws bunch of errors like:

    NewWebServiceService.cs(100,63): error CS0234: The type or namespace
        name 'ServiceModel' does not exist in the namespace 'System' (are you
        missing an assembly reference?)
  5. After a successful compilation, invoking the client shows the result:

    Response from WSIT endpoint: Hello Duke

Now let's deploy a similar Web service on Vista and invoke it using

  1. There are multiple ways a WCF Web service can be created from scratch but
    I find the following steps easiest. Create  service endpoint service.svc

    <%@ServiceHost language=c# Debug="true" Service="WCFEndpoint.Hello"


        using System.ServiceModel;


        namespace WCFEndpoint



           public interface IHello



               string sayHello(string name);



           public class Hello : IHello


               public string sayHello(string name)


        "Hello " + name;



  2. In the same directory create Web.config as:

    <?xml version="1.0" encoding="utf-8"?>





        <behavior name="MetadataBehavior">

        <serviceMetadata httpGetEnabled="true" />





        behaviorConfiguration="MetadataBehavior" name="WCFEndpoint.Hello">

        <endpoint address="" binding="basicHttpBinding"

        name="Hello" contract="WCFEndpoint.IHello" />




  3. I installed IIS after installing Vista so WCF extensions need to be
    explicitly registered as shown
  4. Create a virtual directory, say wsit, in IIS mapping to the
    directory where service.svc and Web.config are
    present. You should now see the default WCF/IIS page as shown
    . The service endpoint now should be hosted at http://localhost/wsit/service.svc.
  5. Using screencast
    , create a JAX-WS client to invoke the Web service.

This is an example of a trivial interoperable Web service between GlassFish
M4 and Vista but the key fact is that, as a developer, this is provided as
out-of-the-box experience. No extra tweaks or no special configurations

I plan to build upon this Web service by adding enterprise Web services
features such as Reliable Messaging, Security etc. and show how WSIT
enables interoperability with WCF.

Technorati: WSIT Web
GlassFish Vista

Related Topics >>