HomeDigital EditionSys-Con RadioSearch Web Services Cd
B2B Beginning WS Business Process Management Case Studies Content Management Distributing Computing e-Business Electronic Data Interchange Enterprise Industry Insight Integration Interviews Java & Web Services .NET Portal Product Reviews Scalability & Performance Security SOAP Source Code UDDI Wireless WS Standards WS Tips & Techniques WSDL WS Editorials XML

Web Services Infrastructure, by Jim Webber
WSJ Vol 02 Issue 10 - pg.54

	


Listing 1: Controlling Atoms from a Web Service Client

// obtain a UserTransaction object (assume it is previously 
// initialized)
userTransaction = UserTransactionFactory.getTransaction();

// obtain references to the Web services we are going to use:
restaurant = new RestaurantService();
taxi = new TaxiService();
theatre = new TheatreService();

// Start a new transaction, using a simple atom
userTransaction.begin(com.hp.mw.xts.TxTypes.ATOM);

// now invoke the business logic
restaurant.bookSeats(3);
theatre.bookSeats(3, 2);
taxi.bookTaxi();

// prepare the transaction (first phase of two phase 
     coordination)
userTransaction.prepare();

// confirm the transaction (second phase of two phase 
     coordination)
userTransaction.confirm();

Listing 2: A BTP Begin Message

<?xml version="1.0" encoding="UTF-8" ?>
<SOAP:Envelope
 SOAP:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP:Body>
    <btp:begin transaction-type="atom"
      xmlns:btp="urn:oasis:names:tc:BTP:1.0:core" />
  </SOAP:Body>
</SOAP:Envelope>

Listing 3: An Application Message with BTP Context

<?xml version="1.0" encoding="UTF-8" ?>
<SOAP:Envelope
  SOAP:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP:Header>
    <btp:messages xmlns:btp="urn:oasis:names:tc:BTP:1.0:core">
      <btp:context>
        <btp:superior-address>
          <btp:binding-name>soap-http-1</btp:binding-name>
            <btp:binding-address>
              http://mybusiness.com/btpservice
            </btp:binding-address>
          </btp:superior-address>
          <btp:superior-identifier>
            12fa6de4ea3ec
          </btp:superior-identifier>
        <btp:superior-type>atom</btp:superior-type>
      </btp:context>
    </btp:messages>  
  </SOAP:Header>
  <SOAP:Body>
    <ns:booking xmlns:ns="http://btp.restaurant.org/">
      <seats xsi:type="xsd:int">99</seats>
    </ns:booking>
  </SOAP:Body>
</SOAP:Envelope>