Web Services Interoperability Technology (WSIT) - Project Tango

Sang Shin, sang.shin@sun.com, www.javapassion.com/webservices



Sun is working closely with Microsoft to ensure interoperability of web services enterprise technologies such as message optimization, reliable messaging, and security. The initial release of WSIT is a product of this joint effort. WSIT is an implementation of a number of open web services specifications to support enterprise features. In addition to message optimization, reliable messaging, and security, WSIT includes a bootstrapping and configuration technology.

In this lab, you are going to learn how to build and deploy Web services and their clients leveraging WSIT features, especially Reliability, Security, and Message Optimization (via MTOM).


Expected duration: 90 minutes


Software Needed

Before you begin, you need to install the following software on your computer. 


Change Log


Things to do by (Sang Shin)


Lab Exercises



Exercise 1: Build and run "HelloWebService" Web Service with Reliable Messaging

In this exercise, you are going to build HelloWebService and its client without using Reliable messaging first and then configure the Web service and its client to use Reliable messaging.  
  1. Build, deploy, and test "HelloWebService" Web service
  2. Build and run "HelloWebServiceClientWSMonitor" standalone client
  3. Build and run "HelloWebServiceWebClientWSMonitor" Web-based client
  4. Configure "HelloWebService" Web service to use Reliable Messaging
  5. Rebuild and run "HelloWebServiceClientWSMonitor" standalone client
  6. Rebuild and run "HelloWebServiceWebClientWSMonitor" Web-based client

(1.1) Build, deploy, and test "HelloWebService" Web service


In this step, you are going to build, deploy, and test "HelloWebService" Web service.  This is a Web service without using any WSIT features.  You are going to add Reliable messaging WSIT feature to this Web service in the subsequent steps.

0. Start NetBeans IDE if you have not done so yet.
1. Open HelloWebService NetBeans project. 

2. Deploy the application.
3. Test the Web service.

Figure-1.11: Test Web Service

Figure-1.12: Send data to the Web service

Figure-1.13: Test result

                                                                                                                        return to top of the exercise



(1.2) Build and run "HelloWebServiceClientWSMonitor" Client


In this step, you are going to build a client application that accesses the HelloWebService while monitoring the SOAP traffic using WS Monitor.

1.  Start the WS Monitor.

Figure-1.21: WS Monitor started

2. Open HelloWebServiceClientWSMonitor NetBeans project. 
3. Build and run the client application.

Figure-1.22: Result of running client application

Figure-1.23: Captured SOAP traffic



(1.3) Build and run "HelloWebServiceWebClientWSMonitor" Web-based client


In this step, you are going to build a Web client application that accesses the HelloWebService while monitoring the SOAP traffic using WS Monitor.

1.  Start the WS Monitor (if you have not done so yet).

2. Open HelloWebServiceWebClientWSMonitor NetBeans project. 
3. Build and run the client application.

Figure-1.31: Result


(1.4) Configure "HelloWebService" Web service to use Reliable Messaging


In this step, you are going to configure the HelloWebService to use Reliable Messaging. 

1. Open Edit Web Service Attributes editor window.

Figure-1.41: Open Edit Web Service Attributes editor

2. Set Reliable Messaging attributes.

Figure-1.43: Configure Reliability

3. Redeploy the Web service.
4. Test the Web service.

Figure-1.44: Reliable messaging

5. Observe the new WSDL document.

Figure-1.45: Click WSDL File link

Figure-1.46: WSDL document with Reliable messaging elements
<?xml version="1.0" encoding="UTF-8"?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.2-hudson-182-RC1. --><!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.2-hudson-182-RC1. --><definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://mypackage/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://mypackage/" name="HelloService">
    <wsp:UsingPolicy></wsp:UsingPolicy>
    <wsp:Policy wsu:Id="HelloPortBindingPolicy">
        <wsp:ExactlyOne>
            <wsp:All>
                <ns1:RMAssertion xmlns:ns1="http://schemas.xmlsoap.org/ws/2005/02/rm/policy"></ns1:RMAssertion>
                <ns2:Ordered xmlns:ns2="http://sun.com/2006/03/rm"></ns2:Ordered>
                <ns3:UsingAddressing xmlns:ns3="http://www.w3.org/2006/05/addressing/wsdl"></ns3:UsingAddressing>
            </wsp:All>
        </wsp:ExactlyOne>
    </wsp:Policy>
    <types>
        <xsd:schema>
            <xsd:import namespace="http://mypackage/" schemaLocation="http://localhost:8080/HelloWebService/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">
        <wsp:PolicyReference URI="#HelloPortBindingPolicy"></wsp:PolicyReference>
        <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/HelloWebService/HelloService"></soap:address>
        </port>
    </service>
</definitions>
Code-1.47: WSDL document with reliable messaging


(1.5) Rebuild "HelloWebServiceClientWSMonitor" (stand-alone client) to use Reliable Messaging


In this step, you are going to rebuild HelloWebServiceClientWSMonitor using reliable messaging.  In order to use WSIT features for a standalone Web service client, you have to manually add the following two jar files to the classpath.  These two jar files contains WSIT implementation.  You don't need to do this when you are creating Web-based Web service client.
1.  Add webservices-tools.jar and webservices-rt.jar to the classpath of the HelloWebServiceClientWSMonitor project.

Figure-1.51: Select Properties of the project

Figure-1.52: Add JAR/Folder

Figure-1.53: Select wbservices-rt.jar and webservices-tools.jar

Figure-1.54: wbservices-rt.jar and webservices-tools.jar are now in the classpath

2. Rebuild the HelloWebServiceClientWSMonitor project using new WSDL (with reliable messaging).

Figure-1.55: Refresh client

Figure-1.56: Confirm Client Refresh

Figure-1.57: New client side code is generated

3. Build and run the client.
4. Observe that the WSMonitor captures two exchanges of SOAP messages.  The first exchange of SOAP request/response messages establishes reliable messaging while the second exchange of SOAP request/response messages contains actual data. (Figure-1.58 below)


Figure-1.58: WS Monitor of the first exchange of SOAP request/response messages

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Header>
        <To xmlns="http://www.w3.org/2005/08/addressing">http://localhost:4040/HelloWebService/HelloService</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:037a53b5-72c2-40ab-aa20-7f31344f4847</MessageID>
    </S:Header>
    <S:Body>
        <ns2:CreateSequence
            xmlns:ns2="http://schemas.xmlsoap.org/ws/2005/02/rm"
            xmlns:ns3="http://schemas.microsoft.com/ws/2006/05/rm"
            xmlns:ns4="http://www.w3.org/2005/08/addressing"
            xmlns:ns5="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ns6="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <ns2:AcksTo>
                <ns4:Address>http://www.w3.org/2005/08/addressing/anonymous</ns4:Address>
            </ns2:AcksTo>
            <ns2:Offer>
                <ns2:Identifier>uuid:3324939e-5798-4d30-9c9b-a90013fe7aff</ns2:Identifier>
            </ns2:Offer>
        </ns2:CreateSequence>
    </S:Body>
</S:Envelope>
Figure-1.59: SOAP request message of the first exchange

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Header>
        <To xmlns="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing/anonymous</To>
        <Action xmlns="http://www.w3.org/2005/08/addressing">http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequenceResponse</Action>
        <MessageID xmlns="http://www.w3.org/2005/08/addressing">uuid:c5255b96-fbeb-4937-92ad-debfa4735390</MessageID>
        <RelatesTo xmlns="http://www.w3.org/2005/08/addressing">uuid:037a53b5-72c2-40ab-aa20-7f31344f4847</RelatesTo>
    </S:Header>
    <S:Body>
        <ns2:CreateSequenceResponse
            xmlns:ns2="http://schemas.xmlsoap.org/ws/2005/02/rm"
            xmlns:ns3="http://schemas.microsoft.com/ws/2006/05/rm"
            xmlns:ns4="http://www.w3.org/2005/08/addressing"
            xmlns:ns5="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ns6="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <ns2:Identifier>uuid:176a6212-5c0d-480c-b31d-d026034a68b1</ns2:Identifier>
            <ns2:Accept>
                <ns2:AcksTo>
                    <ns4:Address>http://localhost:4040/HelloWebService/HelloService</ns4:Address>
                </ns2:AcksTo>
            </ns2:Accept>
        </ns2:CreateSequenceResponse>
    </S:Body>
</S:Envelope>
Figure-1.60: SOAP response message of the first exchange

Figure-1.61: WS Monitor of the second exchange of SOAP request/response messages

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Header>
        <To xmlns="http://www.w3.org/2005/08/addressing">http://localhost:4040/HelloWebService/HelloService</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:037a53b5-72c2-40ab-aa20-7f31344f4847</MessageID>
    </S:Header>
    <S:Body>
        <ns2:CreateSequence
            xmlns:ns2="http://schemas.xmlsoap.org/ws/2005/02/rm"
            xmlns:ns3="http://schemas.microsoft.com/ws/2006/05/rm"
            xmlns:ns4="http://www.w3.org/2005/08/addressing"
            xmlns:ns5="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ns6="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <ns2:AcksTo>
                <ns4:Address>http://www.w3.org/2005/08/addressing/anonymous</ns4:Address>
            </ns2:AcksTo>
            <ns2:Offer>
                <ns2:Identifier>uuid:3324939e-5798-4d30-9c9b-a90013fe7aff</ns2:Identifier>
            </ns2:Offer>
        </ns2:CreateSequence>
    </S:Body>
</S:Envelope>
Figure-1.62: SOAP request message of the second exchange

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Header>
        <To xmlns="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing/anonymous</To>
        <Action xmlns="http://www.w3.org/2005/08/addressing">http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequenceResponse</Action>
        <MessageID xmlns="http://www.w3.org/2005/08/addressing">uuid:c5255b96-fbeb-4937-92ad-debfa4735390</MessageID>
        <RelatesTo xmlns="http://www.w3.org/2005/08/addressing">uuid:037a53b5-72c2-40ab-aa20-7f31344f4847</RelatesTo>
    </S:Header>
    <S:Body>
        <ns2:CreateSequenceResponse
            xmlns:ns2="http://schemas.xmlsoap.org/ws/2005/02/rm"
            xmlns:ns3="http://schemas.microsoft.com/ws/2006/05/rm"
            xmlns:ns4="http://www.w3.org/2005/08/addressing"
            xmlns:ns5="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ns6="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <ns2:Identifier>uuid:176a6212-5c0d-480c-b31d-d026034a68b1</ns2:Identifier>
            <ns2:Accept>
                <ns2:AcksTo>
                    <ns4:Address>http://localhost:4040/HelloWebService/HelloService</ns4:Address>
                </ns2:AcksTo>
            </ns2:Accept>
        </ns2:CreateSequenceResponse>
    </S:Body>
</S:Envelope>
Figure-1.63: SOAP response message of the second exchange

                                                                                                                        return to top of the exercise


(1.6) Rebuild "HelloWebServiceWebClientWSMonitor"  Web-based client


In this step, you are going to rebuild HelloWebServiceWebClientWSMonitor using reliable messaging.

1. Rebuild the HelloWebServiceWebClientWSMonitor project using new WSDL (with reliable messaging).
2. Build and run the client.
3. Observe that the WSMonitor captures two exchanges of SOAP messages.  The first exchange of SOAP request/response messages establishes reliable messaging while the second exchange of SOAP request/response messages contains actual data.

                                                                                                                        return to top of the exercise



Solution


The solutions are provided as ready-to-open NetBeans projects as described below.

Summary

In this exercise,  you have built and deployed a simple wsit Web service using Reliable messaging. 

                                                                                                                        return to the top


Exercise 2: Build and run "HelloWebService" Web Service with Security


In this exercise, you are going to build a simple "HelloWebService" Web service and its client by using Security feature of the WSIT.
  1. Configure "HelloWebService" Web service to use Security
  2. Rebuild "HelloWebServiceWebClientWSMonitor" Web client to use Security

(2.1) Configure "HelloWebService" Web service to use Security


1. Open Edit Web Service Attributes editor window.

2. Set Security attributes.

Figure-2.11: Configure security

3. Redeploy the Web service.

                                                                                                                        return to top of the exercise

(2.2) Rebuild "HelloWebServiceWebClientWSMonitor" Web client to use security


0.  Start the WS Monitor (if you have not done so yet).

1. Rebuild the HelloWebServiceWebClientWSMonitor project using new WSDL (with reliable messaging).
2. Configure client with security.


Figure-2.12: Edit Web Service Attributes for client


Figure-2.13: Configure security for client

3. Build and run the client.

Figure-2.20: Display of the result

4. Observe that the WS Monitor captures an exchanges of SOAP messages.  (Figure-2.21 below)


Figure-2.21: Capture SOAP traffic

Trouble-shooting: If you experience "Invalid Username Password Pair" as shown in Figure-2.22 below, it is because the default username "wsitUser" and password "changeit" pair was not set to the file security realm of the GlassFish.  (It should be set automatically as part of the NetBeans/GlassFish installation.)  Add "wsitUser"/"changeit" username/password pair as described here.



5. Study the SOAP request (Figure-2.22 below) and response (Figure-2.23 below)  messages with security.

?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
    xmlns:exc14n="http://www.w3.org/2001/10/xml-exc-c14n#"
    xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
    <S:Header>
        <To wsu:Id="5006" xmlns="http://www.w3.org/2005/08/addressing">http://localhost:4040/HelloWebService/HelloService</To>
        <Action wsu:Id="5005" xmlns="http://www.w3.org/2005/08/addressing">http://mypackage/Hello/sayHelloRequest</Action>
        <ReplyTo wsu:Id="5004" xmlns="http://www.w3.org/2005/08/addressing">
            <Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
        </ReplyTo>
        <MessageID wsu:Id="5003" xmlns="http://www.w3.org/2005/08/addressing">uuid:1cfbf8f9-5a57-4f60-b937-4f949add9d78</MessageID>
        <wsse:Security S:mustUnderstand="1">
            <wsu:Timestamp wsu:Id="3" xmlns:ns10="http://www.w3.org/2003/05/soap-envelope">
                <wsu:Created>2008-01-14T19:24:35Z</wsu:Created>
                <wsu:Expires>2008-01-14T19:29:35Z</wsu:Expires>
            </wsu:Timestamp>
            <xenc:EncryptedKey Id="5002" xmlns:ns10="http://www.w3.org/2003/05/soap-envelope">
                <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"/>
                <ds:KeyInfo
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="keyInfo">
                    <wsse:SecurityTokenReference>
                        <wsse:KeyIdentifier
                            EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509SubjectKeyIdentifier">dVE29ysyFW/iD1la3ddePzM6IWo=</wsse:KeyIdentifier>
                    </wsse:SecurityTokenReference>
                </ds:KeyInfo>
                <xenc:CipherData>
                    <xenc:CipherValue>GoeW6QsubOkrkrCC+SE+J72hNYUij7xF45H5hLoP7F/MSdlujTvmDc86Pash9f2OM1HG6SGHIbExe30mzqwrmiiFvp+VRGpuMZf7Sh7rzqYRUK9lqNs/nRPn3nxC6BpJycL6xfRNkEpApu9eY9v0X6giAg6x9bnXYGoq+RWhppw=</xenc:CipherValue>
                </xenc:CipherData>
            </xenc:EncryptedKey>
            <xenc:ReferenceList xmlns="" xmlns:ns16="http://www.w3.org/2003/05/soap-envelope">
                <xenc:DataReference URI="#5008"/>
                <xenc:DataReference URI="#5009"/>
            </xenc:ReferenceList>
            <xenc:EncryptedData Id="5009"
                Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns:ns10="http://www.w3.org/2003/05/soap-envelope">
                <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
                <ds:KeyInfo
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="keyInfo">
                    <wsse:SecurityTokenReference>
                        <wsse:Reference URI="#5002" ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey"/>
                    </wsse:SecurityTokenReference>
                </ds:KeyInfo>
                <xenc:CipherData>
                    <xenc:CipherValue>5G8Ua2OmJB4xbUSzHJ3SIOS2zKp4KmkAPVbIAmDG2k0Jcbb2mUXodc7XHP/ys1tq0GXuY3CiTW8PHuwWMM7EnMUTq97tt/bN59Xpw523lutrZau7OBFMwUvJahzG0Q5FdIdKQPpDMAbdK81/n8gFzZfK9d6xWmm/Lhc3thv9xYVmyKpwfafoQTfssqKH/I7YisQ/S0UWCbhnbAimNPQ5BbK8eaxeud2Zl+QG47eznH8It4GiWrDHojffu25c/YHcb+NalV4q9kX51+lgbPqzlsGbLQG8tOEDDtEM3Wu3X1XWVCMikc7gtc6DGfuEp5am6BGAQlX0wMArNnwHuoOgIGL37hrVRdJDxGsiol/ucoYRyhZmcFklTQRQhSgNs2bK8q20r2+mMGSjWr60MMaeXfAlyvUfjndKBnjm1/739Stk1BQueXIoJONDNM7qUF8l6oY92tRb3ki8fyzBEIAAEGy23A0WHRQp6qOmkX6IXYV0uunF1VWFjDCBi/gmqjHU</xenc:CipherValue>
                </xenc:CipherData>
            </xenc:EncryptedData>
            <ds:Signature Id="1" xmlns:ns10="http://www.w3.org/2003/05/soap-envelope">
                <ds:SignedInfo>
                    <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                        <exc14n:InclusiveNamespaces PrefixList="wsse S"/>
                    </ds:CanonicalizationMethod>
                    <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#hmac-sha1"/>
                    <ds:Reference URI="#5003">
                        <ds:Transforms>
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <exc14n:InclusiveNamespaces PrefixList="S"/>
                            </ds:Transform>
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                        <ds:DigestValue>cdMf9xf0QMxZxzBzuM2qqJIlj7c=</ds:DigestValue>
                    </ds:Reference>
                    <ds:Reference URI="#5004">
                        <ds:Transforms>
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <exc14n:InclusiveNamespaces PrefixList="S"/>
                            </ds:Transform>
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                        <ds:DigestValue>WdIQVaynkwqFa/LTJNuUmAHYF+k=</ds:DigestValue>
                    </ds:Reference>
                    <ds:Reference URI="#5005">
                        <ds:Transforms>
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <exc14n:InclusiveNamespaces PrefixList="S"/>
                            </ds:Transform>
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                        <ds:DigestValue>14EHWkiaAKzC7TuUCYpgzOds9cw=</ds:DigestValue>
                    </ds:Reference>
                    <ds:Reference URI="#5006">
                        <ds:Transforms>
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <exc14n:InclusiveNamespaces PrefixList="S"/>
                            </ds:Transform>
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                        <ds:DigestValue>ElipJn3BfXZo+fejFI+obkD9xkE=</ds:DigestValue>
                    </ds:Reference>
                    <ds:Reference URI="#5007">
                        <ds:Transforms>
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <exc14n:InclusiveNamespaces PrefixList="S"/>
                            </ds:Transform>
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                        <ds:DigestValue>W1J188g6XCl3OHHq1pBdGqD6nOY=</ds:DigestValue>
                    </ds:Reference>
                    <ds:Reference URI="#3">
                        <ds:Transforms>
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <exc14n:InclusiveNamespaces PrefixList="wsu wsse S"/>
                            </ds:Transform>
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                        <ds:DigestValue>jltiYqBfUgDl/eDqh22fllmy2eE=</ds:DigestValue>
                    </ds:Reference>
                    <ds:Reference URI="#94c6e56a-3c95-4ac2-971e-89931d1171e8">
                        <ds:Transforms>
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <exc14n:InclusiveNamespaces PrefixList="wsu wsse S"/>
                            </ds:Transform>
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                        <ds:DigestValue>yfj35ZC1YqvePymWo2cMQZ6HpD0=</ds:DigestValue>
                    </ds:Reference>
                </ds:SignedInfo>
                <ds:SignatureValue>XJ6OBH7KLw0T9iKdSP5SAMVskl8=</ds:SignatureValue>
                <ds:KeyInfo>
                    <wsse:SecurityTokenReference wsu:Id="1d90c38c-a044-4a6e-a640-9bc653fda6b1">
                        <wsse:Reference URI="#5002" ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey"/>
                    </wsse:SecurityTokenReference>
                </ds:KeyInfo>
            </ds:Signature>
        </wsse:Security>
    </S:Header>
    <S:Body wsu:Id="5007">
        <xenc:EncryptedData Id="5008"
            Type="http://www.w3.org/2001/04/xmlenc#Content" xmlns:ns10="http://www.w3.org/2003/05/soap-envelope">
            <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
            <ds:KeyInfo
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="keyInfo">
                <wsse:SecurityTokenReference>
                    <wsse:Reference URI="#5002" ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey"/>
                </wsse:SecurityTokenReference>
            </ds:KeyInfo>
            <xenc:CipherData>
                <xenc:CipherValue>BFTxcVhAvYwOHedRy7aQl7QX0OA7Lkfj6aCjCWTGadF3oMvKBArgMgt6JCNnWrxgrrLCuX2Th8vhtZqplUhWoTv0wbs45FcenGHtzgS0AEuvInZRiSXfsVMZTZODBG27F7dAZ0YD4syi/L3hdtAhPQ==</xenc:CipherValue>
            </xenc:CipherData>
        </xenc:EncryptedData>
    </S:Body>
</S:Envelope>
Figure-2.23: SOAP request message with security

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
    xmlns:exc14n="http://www.w3.org/2001/10/xml-exc-c14n#"
    xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
    <S:Header>
        <To wsu:Id="5005" xmlns="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing/anonymous</To>
        <Action wsu:Id="5003" xmlns="http://www.w3.org/2005/08/addressing">http://mypackage/Hello/sayHelloResponse</Action>
        <MessageID wsu:Id="5002" xmlns="http://www.w3.org/2005/08/addressing">uuid:63def426-7169-42ab-841c-ea96368f77bd</MessageID>
        <RelatesTo wsu:Id="5004" xmlns="http://www.w3.org/2005/08/addressing">uuid:1cfbf8f9-5a57-4f60-b937-4f949add9d78</RelatesTo>
        <wsse:Security S:mustUnderstand="1">
            <wsu:Timestamp wsu:Id="3" xmlns:ns10="http://www.w3.org/2003/05/soap-envelope">
                <wsu:Created>2008-01-14T19:24:36Z</wsu:Created>
                <wsu:Expires>2008-01-14T19:29:36Z</wsu:Expires>
            </wsu:Timestamp>
            <xenc:ReferenceList xmlns="" xmlns:ns16="http://www.w3.org/2003/05/soap-envelope">
                <xenc:DataReference URI="#5007"/>
            </xenc:ReferenceList>
            <ds:Signature Id="1" xmlns:ns10="http://www.w3.org/2003/05/soap-envelope">
                <ds:SignedInfo>
                    <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                        <exc14n:InclusiveNamespaces PrefixList="wsse S"/>
                    </ds:CanonicalizationMethod>
                    <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#hmac-sha1"/>
                    <ds:Reference URI="#5002">
                        <ds:Transforms>
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <exc14n:InclusiveNamespaces PrefixList="S"/>
                            </ds:Transform>
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                        <ds:DigestValue>MZWFrz8j3X5elzP90TylQkV7Alo=</ds:DigestValue>
                    </ds:Reference>
                    <ds:Reference URI="#5003">
                        <ds:Transforms>
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <exc14n:InclusiveNamespaces PrefixList="S"/>
                            </ds:Transform>
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                        <ds:DigestValue>8JNcDdllDGDx3XmI1P73S89zJ9A=</ds:DigestValue>
                    </ds:Reference>
                    <ds:Reference URI="#5004">
                        <ds:Transforms>
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <exc14n:InclusiveNamespaces PrefixList="S"/>
                            </ds:Transform>
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                        <ds:DigestValue>trH8Fv6EnNLIsjrBwJCRT50aL0A=</ds:DigestValue>
                    </ds:Reference>
                    <ds:Reference URI="#5005">
                        <ds:Transforms>
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <exc14n:InclusiveNamespaces PrefixList="S"/>
                            </ds:Transform>
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                        <ds:DigestValue>26KDy9ndyfdX/w8zv2re2dt1wsc=</ds:DigestValue>
                    </ds:Reference>
                    <ds:Reference URI="#5006">
                        <ds:Transforms>
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <exc14n:InclusiveNamespaces PrefixList="S"/>
                            </ds:Transform>
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                        <ds:DigestValue>eh5lyt+tkQtH+MHf0u9wlSuTWB4=</ds:DigestValue>
                    </ds:Reference>
                    <ds:Reference URI="#3">
                        <ds:Transforms>
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <exc14n:InclusiveNamespaces PrefixList="wsu wsse S"/>
                            </ds:Transform>
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                        <ds:DigestValue>WmjD41MZGoxol71lue8b15k6uWI=</ds:DigestValue>
                    </ds:Reference>
                </ds:SignedInfo>
                <ds:SignatureValue>yJZ7Jd8xr8LK6NRQN2yIKhfraaA=</ds:SignatureValue>
                <ds:KeyInfo>
                    <wsse:SecurityTokenReference>
                        <wsse:KeyIdentifier
                            EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKeySHA1">rTsBkK4lIc17V6g9FrG70Hdn1HU=</wsse:KeyIdentifier>
                    </wsse:SecurityTokenReference>
                </ds:KeyInfo>
            </ds:Signature>
        </wsse:Security>
    </S:Header>
    <S:Body wsu:Id="5006">
        <xenc:EncryptedData Id="5007"
            Type="http://www.w3.org/2001/04/xmlenc#Content" xmlns:ns10="http://www.w3.org/2003/05/soap-envelope">
            <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
            <ds:KeyInfo
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="keyInfo">
                <wsse:SecurityTokenReference>
                    <wsse:KeyIdentifier
                        EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKeySHA1">rTsBkK4lIc17V6g9FrG70Hdn1HU=</wsse:KeyIdentifier>
                </wsse:SecurityTokenReference>
            </ds:KeyInfo>
            <xenc:CipherData>
                <xenc:CipherValue>G55eGG4/kCq7ZOD/zj0JBiBnQzSiooJgWLCcAg9v28vLmut8kdQsJ2NPjN7vaJTqJNFzoI7XmqcLZ9iXkkHhOM111BUKGRmQlAE/z9wjgA3H2xi2QqA6YGYTc5AtXIdyaxycafd2HhVEdfeTSW8be+oy064qXE51iwJXd9MSojc=</xenc:CipherValue>
            </xenc:CipherData>
        </xenc:EncryptedData>
    </S:Body>
</S:Envelope>
Figure-2.24: SOAP response message with security

                                                                                                                        return to top of the exercise

Solution


Summary


In this exercise,  you have built and deployed a Web service and its client with security. 


Exercise 3: Build and run "HelloWebService" Web Service with Message Optimization (MTOM)


In this exercise, you are going to build a simple "HelloWebService" Web service by using Message Optimization (MTOM) feature of the WSIT.
  1. Configure "HelloWebService" Web service to use Message Optimization
  2. Rebuild "HelloWebServiceWebClientWSMonitor" Web client to use Message Optimization

(3.1) Configure "HelloWebService" Web service to use Message Optimization


1. Open Edit Web Service Attributes editor window.

2. Set Security attributes.

Figure-3.11: Conifgure MTOM

3. Redeploy the Web service.
<?xml version="1.0" encoding="UTF-8"?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.2-hudson-182-RC1. --><!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.2-hudson-182-RC1. --><definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://mypackage/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://mypackage/" name="HelloService">
    <wsp:UsingPolicy></wsp:UsingPolicy>
    <wsp:Policy wsu:Id="HelloPortBindingPolicy">
        <wsp:ExactlyOne>
            <wsp:All>
                <ns1:OptimizedMimeSerialization xmlns:ns1="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization"></ns1:OptimizedMimeSerialization>
            </wsp:All>
        </wsp:ExactlyOne>
    </wsp:Policy>
    <types>
        <xsd:schema>
            <xsd:import namespace="http://mypackage/" schemaLocation="http://localhost:8080/HelloWebService/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">
        <wsp:PolicyReference URI="#HelloPortBindingPolicy"></wsp:PolicyReference>
        <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/HelloWebService/HelloService"></soap:address>
        </port>
    </service>
</definitions>
Figure-3.12: WSDL document with MTOM configuration

                                                                                                                        return to top of the exercise



(3.2) Rebuild "HelloWebServiceWebClientWSMonitor" Web client to use Message Optimization


0.  Start the WS Monitor (if you have not done so yet).

1. Rebuild the HelloWebServiceWebClientWSMonitor project using new WSDL (with Message Optimization).
2. Build and run the client.
3. Observe the captured HTTP Headers.  Note that the Content-Type is now set to multipart/related;... (Figure-3.21 below)


Figure-3.21: HTTP Headders

4. Observe that the WS Monitor captures an exchanges of SOAP messages.  (Figure-3.22 below)


Figure-3.22: Captured SOAP mesages

--uuid:0663772b-6294-4e1b-8d5f-243839435938
Content-Id: <rootpart*0663772b-6294-4e1b-8d5f-243839435938@example.jaxws.sun.com>
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: binary

<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <ns2:sayHello xmlns:ns2="http://mypackage/">
             <arg0>Sang Shin</arg0>
        </ns2:sayHello>
    </S:Body>
</S:Envelope>
--uuid:0663772b-6294-4e1b-8d5f-243839435938--
Figure-3.23: SOAP request message with indentation

--uuid:9ee30d23-5c34-4677-a609-f489afd9c487
Content-Id: <rootpart*9ee30d23-5c34-4677-a609-f489afd9c487@example.jaxws.sun.com>
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: binary

<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
        <ns2:sayHelloResponse xmlns:ns2="http://mypackage/">
               <return>Hello Sang Shin!</ret