Arun Gupta, Miles to go ...

Arun Gupta is a technology enthusiast, a passionate runner, and a community guy who works for Sun Microsystems.
« Previous day (Feb 1, 2007) | Main | Next day (Feb 3, 2007) »

http://blogs.sun.com/arungupta/date/20070202 Friday February 02, 2007

Sun understands WS-* very well!!!

Thanks to Robin Wilton for the link.

Read more about how Sun and Microsoft achieved product-level interoperability between GlassFish and Windows Vista. A quote from the article ...

"as these two teams worked together to bring about some calm in the turbulent seas of Web services, they found that engineering knows no prejudice. The result, three years later, is Sun’s Web Services Integration Technology, and Microsoft has called it the best implementation of the WS-* standards outside of its own."

I'm proud to be part of WSIT team since it's inception. This is a great start to the weekend!

Technorati: WSIT GlassFish Web services Sun Microsoft

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

Deployment Descriptor-free Web services in GlassFish

One of the big benefits of JAX-WS 2.0 is that deployment descriptors are optional. By optional, it means no deployment descriptors are required if you can live with the reasonable defaults defined by the JAX-WS specification. So if you develop a trivial Web service, starting from POJO (Plain Old Java Object), as:

@javax.jws.WebService(targetNamespace="http://example.org")
public class Hello {
  public String sayHello(String name) {
    return "Hello " + name;
  }
}

compile it and drop the class in $AS_HOME/domains/domain/autodeploy directory, where AS_HOME is the directory location for GlassFish, then you have deployed a Web service at http://localhost:8080/Hello/HelloService?wsdl. With GlassFish v2 M4, the WSDL looks like (default values are highlighted in bold):

<?xml version="1.0" ?>
<definitions 
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns:tns="http://example.org"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns="http://schemas.xmlsoap.org/wsdl/"
  targetNamespace="http://example.org"
  name="HelloService">
  <types>
    <xsd:schema>
      <xsd:import namespace="foobar" schemaLocation="http://localhost:8080/Hello/HelloService?xsd=1">
      </xsd:import>
    </xsd:schema>
  </types>
  <message name="sayHello">
    <part name="parameters" element="tns:sayHello">
    </part>
  </message>
  <message name="sayHelloResponse">
    <part name="parameters" element="tns:sayHelloResponse">
    </part>
  </message>
  <portType name="Hello">
    <operation name="sayHello">
      <input message="tns:sayHello">
      </input>
      <output message="tns:sayHelloResponse">
      </output>
    </operation>
  </portType>
  <binding name="HelloPortBinding" type="tns:Hello">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document">
    </soap:binding>
    <operation name="sayHello">
      <soap:operation soapAction="">
      </soap:operation>
      <input>
        <soap:body use="literal">
        </soap:body>
      </input>
      <output>
        <soap:body use="literal">
        </soap:body>
      </output>
    </operation>
  </binding>
  <service name="HelloService">
    <port name="HelloPort" binding="tns:HelloPortBinding">
      <soap:address location="http://localhost:8080/Hello/HelloService">
      </soap:address>
    </port>
  </service>
</definitions>

The wsdl:service/@name, wsdl:port/@name, wsdl:portType/@name and other similar elements use a default value, defined by the JAX-WS specification, derived from the class name and method name. All these values can be easily configured using @WebService and @WebMethod.

This class is in default package and that's why @WebService/targetNamespace attribute is required. Otherwise targetNamespace is derived from the package name and in which case the Web service implementation looks like:

package hello;

public class Hello 
  public String sayHello(String name) {
    return "Hello " + name;
  }
}

There is a similar sample in GlassFish samples as well. A much broader collection of JAX-WS samples is available here.

This Deployment Descriptor-free concept also work if you really like to bundle up your classes together in a WAR. Basically just package your classes in WEB-INF/classes directory and that's it. No web.xml, sun-web.xml or any proprietary descriptors are required.

As shown above, converting your POJO to a Web service is really simple, does not require any deployment descriptors, improves readability of code and is backed by the production-quality JAX-WS runtime in GlassFish.

And if you are using NetBeans, then you don't need to worry about any of these details.

Technorati: Web service GlassFish JAX-WS JAXWS Samples Ease of Use

del.icio.us | furl | simpy | slashdot | technorati | digg |
|
« Previous day (Feb 1, 2007) | Main | Next day (Feb 3, 2007) »

Valid HTML! Valid CSS!

This is a personal weblog, I do not speak for my employer.