Web Services Interoperability Technology (WSIT)

Sang Shin 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).  The Web service transaction is covered in another hands-on lab.

Expected duration: 90 minutes


Software Needed

Before you begin, you need to install the software mentioned in the class website on your computer.  You also need download and unzip the hands-on lab zip file below (if you have not done so yet).


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

Note: As a default, the WSMonitor assumes the service is deployed on port number 8080.  If your service is deployed on a port other than 8080, you can change the ../etc/config.xml file and then run the wsmonitor with the modified configuration file. For example


Trouble-shooting:  If you experience a problem in running wsmonitor, please the JAVA_HOME environment variable as following and then run wsmonitor.


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

                                                                                                                        return to top of the exercise


(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

                                                                                                                        return to top of the exercise



(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.
This setting ensures that the service sends an acknowledgement to the clients for each message that is delivered, thus enabling clients to recognize message delivery failures and to retransmit the message. This capability makes the web service a "reliable" web service.


Figure-1.43: Configure Reliability

3. Redeploy the Web service.


4. Test the Web service.

Figure-1.44: Reliable messaging

Trouble-shooting: If you experience the following problem, undeploy all the Web applications first (Select service tab, expand Servers->GlassFish 2.1->Applications->Web Applications and select all apps and right click and select Undeploy) and then try it again.



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

                                                                                                                        return to top of the exercise


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


1. 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

2. Add METRO 1.4 library to the project.





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/...</Action>
        <MessageID xmlns="http://www.w3.org/2005/08/addressing">uuid:...</MessageID>
        <RelatesTo xmlns="http://www.w3.org/2005/08/addressing">uuid:...</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/...</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

Trouble-shooting: If you see the following symptom, it is because the client project was not configured with METRO library as described above.

hy

                                                                                                                        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. Add "wsitUser"/"changeit" username/password to the GlassFish security realm
  2. Configure "HelloWebService" Web service to use Security
  3. Rebuild "HelloWebServiceWebClientWSMonitor" Web client to use Security

(2.0) Add "wsitUse"/"changeit" username/password to the GlassFish security realm


Make sure the "wsitUser"/"changeit" username/password pair has been set up.    If it is not set up for some reason, you can manually add it as described here.

1. Start Admin console of the GlassFish V2.


2. Open Manage Users page of the file security realm

Figure-10.01: Manage Users

3. Add a new user "wsitUser"/"changeit"

Figure-10.02: Create a new user

Enter UserId and Password

4. Restart GlassFish App server.

                                                                                                                        return to top of the exercise


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


1. Open Edit Web Service Attributes editor window.

2. Set Security attributes.
The Username Authentication with Symmetric Key mechanism protects your application for integrity and confidentiality. Symmetric key cryptography relies on a single, shared secret key that is used to both sign and encrypt a message. Symmetric keys are usually faster than public key cryptography.

For this mechanism, the client does not possess any certificate/key of his own, but instead sends its username/password for authentication. The client shares a secret key with the server. The shared, symmetric key is generated at runtime and encrypted using the service's certificate. The client must specify the alias in the truststore by identifying the server's certificate alias. The other security mechanisms are explained later in this tutorial.

Use Development Defaults. Select this option to import certificates into the GlassFish keystore and truststore, so that they can be used immediately for development. Because the default certificates are not in an appropriate format to be used in this context, this import is done for you, so that you do not need to do this manually yourself.  In addition to importing certificats, a default user is created in the "file" realm, with username "wsitUser". In a production environment, you will probably want to provide your own certificates and user settings, however, in a development environment you may find these defaults useful.
 

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 security).


2. Configure client with security.


Figure-2.12: Edit Web Service Attributes for client


Figure-2.13: Configure security for client

A new file is added to the project. To view the WSIT configuration file, expand Web Pages→WEB-INF, then double-click the file wsit-org.me.calculator.CalculatorWS.xml. This file contains the security elements within wsp:Policy tags.

3. Build and run the client.

Figure-2.20: Display of the result


Trubleshooting: If things do not work, please make sure the following:


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.



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


Figure-2.21: Capture SOAP traffic


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="..."               ValueType="http://docs.oasis-open.org/wss/2004/01/...">
                                           dVE29ysyFW/iD1la3ddePzM6IWo=</wsse:KeyIdentifier>

                    </wsse:SecurityTokenReference>
                </ds:KeyInfo>
                <xenc:CipherData>
                    <xenc:CipherValue>...</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>92tRb3m...kX6IXYV0uunF1VWFjDCBi/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>
               Z0YD4syi/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:...</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="..."
                           ValueType="...">r..=</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="..."
                       ValueType="...">rTsBk...HU=</wsse:KeyIdentifier>

                </wsse:SecurityTokenReference>
            </ds:KeyInfo>
            <xenc:CipherData>
                <xenc:CipherValue>G55e...MSojc=</xenc:CipherValue>
            </xenc:CipherData>
        </xenc:EncryptedData>
    </S:Body>
</S:Envelope>
Figure-2.24: SOAP response message with security

6. Study the WSDL document.

<?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>
       
        <ns3:SignedSupportingTokens xmlns:ns3="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
          <wsp:Policy>
            <wsp:ExactlyOne>
              <wsp:All>
                <ns3:UsernameToken ns3:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
                  <wsp:Policy>
                    <wsp:ExactlyOne>
                      <wsp:All>
                        <ns3:WssUsernameToken10></ns3:WssUsernameToken10>
                      </wsp:All>
                    </wsp:ExactlyOne>
                  </wsp:Policy>
                </ns3:UsernameToken>
              </wsp:All>
            </wsp:ExactlyOne>
          </wsp:Policy>
        </ns3:SignedSupportingTokens>
        <ns4:SymmetricBinding xmlns:ns4="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
          <wsp:Policy>
            <wsp:ExactlyOne>
              <wsp:All>
                <ns4:AlgorithmSuite>
                  <wsp:Policy>
                    <wsp:ExactlyOne>
                      <wsp:All>
                        <ns4:Basic128></ns4:Basic128>
                      </wsp:All>
                    </wsp:ExactlyOne>
                  </wsp:Policy>
                </ns4:AlgorithmSuite>
                <ns4:IncludeTimestamp></ns4:IncludeTimestamp>
                <ns4:Layout>
                  <wsp:Policy>
                    <wsp:ExactlyOne>
                      <wsp:All>
                        <ns4:Strict></ns4:Strict>
                      </wsp:All>
                    </wsp:ExactlyOne>
                  </wsp:Policy>
                </ns4:Layout>
                <ns4:OnlySignEntireHeadersAndBody></ns4:OnlySignEntireHeadersAndBody>
                <ns4:ProtectionToken>
                  <wsp:Policy>
                    <wsp:ExactlyOne>
                      <wsp:All>
                        <ns4:X509Token ns4:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
                          <wsp:Policy>
                            <wsp:ExactlyOne>
                              <wsp:All>
                                <ns4:WssX509V3Token10></ns4:WssX509V3Token10>
                              </wsp:All>
                            </wsp:ExactlyOne>
                          </wsp:Policy>
                        </ns4:X509Token>
                      </wsp:All>
                    </wsp:ExactlyOne>
                  </wsp:Policy>
                </ns4:ProtectionToken>
              </wsp:All>
            </wsp:ExactlyOne>
          </wsp:Policy>
        </ns4:SymmetricBinding>
        <ns5:Wss11 xmlns:ns5="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
          <wsp:Policy>
            <wsp:ExactlyOne>
              <wsp:All>
                <ns5:MustSupportRefEncryptedKey></ns5:MustSupportRefEncryptedKey>
                <ns5:MustSupportRefIssuerSerial></ns5:MustSupportRefIssuerSerial>
                <ns5:MustSupportRefKeyIdentifier></ns5:MustSupportRefKeyIdentifier>
                <ns5:MustSupportRefThumbprint></ns5:MustSupportRefThumbprint>
              </wsp:All>
            </wsp:ExactlyOne>
          </wsp:Policy>
        </ns5:Wss11>
        <ns6:UsingAddressing xmlns:ns6="http://www.w3.org/2006/05/addressing/wsdl"></ns6:UsingAddressing>
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>
  <wsp:Policy wsu:Id="HelloPortBinding_sayHello_Policy">
    <wsp:ExactlyOne>
      <wsp:All>
        <ns7:ATAlwaysCapability xmlns:ns7="http://schemas.xmlsoap.org/ws/2004/10/wsat"></ns7:ATAlwaysCapability>
        <ns8:ATAssertion xmlns:ns8="http://schemas.xmlsoap.org/ws/2004/10/wsat" wsp:Optional="true"></ns8:ATAssertion>
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>
  <wsp:Policy wsu:Id="HelloPortBinding_sayHello_Input_Policy">
    <wsp:ExactlyOne>
      <wsp:All>
        <ns9:EncryptedParts xmlns:ns9="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
          <ns9:Body></ns9:Body>
        </ns9:EncryptedParts>
        <ns10:SignedParts xmlns:ns10="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
          <ns10:Body></ns10:Body>
          <ns10:Header Namespace="http://www.w3.org/2005/08/addressing" Name="ReplyTo"></ns10:Header>
          <ns10:Header Namespace="http://www.w3.org/2005/08/addressing" Name="To"></ns10:Header>
          <ns10:Header Namespace="http://www.w3.org/2005/08/addressing" Name="From"></ns10:Header>
          <ns10:Header Namespace="http://www.w3.org/2005/08/addressing" Name="MessageID"></ns10:Header>
          <ns10:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing"></ns10:Header>
          <ns10:Header Namespace="http://www.w3.org/2005/08/addressing" Name="Action"></ns10:Header>
          <ns10:Header Namespace="http://www.w3.org/2005/08/addressing" Name="RelatesTo"></ns10:Header>
          <ns10:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="AckRequested"></ns10:Header>
          <ns10:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="Sequence"></ns10:Header>
          <ns10:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="SequenceAcknowledgement"></ns10:Header>
        </ns10:SignedParts>
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>
  <wsp:Policy wsu:Id="HelloPortBinding_sayHello_Output_Policy">
    <wsp:ExactlyOne>
      <wsp:All>
        <ns11:EncryptedParts xmlns:ns11="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
          <ns11:Body></ns11:Body>
        </ns11:EncryptedParts>
        <ns12:SignedParts xmlns:ns12="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
          <ns12:Body></ns12:Body>
          <ns12:Header Namespace="http://www.w3.org/2005/08/addressing" Name="ReplyTo"></ns12:Header>
          <ns12:Header Namespace="http://www.w3.org/2005/08/addressing" Name="To"></ns12:Header>
          <ns12:Header Namespace="http://www.w3.org/2005/08/addressing" Name="From"></ns12:Header>
          <ns12:Header Namespace="http://www.w3.org/2005/08/addressing" Name="MessageID"></ns12:Header>
          <ns12:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing"></ns12:Header>
          <ns12:Header Namespace="http://www.w3.org/2005/08/addressing" Name="Action"></ns12:Header>
          <ns12:Header Namespace="http://www.w3.org/2005/08/addressing" Name="RelatesTo"></ns12:Header>
          <ns12:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="AckRequested"></ns12:Header>
          <ns12:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="Sequence"></ns12:Header>
          <ns12:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="SequenceAcknowledgement"></ns12:Header>
        </ns12:SignedParts>
      </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">
      <wsp:PolicyReference URI="#HelloPortBinding_sayHello_Policy"></wsp:PolicyReference>
      <soap:operation soapAction=""></soap:operation>
      <input>
        <wsp:PolicyReference URI="#HelloPortBinding_sayHello_Input_Policy"></wsp:PolicyReference>
        <soap:body use="literal"></soap:body>
      </input>
      <output>
        <wsp:PolicyReference URI="#HelloPortBinding_sayHello_Output_Policy"></wsp:PolicyReference>
        <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>
WSDL document

                                                                                                                        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.3.3-hudson-757-SNAPSHOT. --><!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.3.3-hudson-757-SNAPSHOT. -->
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 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">
    <ns1:Policy xmlns:ns1="http://schemas.xmlsoap.org/ws/2004/09/policy" wsu:Id="HelloPortBindingPolicy">
        <ns1:ExactlyOne>
            <ns1:All>
                <ns2:OptimizedMimeSerialization xmlns:ns2="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization"></ns2:OptimizedMimeSerialization>
            </ns1:All>
        </ns1:ExactlyOne>
    </ns1: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">
        <ns3:PolicyReference xmlns:ns3="http://schemas.xmlsoap.org/ws/2004/09/policy" URI="#HelloPortBindingPolicy"></ns3: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!</return>
        </ns2:sayHelloResponse>
   </S:Body>
</S:Envelope>
--uuid:9ee30d23-5c34-4677-a609-f489afd9c487--
Figure-3.24: SOAP response message with indentation


Solution


Summary


In this exercise,  you have built and deployed a Web service and its client with Message Optimization(MTOM). 



Homework Exercise (for people who are taking Sang Shin's "Web Services & SOA Programming online course")


1. The homework is to rebuild CaculatorApp project and CaculatorClientApp  projects to use Reliable messaging.  The CaculatorApp project and CaculatorClientApp  projects are available under <LAB_UNZIPPED_DIRECTORY>/wswsit/samples directory for convenience. 

I am waiving security part of the homework since there seems to be some problem in doing the security part of the hands-on lan exercise 2.   Sang Shin, Sep. 14th, 2008.  Just do the reliable messaging part of the homework.

2. Send the following files to  webserviceshomework@javapassion.com with Subject as WebServices-wswsit.