Miles to go …

July 10, 2007

GlassFish V2 Beta3 and Vista – Interoperable out-of-the-box

Filed under: webservices — arungupta @ 12:18 pm

GlassFish V2 beta3 is now available. I take this opportune moment for a follow up entry showing how a Reliable WSIT endpoint can be invoked from WCF client and vice versa. WSIT is already integrated in GlassFish V2.

The first part where a WSIT endpoint is invoked by a WCF client is now already available in this entry by Jesus Rodriguez. Couple of points in the entry:

  • The Web Service configuration (a.k.a. WSIT configuration file) is not hand edited. Instead it is conveniently generated by NetBeans IDE as shown in screencast #ws3. The user experience really is to just check mark a box and all the relevant XML fragments are generated by NetBeans.
  • Even though entry requires to rely on SOAP 1.1 (mistyped as WS-Addressing 1.1) , it workes with SOAP 1.2 very well. In fact, I’ve used SOAP 1.2 in the code below.

This entry provides the code to deploy a Reliable WCF endpoint and invoke it using a WSIT client.

  1. Create a service endpoint service.svc as:

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

    using System.ServiceModel;

    namespace WCFReliableEndpoint
    {
      [ServiceContract]
       public interface IHello
       {
         [OperationContract]
         string sayHello(string name);
       }

       public class Hello : IHello
       {
         public string sayHello(string name)
         {
           return "Hello " + name;
         }
       }
    }

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

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.serviceModel>
        <services>
          <service name="WCFReliableEndpoint.Hello" behaviorConfiguration="MetadataBehavior">
            <endpoint address=""
                      binding="customBinding"
                      bindingConfiguration="Binding1"
                      contract="WCFReliableEndpoint.IHello" />
          </service>
        </services>

        <bindings>
          <customBinding>
            <binding name="Binding1">
              <reliableSession />
                <textMessageEncoding messageVersion="Soap12WSAddressing10" writeEncoding="utf-8" />
                <httpTransport authenticationScheme="Anonymous" bypassProxyOnLocal="false"
                  hostNameComparisonMode="StrongWildcard"
                  proxyAuthenticationScheme="Anonymous" realm=""
                  useDefaultWebProxy="true" />
            </binding>
          </customBinding>
        </bindings>

        <behaviors>
          <serviceBehaviors>
            <behavior name="MetadataBehavior">
              <serviceMetadata httpGetEnabled="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>

      </system.serviceModel>
    </configuration>

  3. If IIS was installed after Vista installation was complete, then you’ll have to explicitly register WCF components with IIS following these instructions and as shown below:

  4. Create a virtual directory, say wsit-reliable, in IIS mapping to the directory where service.svc and Web.config are present. You should now see the default WCF/IIS page as below:

    The service endpoint is now hosted at http://localhost/wsit-reliable/service.svc and the WSDL of the endpoint looks like:

  5. Create a WSIT client, using NetBeans IDE, following the instructions in screencast #ws2. Enable WSIT message logging by adding the following property to domains/domain1/config/domain.xml:

    <jvm-options>-Dcom.sun.xml.ws.assembler.client=true</jvm-options>

  6. The SOAP messages exchanged between the WSIT client and the WCF endpoint are given below:

    ====[com.sun.xml.ws.assembler.client:request]====
    <?xml version="1.0" ?>
    <S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope">
      <S:Header>
        <To xmlns="http://www.w3.org/2005/08/addressing">http://iamfine/wsit-reliable/service.svc</To>
        <Action xmlns="http://www.w3.org/2005/08/addressing">http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence</Action>
        <ReplyTo xmlns="http://www.w3.org/2005/08/addressing">
          <Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
        </ReplyTo>
        <MessageID xmlns="http://www.w3.org/2005/08/addressing">uuid:fcaef2ab-bccf-4a08-a1d1-b10f7819f7ea</MessageID>
      </S:Header>
      <S:Body>
        <ns2:CreateSequence
            xmlns:ns6="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
            xmlns:ns5="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
            xmln
    s:ns4="http://www.w3.org/2005/08/addressing" xmlns:ns3="http://schemas.microsoft.com/ws/2006/05/rm"
            xmlns:ns2="http://schemas.xmlsoap.org/ws/2005/02/rm">
          <ns2:AcksTo>
            <ns4:Address>http://www.w3.org/2005/08/addressing/anonymous</ns4:Address>
          </ns2:AcksTo>
          <ns2:Offer>
            <ns2:Identifier>uuid:4953079f-3726-40b5-b6b4-255eb46c0fda</ns2:Identifier>
          </ns2:Offer>
        </ns2:CreateSequence>
      </S:Body>
    </S:Envelope>
    ============
    ====[com.sun.xml.ws.assembler.client:response]====
    <?xml version="1.0" ?>
    <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
      <s:Header>
        <a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequenceResponse</a:Action>
        <a:RelatesTo>uuid:fcaef2ab-bccf-4a08-a1d1-b10f7819f7ea</a:RelatesTo>
      </s:Header>
      <s:Body>
        <CreateSequenceResponse xmlns="http://schemas.xmlsoap.org/ws/2005/02/rm">
          <Identifier>urn:uuid:8ebe44c6-494c-4a43-8ade-dab90800d7f5</Identifier>
          <Accept>
            <AcksTo>
              <a:Address>http://iamfine/wsit-reliable/service.svc</a:Address>
            </AcksTo>
          </Accept>
        </CreateSequenceResponse>
      </s:Body>
    </s:Envelope>
    ============
    ====[com.sun.xml.ws.assembler.client:request]====
    <?xml version="1.0" ?>
    <S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope">
      <S:Header>
        <To xmlns="http://www.w3.org/2005/08/addressing">http://iamfine/wsit-reliable/service.svc</To>
        <Action xmlns="http://www.w3.org/2005/08/addressing">http://tempuri.org/IHello/sayHello</Action>
        <ReplyTo xmlns="http://www.w3.org/2005/08/addressing">
          <Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
        </ReplyTo>
        <MessageID xmlns="http://www.w3.org/2005/08/addressing">uuid:5ac7c151-8049-444e-8dd0-1e053b26895d</MessageID>
        <ns2:Sequence
          xmlns:ns4="http://www.w3.org/2005/08/addressing"
          xmlns:ns3="http://schemas.microsoft.com/ws/2006/05/rm"
          xmlns:ns2="http://schemas.xmlsoap.org/ws/2005/02/rm">
          <ns2:Identifier>urn:uuid:8ebe44c6-494c-4a43-8ade-dab90800d7f5</ns2:Identifier>
          <ns2:MessageNumber>1</ns2:MessageNumber>
        </ns2:Sequence>
        <ns2:AckRequested
          xmlns:ns4="http://www.w3.org/2005/08/addressing"
          xmlns:ns3="http://schemas.microsoft.com/ws/2006/05/rm"
          xmlns:ns2="http://schemas.xmlsoap.org/ws/2005/02/rm">
          <ns2:Identifier>urn:uuid:8ebe44c6-494c-4a43-8ade-dab90800d7f5</ns2:Identifier>
        </ns2:AckRequested>
      </S:Header>
      <S:Body>
        <sayHello xmlns:ns2="http://schemas.microsoft.com/2003/10/Serialization/" xmlns="http://tempuri.org/">
          <name>Duke</name>
        </sayHello>
      </S:Body>
    </S:Envelope>
    ============
    ====[com.sun.xml.ws.assembler.client:response]====
    <?xml version="1.0" ?>
    <s:Envelope
        xmlns:s="http://www.w3.org/2003/05/soap-envelope"
        xmlns:r="http://schemas.xmlsoap.org/ws/2005/02/rm"
        xmlns:a="http://www.w3.org/2005/08/addressing">
      <s:Header>
        <r:Sequence s:mustUnderstand="1">
          <r:Identifier>uuid:4953079f-3726-40b5-b6b4-255eb46c0fda</r:Identifier>
          <r:MessageNumber>1</r:MessageNumber>
        </r:Sequence>
        <r:SequenceAcknowledgement>
        <r:Identifier>urn:uuid:8ebe44c6-494c-4a43-8ade-dab90800d7f5</r:Identifier>
        <r:AcknowledgementRange Lower="1" Upper="1"></r:AcknowledgementRange>
          <netrm:BufferRemaining xmlns:netrm="http://schemas.microsoft.com/ws/2006/05/rm">8</netrm:BufferRemaining>
        </r:SequenceAcknowledgement>
        <a:Action s:mustUnderstand="1">http://tempuri.org/IHello/sayHelloResponse</a:Action>
        <a:RelatesTo>uuid:5ac7c151-8049-444e-8dd0-1e053b26895d</a:RelatesTo>
      </s:Header>
      <s:Body>
        <sayHelloResponse xmlns="http://tempuri.org/">
          <sayHelloResult>Hello Duke</sayHelloResult>
        </sayHelloResponse>
      </s:Body>
    </s:Envelope>
    ============

There were no custom settings or configurations required to make the WSIT client This shows, once again, that GlassFish V2 and .NET 3.0 (pre-bundled in Vista) are interoperable out of the box.

Technorati: webservices wsit glassfish reliablemessaging wcf interoperability

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot
Related posts:
  1. wsHttpDualBinding – a non-interoperable binding
  2. GlassFish and Vista – Interoperable out-of-the-box
  3. TOTD #22: Java SE client for a Metro endpoint
  4. How to invoke a WSIT endpoint from a WCF client ?
  5. How WS-Addressing Action header is calculated ?

5 Comments »

  1. [Trackback] It looks like I don’t need to post the second part of my WS-ReliableMessaging WCF WSIT interoperability

    Comment by Jesus Rodriguez's WebLog — July 11, 2007 @ 6:44 pm

  2. [Trackback] Rama described how to run JAX-WS samples with Tomcat 6.x. JAX-WS is part of Metro – the Web services stack in GlassFish. Another key component of Metro is WSIT (aka Project Tango) that provides Secure, Reliable, Transactional and Interoperable Web…

    Comment by Arun Gupta's Blog — July 23, 2007 @ 6:05 am

  3. [Trackback] WS-ReliableMessaginginteroperabilitybetweenMicrosoftWCFandSunWSIT

    .style1{
    background…

    Comment by 龍龙 — April 28, 2008 @ 11:05 am

  4. I have an WCF webservice with Reliable Messaging – but I can’t get a working client using Eclipse and WSIT.

    WSDL: http://adifa.software-ticon.de:52000/TestService/

    Is there any tutorial showing how to use WSIT wsimport and the generated code to talk to such a service?

    Regards.
    Herwig

    Comment by Herwig Weidle — November 1, 2010 @ 1:45 pm

  5. Herwig,

    Can you post your question to ?

    Thanks
    -Arun

    Comment by Arun Gupta — November 1, 2010 @ 2:56 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.
Powered by WordPress