<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../../web/sc2html.xsl" title="scenario"?>
<scenario xmlns="http://www.wstf.org">

 <metadata>
  <number>sc009</number>
  <title>Purchase Order Service</title>
  <date>2008/11/19</date>
  <status>Published</status>
 </metadata>

 <abstract>
  This scenario illustrates how Web services can be used to solve the 
  problems of asynchronous interaction, request/response correlation, 
  status notification, with the ability to provide ongoing status on 
  the transaction. Use of long running web services provides an enterprise 
  the ability to expose legacy systems to the internet / intranet and 
  invoke interoperable services. The resultant value to the enterprise 
  is increased flexibility and responsiveness to addressing 
  business challenges.
  <p/>
  It is expected that other scenarios will 
  build on this scenario to add things like QoS. This scenario defines a 
  service that allows customers to create, update, and cancel purchase 
  orders. Once created, the purchase orders are acted on, and if valid and 
  approved, proceed through various stages before completion. The PO submitter 
  can query the status of the PO at anytime. The PO submitter may also 
  elect to receive status updates as the PO goes through various stages. 
  To permit the timely implementation of this scenario, the application 
  logic and business rules have been highly simplified in relation to 
  real-world processes of this type. Nevertheless, this scenario 
  illustrates how web services can be used to solve the problems of 
  asynchronous interaction, request/response correlation, status 
  notification, etc.
  <p/>
  It is often desirable to enable resources to be access in a variety of 
  ways to allow for the data to be reused for multiple purposes. For example, 
  in this scenarios while some of the interactions between the customer and 
  the supplier should require some level of Quality of Service (QoS) to ensure 
  proper delivery of messages (e.g. adding WS-ReliableMessaging for the 
  delivery of the CreatePO message), some interactions are less critical.  
  One example might be a dashboard type of webpage that is used to display 
  the status of outstanding purchase orders. For this purpose the use of a 
  REST style of interaction might be sufficient as the interactions are 
  less critical and are "read-only" in nature. This scenario includes an 
  optional variant that demonstrates how WS*/SOAP as well as REST/HTTP 
  interactions can be used in a complimentary manner - thus allowing the 
  customer the option of choosing the appropriate technology for their needs.
 </abstract>

 <section title="Dependencies">
  <scope>
   <technology name="SOAP 1.1"
               url="http://www.w3.org/TR/2000/NOTE-SOAP-20000508/"/>
   <technology name="WS-Addressing 1.0 - Core" 
               url="http://www.w3.org/TR/2006/REC-ws-addr-core-20060509/"/>
   <technology name="WS-Addressing 1.0 - SOAP Binding" 
               url="http://www.w3.org/TR/2006/REC-ws-addr-soap-20060509/"/>
   <technology name="WS-Addressing 1.0 - Metadata" 
               url="http://www.w3.org/TR/2007/REC-ws-addr-metadata-20070904/"/>
   <technology name="WSDL 1.1"
               url="http://www.w3.org/TR/2001/NOTE-wsdl-20010315"/>
   <technology name="WS-Policy 1.5"
               url="http://www.w3.org/TR/2007/REC-ws-policy-20070904/"/>
  </scope>

  <namespaces>
   <namespace prefix="soapenv" ns="http://schemas.xmlsoap.org/soap/envelope/"
                               name="SOAP 1.1"/>
   <namespace prefix="xs" ns="http://www.w3.org/2001/XMLSchema"
                           name="XML Schema"/>
   <namespace prefix="wsa" ns="http://www.w3.org/2005/08/addressing"
                           name="WS-Addressing"/>
   <namespace prefix="sc009" ns="http://www.wstf.org/docs/scenarios/sc009"
                           name="SC009 (this scenario)"/>
  </namespaces>

  <subheading title="Preconditions">
   The tests in this scenario require the support for WSDL 1.1, and
   WS-Addressing 1.0. To simplify implementation only one version of
   SOAP, SOAP 1.1, is supported in this scenario. Clients in this
   scenario must be addressable - or use a mechanism such as WS-MakeConnection
   to allow asynchronous responses to be delivered.
  </subheading>

  <terms>
   <term term="Addressable Client">
    A client that is capable of accepting connections on a network endpoint.
   </term>
   <term term="Asynchronous Request-Response Message Exchange">
    A SOAP message exchange in which a requester sends a SOAP message to a 
    service and receives a response message. "Asynchronous" in this context 
    refers to the manner in which the underlying transport protocol is used 
    to carry the request and response messages. The response message is 
    sent over a separate connection that is initiated by the service to 
    the client (a "callback").
   </term>
   <term term="One-way Message">
    An application SOAP message for which no application SOAP response is 
    expected.
   </term>
   <term term="Request Message">
    An application SOAP message for which an application SOAP response is 
    expected.
   </term>
   <term term="Response Message">
    An application SOAP message triggered by a Request Message.
   </term>
   <term term="Synchronous Request-Response Message Exchange">
    A SOAP message exchange in which a requester sends a SOAP message to a 
    service and receives a response message. "Synchronous" in this context 
    refers to the way in which the underlying transport protocol used to 
    carry the request and response messages. The response message is 
    returned on the back channel of the request message.
   </term>
  </terms>

 </section>

 <section title="Scenario Description">
  In this scenario, the supplier offers the customer a purchase order (PO) 
  service. The interface to this service is a CRUD (create, retrieve, update 
  and delete) interface for POs. The customer's client uses this interface 
  to create a new PO or retrieve (get status), update, or delete (cancel) 
  an existing PO. When a new PO is submitted by a customer it is assigned 
  a new order number by the supplier, which is unique within the scope 
  of that supplier. The PO order number can be used to get the status of, 
  update or cancel the PO.
  <p/>
  Once created, the PO goes through the following states:
  <num>Created (initial state)</num>
  <num>Verified</num>
  <num>Approved</num>
  <num>Back Ordered (if not in stock)</num>
  <num>Completed</num>
  The following figure shows a simplified state diagram of the PO process:<br/>
  <img src="PO-States.png"/><br/>
  <b>Figure 1 - Purchase Order State Diagram</b>
  <p/>
  Once created a PO must be verified against a set of business rules that 
  check such things as allowable purchase amounts, credit and payment 
  history, etc. This verification is done automatically by the suppliers 
  system. Once verified, the PO must be approved by a human being. Once 
  approved the PO either begins the shipping process or, if the ordered 
  items are not in stock, enters the "Back Ordered" state. When the 
  back-ordered items are received by the supplier, the order ships and 
  the process is complete.
  <p/>
  A PO can be either updated (changed) or canceled while in any of the 
  "Verified", "Approved" or "Back Ordered" states. If updated the PO 
  returns to the "Created" state where it will be re-verified. If canceled, 
  the PO enters the "Completed" state. 
 </section>

 <section title="Scenario Details">
  Because the verification of a PO happens in an automated fashion, the 
  designers of this service have decided to encompass the first state 
  transition in a single Asynchronous Request-Reponse Message Exchange. The 
  client sends a CreatePORequest to the service, the service creates the PO 
  and verifies it, then communicates the results to the client in a 
  CreatePOResponse message. The benefit of doing this is that the client can 
  determine, from the CreatePOResponse message, if the PO was verified or not.
  This simplifies the clients interaction with the PO state machine be 
  eliminating the need to perform another operation to determine whether or 
  not the PO passed verfication. However, for various reasons, the 
  verification process, although automated, takes 5 to 10 minutes to complete. 
  For this reason, the CreatePORequest/CreatePOResponse is asynchronous. 
  Clients that attempt to invoke the CreatePO operation in a synchronous 
  fashion will likely timeout awaiting the response. Similar logic applies to 
  the UpdatePORequest/UpdatePOResponse exchange. Because the effect of 
  updating a PO is to reset the state to "Created" and trigger a 
  re-verification, the UpdatePOResponse message must be sent to the client 
  in an asynchronous fashion to prevent the client from timing out. This means
  that the CreatePO and UpdatePO request message must not use wsa:Anonymous
  in their wsa:ReplyTo EPRs - however, if the clients are non-addressable 
  then they may choose to use a mechanism such as WS-MakeConnection.
  <p/>
  Clients can keep up to date with the state of their POs through two 
  orthogonal mechanisms. The first is to pull the state of a PO through 
  the GetPOStatus operation. Because the state of a PO is readily available 
  and the client is presumed to require timely information, GetPOStatus is 
  modeled as a Synchronous Request-Response Message Exchange. The second 
  method is to register with the service for asynchronous notification of 
  PO state changes. Clients do this by supplying a value for the 
  optional /wstfpo:PurchaseOrder/wstfpo:StatusUpdateEPR. This value is 
  the EPR of a client-provided endpoint that implements the 
  wstfpo:NotifyPortType interface. The PO service will send NotifyPOStatus 
  messages to this endpoint whenever the PO changes from one state to 
  another. Clients that implement some form of mapping between their own 
  order IDs and those of the supplier are encouraged to encode these IDs 
  as WS-Addressing Reference Parameters in the notification EPR. In this 
  way, each NotifyPOStatus notification message for a given PO will be 
  accompanied by SOAP headers that carry the customers internal ID, 
  thus saving the overhead of a table lookup operation on every 
  notification.
  <p/>
  If the supplier supports a REST-full interface to the PO then it may 
  include a "StatusURL" within the CreatePOResponse message.  The client may 
  then choose to issue an HTTP GET to this URL to retrieve the latest 
  status of the PO.
  <p/>
  Note that POs in the "Completed" state may still have their status 
  pulled via the GetPOStatus operation. The length of time that a supplier 
  must maintain information on completed POs is negotiated between the 
  customer and supplier via out-of-band agreements and is left 
  unspecified by this scenario. 
 </section>

 <section title="Test Cases">
   One of the goals of this scenario is to test long-running, asynchronous
   interactions between a service consumer and its provider. While some aspects
   of these interactions can be simulated in a relative short time period, to
   fully test the behavior of a particular web service stack under such
   circumstances requires an interaction that does, in fact, run for a "long"
   period of time. Each of the test cases in this scenario are described by a
   timeline which specifies the time at which various steps, actions, and state
   transitions occur in the scenario. To insure consitent comparisons between
   implementations, implementers of this scenario (both client and server
   sides) must adhere to the timelines specified in this section.

   <part title="Simple Test - Create to Completed">
     These tests exercise the simplest success path of a PO from Created to
     Completed. The /sc009:POReq/sc009:OrderDetails/sc009:CustID for these
     tests is "ProtoGee". The timeline for both of these tests is as follows:
     <br/><br/>
     <table cellpadding="2" cellspacing="0">
       <thead>
         <tr>
           <td><b>Time</b></td>
           <td><b>Expedite Time</b></td>
           <td><b>Action</b></td>
         </tr>
       </thead>
       <tbody>
         <tr>
           <td>0</td>
           <td>0</td>
           <td>PO created by customer</td>
         </tr>
         <tr>
           <td>6 minutes</td>
           <td>15 seconds</td>
           <td>PO verified by supplier</td>
         </tr>
         <tr>
           <td>25 minutes</td>
           <td>30 seconds</td>
           <td>PO accepted by supplier</td>
         </tr>
         <tr>
           <td>385 minutes</td>
           <td>45 seconds</td>
           <td>PO shipped by supplier</td>
         </tr>
       </tbody>
     </table>
     <br/>
     Note: An order may optionally include an Expedite value of 'true'
     to indicate that the PO service should use the shorter timing
     intervals.  However, this should only be used for quick testing
     purposes. The normal (longer) times should be used to ensure
     proper, and full, testing of the more complex long-running nature
     of a true PO service.
     <br/>
     <br/>
     <tests>
       <test name="Simple Test - No Notifications">
         <desc>
           This test is initiated by the client sending the following message to the PO service:<br/><br/>
           <xml>
&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns:sc009="http://www.wstf.org/docs/scenarios/sc009"
                  xmlns:wsa="http://www.w3.org/2005/08/addressing">
  &lt;soapenv:Header>
    &lt;wsa:MessageID><i>some message ID</i>&lt;/wsa:MessageID>
    &lt;wsa:To><i>appropriate URI</i>&lt;/wsa:To>
    &lt;wsa:Action><b>http://www.wstf.org/docs/scenarios/sc009/CreatePO</b>&lt;/wsa:Action>
    &lt;wsa:From>
      &lt;wsa:Address><i>appropriate URI</i>&lt;/wsa:Address>
    &lt;/wsa:From>
    &lt;wsa:ReplyTo>
      <i>appropriate EPR</i>
    &lt;/wsa:ReplyTo>
    &lt;wsa:FaultTo>
      <i>appropriate EPR</i>
    &lt;/wsa:FaultTo>
  &lt;/soapenv:Header>
  &lt;soapenv:Body>
    &lt;sc009:POReq>
      &lt;sc009:OrderDetails>
        &lt;sc009:CustID><b>ProtoGee</b>&lt;/sc009:CustID>
        &lt;sc009:ShipTo/>
        &lt;sc009:BillTo/>
        &lt;sc009:UserContact/>
        &lt;sc009:LineItems>
          &lt;sc009:Item>
            &lt;sc009:LineNo>1&lt;/sc009:LineNo>
            &lt;sc009:ProductName>ATX5350 Micro ATX Tower Case&lt;/sc009:ProductName>
            &lt;sc009:ItemType>computer components&lt;/sc009:ItemType>
            &lt;sc009:Partnum>ATX5350PRO2B&lt;/sc009:Partnum>
            &lt;sc009:Price>45&lt;/sc009:Price>
            &lt;sc009:Quantity>20&lt;/sc009:Quantity>
          &lt;/sc009:Item>
        &lt;/sc009:LineItems>
      &lt;/sc009:OrderDetails>
    &lt;/sc009:POReq>
  &lt;/soapenv:Body>
&lt;/soapenv:Envelope>
           </xml>
           The following diagram shows the message flows for this test:
           <img src="test-1.1.png"/>
         </desc>
         <success>
           After 6 minutes the service should send a CreatePOResponse (a SOAP message 
           with a wsa:Action of 
           "http://www.wstf.org/docs/scenarios/sc009/CreatePOResponse" and 
           a sc009:OrderInfo element in the body) to the ReplyTo EPR.<br/><br/>
           <note>
             For the remaining portion of the test (and for some unspecified period of time thereafter) the client may send GetPOStatusRequest messages to the service. The ReplyTo EPR for these requests may be either anonymous or non-anonymous. The service should respond with GetPOStatusResponse messages that indicate the appropriate state of the PO (depending upon the above timeline).
           </note>
           <note>
             The information in the /sc009:POReq/sc009:OrderDetails/sc009:LineItems element is not significant. It is only necessary that the order should contain at least one line item.
           </note>
         </success>
       </test>
       <test name="Simple Test - With Notifications">
         <desc>
           This test is initiated by the client sending the following message to the PO service:<br/><br/>
           <xml>
&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns:sc009="http://www.wstf.org/docs/scenarios/sc009"
                  xmlns:wsa="http://www.w3.org/2005/08/addressing">
  &lt;soapenv:Header>
    &lt;wsa:MessageID><i>some message ID</i>&lt;/wsa:MessageID>
    &lt;wsa:To><i>appropriate URI</i>&lt;/wsa:To>
    &lt;wsa:Action><b>http://www.wstf.org/docs/scenarios/sc009/CreatePO</b>&lt;/wsa:Action>
    &lt;wsa:From>
      &lt;wsa:Address><i>appropriate URI</i>&lt;/wsa:Address>
    &lt;/wsa:From>
    &lt;wsa:ReplyTo>
      <i>appropriate EPR</i>
    &lt;/wsa:ReplyTo>
    &lt;wsa:FaultTo>
      <i>appropriate EPR</i>
    &lt;/wsa:FaultTo>
  &lt;/soapenv:Header>
  &lt;soapenv:Body>
    &lt;sc009:POReq>
      &lt;sc009:OrderDetails>
        &lt;sc009:CustID><b>ProtoGee</b>&lt;/sc009:CustID>
        &lt;sc009:ShipTo/>
        &lt;sc009:BillTo/>
        &lt;sc009:UserContact/>
        &lt;sc009:LineItems>
          &lt;sc009:Item>
            &lt;sc009:LineNo>1&lt;/sc009:LineNo>
            &lt;sc009:ProductName>ATX5350 Micro ATX Tower Case&lt;/sc009:ProductName>
            &lt;sc009:ItemType>computer components&lt;/sc009:ItemType>
            &lt;sc009:Partnum>ATX5350PRO2B&lt;/sc009:Partnum>
            &lt;sc009:Price>45&lt;/sc009:Price>
            &lt;sc009:Quantity>20&lt;/sc009:Quantity>
          &lt;/sc009:Item>
        &lt;/sc009:LineItems>
      &lt;/sc009:OrderDetails>
      &lt;sc009:StatusUpdateEPR>
        <b><i>notification endpoint reference</i></b>
      &lt;/sc009:StatusUpdateEPR>
    &lt;/sc009:POReq>
  &lt;/soapenv:Body>
&lt;/soapenv:Envelope>
           </xml>
           The following diagram shows the message flows for this test:
           <img src="test-1.2.png"/>
         </desc>
         <success>
           After 6 minutes the service should send a CreatePOResponse (a SOAP message 
           with a wsa:Action of 
           "http://www.wstf.org/docs/scenarios/sc009/CreatePOResponse" 
           and a sc009:OrderInfo element in the body) to the ReplyTo EPR. Subsequent to this the service should send a NotifyPOStatus (a SOAP message with a wsa:Action of "http://www.wstf.org/docs/scenarios/sc009/PONotify" and a sc009:OrderInfo element in the body) to the endpoint indicated by /sc009:POReq/sc009:StatusUpdateEPR for every change of state in the order (e.g. Verified -> Approved).<br/><br/>
           <note>
             The initial state transition from "Created" to "Verified" results in two messages being sent from the service to the client. The first message is a CreatePOResponse. The second message is a NotifyPOStatus.
           </note>
           <note>
             For the remaining portion of the test (and for some unspecified period of time thereafter) the client may send GetPOStatusRequest messages to the service. The ReplyTo EPR for these requests may be either anonymous or non-anonymous. The service should respond with GetPOStatusResponse messages that indicate the appropriate state of the PO (depending upon the above timeline).
           </note>
           <note>
             The information in the /sc009:POReq/sc009:OrderDetails/sc009:LineItems element is not significant. It is only necessary that the order should contain at least one line item.
           </note>
         </success>
       </test>

       <test name="Simple Test - REST Status">
         <desc>
           This test follows the same steps as 1.1, however, the service 
           includes a StatusURL element within the CreatePOResponse message.
           <p/>
           The client will then using this URL to query the status of the PO.
         </desc>
         <success>
           Same as 1.1 with the addition that the client successful retrieves 
           the status of the PO using HTTP GET against the StatusURL returned 
           by the service.
         </success>
       </test>
     </tests>
   </part>
 </section>

 <section title="WSDL">
  The following WSDL defines the messages, interfaces, bindings and services 
  that make up this scenario. It can also be found at: 
  <a href="http://www.wstf.org/docs/scenarios/sc009/sc009.wsdl">
   http://www.wstf.org/docs/scenarios/sc009/sc009.wsdl</a>.
  <populate url="sc009.wsdl"/>
 </section>

 <section title="Schema">
  The following schema defines the XML types and elements used in this 
  scenario. It can also be found at: 
  <a href="http://www.wstf.org/docs/scenarios/sc009/sc009.xsd">
   http://www.wstf.org/docs/scenarios/sc009/sc009.xsd</a>.
  <populate url="sc009.xsd"/>
 </section>

 <section title="Sample Messages">
  <subsection title="CreatePO - Test 1.2">
   <xml title="Request">&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:wsa="http://www.w3.org/2005/08/addressing"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 &lt;soapenv:Header>
  &lt;wsa:MessageID>uuid:8e8af8c0c0a9010343fa43fa78e11a9b&lt;/wsa:MessageID>
  &lt;wsa:To> ... &lt;/wsa:To>
  &lt;wsa:Action>http://www.wstf.org/docs/scenarios/sc009/CreatePO&lt;/wsa:Action>
  &lt;wsa:ReplyTo>
   &lt;wsa:Address> ... &lt;/wsa:Address>
  &lt;/wsa:ReplyTo>
 &lt;/soapenv:Header>
 &lt;soapenv:Body>
  &lt;sc009:POReq xmlns:sc009="http://www.wstf.org/docs/scenarios/sc009">
     &lt;sc009:OrderDetails>
        &lt;sc009:CustID>ProtoGee&lt;/sc009:CustID>
        &lt;sc009:ShipTo/>
        &lt;sc009:BillTo/>
        &lt;sc009:UserContact/>
        &lt;sc009:LineItems>
           &lt;sc009:Item>
              &lt;sc009:LineNo>1&lt;/sc009:LineNo>
              &lt;sc009:ProductName>ATX5350 ATX Tower Case&lt;/sc009:ProductName>
              &lt;sc009:ItemType>computer components&lt;/sc009:ItemType>
              &lt;sc009:Partnum>ATX5350PRO2B&lt;/sc009:Partnum>
              &lt;sc009:Price>45&lt;/sc009:Price>
              &lt;sc009:Quantity>20&lt;/sc009:Quantity>
           &lt;/sc009:Item>
        &lt;/sc009:LineItems>
        &lt;sc009:Expedite>true&lt;/sc009:Expedite>
     &lt;/sc009:OrderDetails>
   &lt;sc009:StatusUpdateEPR>
    &lt;wsa:Address> ... &lt;/wsa:Address>
   &lt;/sc009:StatusUpdateEPR>
  &lt;/sc009:POReq>
 &lt;/soapenv:Body>
&lt;/soapenv:Envelope>
   </xml>
   <xml title="Response">&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
   xmlns:wsa="http://www.w3.org/2005/08/addressing"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 &lt;soapenv:Header>
  &lt;wsa:MessageID>uuid:8e8af8d4c0a9010343fa43fa43413423&lt;/wsa:MessageID>
  &lt;wsa:To> ... &lt;/wsa:To>
  &lt;wsa:Action>http://www.wstf.org/docs/scenarios/sc009/CreatePOResponse&lt;/wsa:Action>
  &lt;wsa:RelatesTo>uuid:8e8af8c0c0a9010343fa43fa78e11a9b&lt;/wsa:RelatesTo>
 &lt;/soapenv:Header>
 &lt;soapenv:Body>
  &lt;sc009:OrderInfo xmlns:sc009="http://www.wstf.org/docs/scenarios/sc009">
     &lt;sc009:OrderID>sc009-order-5&lt;/sc009:OrderID>
     &lt;sc009:OrderDate>2008-11-11T21:32:36.718-05:00&lt;/sc009:OrderDate>
     &lt;sc009:OrderPrice>100&lt;/sc009:OrderPrice>
     &lt;sc009:OrderStatus>Verified&lt;/sc009:OrderStatus>
     &lt;sc009:LastUpdate>2008-11-11T21:32:31.700-05:00&lt;/sc009:LastUpdate>
     &lt;sc009:StatusURL>http://.../orders/sc009-order-5&lt;/StatusURL>
  &lt;/sc009:OrderInfo>
 &lt;/soapenv:Body>
&lt;/soapenv:Envelope>
   </xml>
  </subsection>

  <subsection title="GetPOStatus">
   <xml title="Request">&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
   xmlns:wsa="http://www.w3.org/2005/08/addressing"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 &lt;soapenv:Header>
  &lt;wsa:MessageID>uuid:8e8b0d54c0a9010343fa43fa50fe3f40&lt;/wsa:MessageID>
  &lt;wsa:To> ... &lt;/wsa:To>
  &lt;wsa:Action>http://www.wstf.org/docs/scenarios/sc009/GetPOStatus&lt;/wsa:Action>
 &lt;/soapenv:Header>
 &lt;soapenv:Body>
  &lt;sc009:GetPOStatusReq xmlns:sc009="http://www.wstf.org/docs/scenarios/sc009">
     &lt;sc009:OrderID>sc009-order-5&lt;/sc009:OrderID>
  &lt;/sc009:GetPOStatusReq>
 &lt;/soapenv:Body>
&lt;/soapenv:Envelope>
   </xml>
   <xml title="Response">&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
   xmlns:wsa="http://www.w3.org/2005/08/addressing"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 &lt;soapenv:Header>
  &lt;wsa:MessageID>uuid:8e8b0d5ec0a9010343fa43fad3610a7e&lt;/wsa:MessageID>
  &lt;wsa:To> ... &lt;/wsa:To>
  &lt;wsa:Action>http://www.wstf.org/docs/scenarios/sc009/GetPOStatusResponse&lt;/wsa:Action>
  &lt;wsa:RelatesTo>uuid:8e8b0d54c0a9010343fa43fa50fe3f40&lt;/wsa:RelatesTo>
 &lt;/soapenv:Header>
 &lt;soapenv:Body>
  &lt;sc009:OrderInfo xmlns:sc009="http://www.wstf.org/docs/scenarios/sc009">
     &lt;sc009:OrderID>sc009-order-5&lt;/sc009:OrderID>
     &lt;sc009:OrderDate>2008-11-11T21:32:36.718-05:00&lt;/sc009:OrderDate>
     &lt;sc009:OrderPrice>100&lt;/sc009:OrderPrice>
     &lt;sc009:OrderStatus>Verified&lt;/sc009:OrderStatus>
     &lt;sc009:LastUpdate>2008-11-11T21:32:31.700-05:00&lt;/sc009:LastUpdate>
     &lt;sc009:StatusURL>http://.../orders/sc009-order-5&lt;/StatusURL>
  &lt;/sc009:OrderInfo>
 &lt;/soapenv:Body>
&lt;/soapenv:Envelope>
   </xml>
  </subsection>

  <subsection title="NotifyPOStatus">
   <xml>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
   xmlns:wsa="http://www.w3.org/2005/08/addressing"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 &lt;soapenv:Header>
  &lt;wsa:MessageID>uuid:8e8b6e45c0a9010343fa43fa59ca00e5&lt;/wsa:MessageID>
  &lt;wsa:To> ... &lt;/wsa:To>
  &lt;wsa:Action>http://www.wstf.org/docs/scenarios/sc009/NotifyPOStatus&lt;/wsa:Action>
 &lt;/soapenv:Header>
 &lt;soapenv:Body>
  &lt;sc009:OrderInfo xmlns:sc009="http://www.wstf.org/docs/scenarios/sc009">
     &lt;sc009:OrderID>sc009-order-5&lt;/sc009:OrderID>
     &lt;sc009:OrderDate>2008-11-11T21:32:36.718-05:00&lt;/sc009:OrderDate>
     &lt;sc009:OrderPrice>100&lt;/sc009:OrderPrice>
     &lt;sc009:OrderStatus>Approved&lt;/sc009:OrderStatus>
     &lt;sc009:LastUpdate>2008-11-11T21:33:01.765-05:00&lt;/sc009:LastUpdate>
     &lt;sc009:StatusURL>http://.../orders/sc009-order-5&lt;/StatusURL>
  &lt;/sc009:OrderInfo>
 &lt;/soapenv:Body>
&lt;/soapenv:Envelope>
   </xml>
  </subsection>

  <subsection name="HTTP GET">
    <xml title="Request">
GET orders/sc009-order-5 HTTP/1.1 
    </xml>

    <xml title="Response">&lt;sc009:OrderInfo xmlns:sc009="http://www.wstf.org/docs/scenarios/sc009">
  &lt;sc009:OrderID>sc009-order-5&lt;/sc009:OrderID>
  &lt;sc009:OrderDate>2008-11-11T21:32:36.718-05:00&lt;/sc009:OrderDate>
  &lt;sc009:OrderPrice>100&lt;/sc009:OrderPrice>
  &lt;sc009:OrderStatus>Approved&lt;/sc009:OrderStatus>
  &lt;sc009:LastUpdate>2008-11-11T21:33:01.765-05:00&lt;/sc009:LastUpdate>
  &lt;sc009:StatusURL>http://.../orders/sc009-order-5&lt;/StatusURL>
&lt;/sc009:OrderInfo>
    </xml>
    
  </subsection>

 </section>

 <section title="Findings">
   <part title="Mixed Synchronous and Asynchronous Operations in the Same portType">
     Section 3.1 of the <a href="http://www.w3.org/TR/ws-addr-metadata/#wspolicyassertions">WS-Addressing 1.0 Metadata</a>
     specification says the following about the wsam:Addressing policy assertion attachment point:<br/>
     <p/>
     <i>The wsam:Addressing policy assertion applies to the endpoint policy subject.<br/>
     <p/>
     For WSDL 1.1, these assertions may be attached to wsdl11:port or wsdl11:binding. For WSDL 2.0, they may be attached to
     wsdl20:endpoint or wsdl20:binding. A policy expression containing the wsam:Addressing policy assertion MUST NOT be attached to
     a wsdl:portType or wsdl20:interface. The wsam:Addressing policy assertion specifies a concrete behavior whereas the
     wsdl:portType or wsdl20:interface is an abstract construct.</i><br/>
     <p/>
     This is a problem for the following reasons:<br/>
     <p/>
     <num group="problems">
       A WSDL portType is a description of a set of related operations that affect the state of one or more semantically coupled
       resources.
     </num>
     <num group="problems">
       The synchronous or asynchronous nature of an operation is largely orthogonal to the underlying semantics of that operation;
       the semantics of an operation are essentially <b>what</b> the operation is doing, whereas the sync/async aspect of an
       operation is about <b>how</b> it does it.
     </num>
     <num group="problems">
       Given the above is is inevitable that there will exist portTypes (or bindings of portTypes if you prefer) in which some of
       the operations must be implemented in a synchronous fashion while others require an asynchronous interaction style. This
       scenario provides an example of such a situation.
     </num>
     <p/>
     The current state of the WS-Addressing Metadata specification forces one of the following undesirable solutions:<br/>
     <p/>
     <num group="solutions">
       Split the portType into two separate portTypes, one of which contains the synchronous operations and the other which contains
       the asynchronous operations. This both complicates the interface and acts as a multiplier on the number of WSDL components
       and their related artifacts. If you had one portType that with two bindings and two endpoints, splitting it creates two
       portTypes, four bindings, and four endpoints.
     </num>
     <num  group="solutions">
       Force all of the operations in the portType to be asynchronous. This greatly increases the complexity of programming the
       client.
     </num>
     <num  group="solutions">
       Re-factor the asynchronous operations into one-way operations with a callback EPRs. This complicates the interface, increases
       the complexity of the client, and undermines one of the primary reasons for using WS-Addressing.
     </num>
     <p/>
     When this issue was discussed in the WS-Addressing WG, it was thought that it would never be the case that an endpoint could
     support WS-Addressing for one operation but not another. If an implementation was capable of supporting addressing for one
     operation, it was argued, it should be able to support it for all operations. By itself, this argument makes sense. However,
     when the previously independent, top-level <code>wsam:AnonymousResponse</code> and <code>wsam:NonAnonymousResponse</code>
     assertions were moved under <code>wsam:Addressing</code> as nested assertions, this had the inadvertent side-effect of removing
     the ability to attach these assertions at the operation level.
   </part>

   <part title="Lack of Java Web Service APIs for Long-Running, Asynchronous Interactions">
     This scenario illustrates an important shortcoming in the <a href="http://jcp.org/en/jsr/detail?id=224">JAX-WS</a> server-side
     programming model. JAX-WS server-side requests are modeled as a synchronous method invocation on an impelementation of the
     service endpoint interface. The response to the client blocks on the return from this method. The fact that, in the
     asynchronous case, the response is transmitted over a separate connection to the <code>wsa:ReplyTo</code> address is besides
     the point; in both the synchronous and asynchronous cases, handling a request consumes a Java thread for the lifetime of the
     request. For asynchronous interactions in which the response may not be available for hours, minutes, or days, this has obvious
     drawbacks. For example, a JAX-WS implemention of this scenario, when handling the Test 1.1 CreatePO requestion (without the
     "Expedite" flag) will consume one thread for 6 minutes. If you send such an implementation 10 such requests per minute you will
     cause the service to consume around 60 threads in a steady state. This may not be enough to burden a real-world web services
     stack, but the implications are obvious; increase the request/response delay and/or the number of requests per minute and the
     result quickly exceeds the limitations of what most enterprises are willing to support.
   </part>

   <part title="Java support for timezone(Z) in SimpleDateFormat">
     As part of the testing it was noticed that some Java implementations used the
     SimpleDateFormat class to format xs:dateTime values.  In that class the letter 'Z'
     can be used in the pattern string to generate the timezone value (e.g. -0800).  
     However, notice that this value does not match the format specified in 
     <a href="http://www.w3.org/TR/xmlschema-2/">XML Schema</a> section 3.2.7.3, which
     states that the timezone is to be of the form: (('+' | '-') hh ':' mm) | 'Z'. Note
     the colon(:).  This difference can cause interoperability issues so care needs to
     be taken when using this Java class.
   </part>
 </section>

 <section title="Change History">
  <changes>
   <change date="2008/04/23" who="Anish Karmarkar">Initial Draft</change>
   <change date="2008/06/18" who="Anish Karmarkar">
     Updated to include details, message samples and to remove reliability and 
     security.
   </change>
   <change date="2008/06/24" who="Gilbert Pilz">
     Re-wrote business logic, schema and WSDLs. Added asynchronous notify 
     operation (NotifyPOStatus). Removed sections about supporting 
     non-addressable clients with WS-MakeConnection.
   </change>
   <change date="2008/06/26" who="Doug Davis">
     Converted to XML.
   </change>
   <change date="2008/07/08" who="Gilbert Pilz">
     Added test case 1.
   </change>
   <change date="2008/09/19" who="Gilbert Pilz">
     Remove references to SOAP 1.1. Changed "expedite" timings for the
     Simple Test.
   </change>
   <change date="2008/11/11" who="Doug Davis">
     Add stuff to the findings section - part 3.<br/>
     Add some sample messages.
   </change>
   <change date="2008/11/12" who="Gilbert Pilz">
     Add finding on mixed synch and asynch operations in the same 
     portType/binding.
   </change>
   <change date="2008/11/12" who="Gilbert Pilz">
     Add finding on lack of JAX-WS support for true server-side asynchrony.
   </change>
   <change date="2008/11/14" who="Doug Davis">
     Add some flow diagrams for each test.
   </change>
   <change date="2008/11/18" who="Doug Davis">
     Minor tweaks/typos.
   </change>
   <change date="2009/02/16" who="Doug Davis">
     Allow mc:Anon in async MEPs.
   </change>
   <change date="2009/06/11" who="Doug Davis">
     Add REST interface.
   </change>
  </changes>
 </section>

</scenario>
