SOAP

We describe SOAP. This talk summarizes

1 Web Services

1.1 SOAP Parts

1.2 Just-In-Time Integration

1.3 Web Service Technology Stack

Discovery: fetch descriptions of providers. UDDI, WS-Inspection.
Description: describe services. WSDL.
Packaging: is serialization or marshaling. SOAP.
Transport: application-to-application communication. HTTP, SMTP, TCP, Jabber.
Network: network layer. TCP/IP

2 SOAP Introduction

3 SOAP Messages

Envelope picture
<?xml version='1.0' ?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope"
  env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding"> 
  <env:Header>
    <m:reservation xmlns:m="http://example.org/reservation" 
      env:actor="http://www.w3.org/2001/12/soap-envelope/actor/next"
      env:mustUnderstand="true">
      <m:reference>uuid:093a2da1-q345-739r-ba5d-pqff98fe8j7d</reference>
        <m:dateAndTime>2001-11-29T13:20:00.000-05:00</m:dateAndTime>
      </m:reservation>
      <n:passenger xmlns:n="http://mycompany.example.com/employees"
        env:actor="http://www.w3.org/2001/12/soap-envelope/actor/next"
        env:mustUnderstand="true">
        <n:name>John Q. Public</n:name>
      </n:passenger>
  </env:Header>
  <env:Body>
    <p:itinerary xmlns:p="http://example.org/reservation/travel">
      <p:departure>
        <p:departing>New York</p:departing>
        <p:arriving>Los Angeles</p:arriving>
        <p:departureDate>2001-12-14</p:departureDate>
        <p:departureTime>late afternoon</p:departureTime>
        <p:seatPreference>aisle</p:seatPreference>
      </p:departure>
      <p:return>
        <p:departing>Los Angeles</p:departing>
        <p:arriving>New York</p:arriving>
        <p:departureDate>2001-12-20</p:departureDate>
        <p:departureTime>mid morning</p:departureTime>
        <p:seatPreference/>
        </p:return>
      </p:itinerary>
      <q:lodging xmlns:q="http://example.org/reservation/hotels">
        <q:preference>none</q:preference>
      </q:lodging>
  </env:Body>
</env:Envelope>

3.1 Envelope Structure

<?xml version='1.0' ?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope"> 
  <env:Header>
    <m:reservation xmlns:m="http://example.org/reservation" 
      env:actor="http://www.w3.org/2001/12/soap-envelope/actor/next"
      env:mustUnderstand="true">
      <m:reference>uuid:093a2da1-q345-739r-ba5d-pqff98fe8j7d</reference>
        <m:dateAndTime>2001-11-29T13:20:00.000-05:00</m:dateAndTime>
      </m:reservation>
      <n:passenger xmlns:n="http://mycompany.example.com/employees"
        env:actor="http://www.w3.org/2001/12/soap-envelope/actor/next"
        env:mustUnderstand="true">
        <n:name>John Q. Public</n:name>
      </n:passenger>
  </env:Header>
....
</env:Envelope>

3.3 SOAP Body

<?xml version='1.0' ?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope"> 
...
  <env:Body>
    <p:itinerary xmlns:p="http://example.org/reservation/travel">
      <p:departure>
        <p:departing>New York</p:departing>
        <p:arriving>Los Angeles</p:arriving>
        <p:departureDate>2001-12-14</p:departureDate>
        <p:departureTime>late afternoon</p:departureTime>
        <p:seatPreference>aisle</p:seatPreference>
      </p:departure>
      <p:return>
        <p:departing>Los Angeles</p:departing>
        <p:arriving>New York</p:arriving>
        <p:departureDate>2001-12-20</p:departureDate>
        <p:departureTime>mid morning</p:departureTime>
        <p:seatPreference/>
        </p:return>
      </p:itinerary>
      <q:lodging xmlns:q="http://example.org/reservation/hotels">
        <q:preference>none</q:preference>
      </q:lodging>
  </env:Body>
</env:Envelope>

3.4 SOAP Faults

<?xml version='1.0' ?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope"
  xmlns:f='http://www.w3.org/2001/12/soap-faults'>
  <env:Body>
    <env:Fault>
      <faultcode>env:Receiver</faultcode>
      <faultstring>Processing Error</faultstring>
      <detail>
        <e:myfaultdetails xmlns:e="http://example.org/faults">
          <message>Name does not match card number</message>
          <errorcode>999</errorcode>
        </e:myfaultdetails>
      </detail>
    </env:Fault>
  </env:Body>
</env:Envelope>

4 SOAP Data Encoding

4.1 Structs and Arrays

4.1.1 More Arrays

4.2 Single and Multireferenced

4.2.1 Multireferencing Example

class Employee{
  protected String firstName;
  protected String lastName;
  protected String title = "Worker Bee";
  protected Employee manager;

  public Employee (String first, String last,
                   Employee mgr){
    firstName = first;
    lastName = last;
    manager = mgr;}

  public String getTitle() {
    return title;
  }
  public void setTitle(String newTitle) {
    title = newTitle;
  }

  public String getFirstName() {
    return firstName;
  }
  public String getLastName() {
    return lastName;
  }
  public String getManager() {
    return manager;
  }
}

Employee rob = new Employee("rob", "englanger", null);
rob.setTitle("Slave Driver");
Employee ben = new Employee("ben", "jones", rob);
Employee andrew = new Employee("andrew", "smith", rob);
Employee lorraine = new Employee("lorraine", "white", rob);
  
<rob id="rob">
  <firstName>rob</firstName>
  <lastName>englander</lastName>
  <title>slave driver</title>
</rob>
<ben>
  <firstName>ben</firstName>
  <lastName>jones</lastName>
  <title>worker bee</title>
  <manager href="#rob"></manager>
</ben>
<andrew>
  <firstName>andrew</firstName>
  <lastName>smith</lastName>
  <title>worker bee</title>
  <manager href="#rob"></manager>
</andrew>
<lorraine>
  <firstName>lorraine</firstName>
  <lastName>white</lastName>
  <title>worker bee</title>
  <manager href="#rob"></manager>
</lorraine>

4.3 Expressing Type

  1. Use the xsi:type attribute on each accessor and reference the appropriate XML Schema type:
    <s:Envelope 
      xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" 
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" 
      xmlns:xsd="http://www.w3.org/1999/XMLSchema">
      <s:Body>
        <ns1:doSearch>
          <param xsi:type="xsd:string">hello</param>
        </ns1:doSearch>
      </s:Body>
    </s:Envelope>
    
  2. Reference an XML Schema document that defines the data type.
    <s:Envelope 
      xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" 
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" 
      xmlns:xsd="http://www.w3.org/1999/XMLSchema">
      <s:Body>
        <ns1:doSearch 
          xmlns="myschema.xsd">
          <param>hello</param>
        </ns1:doSearch>
      </s:Body>
    </s:Envelope>
    
  3. Reference some other type of schema document that defines the data type of schema document that defines the data type of element within its definition.
    <s:Envelope 
      xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" >
      <s:Body>
        <ns1:doSearch 
          xmlns="urn:some_namespace">
          <param>hello</param>
        </ns1:doSearch>
      </s:Body>
    </s:Envelope>
    <!--Where urn:some_namespace indicates some namespace-->
    <!-- where the value of param elements are strings.-->

4.4 SOAP Data Types

4.5 Multiple References

4.6 Encoding Arrays

5 SOAP Message Exchange Model

5.1 Targeting SOAP Header Blocks

5.2 Processing SOAP Messages

  1. Determine the set of roles in which the node is to act.
  2. Identify all header blocks targeted at the node that are mandatory.
  3. If one or more of the header blocks identified in the preceding step are not understood by the node then generate a single SOAP MustUnderstand fault and stop processing.
  4. Process all header blocks targeted at the node and, in the case of the ultimate SOAP recipient, the SOAP body.
  5. In the case of a SOAP intermediary, and where the message is to be forwarded further along the message path, remove all SOAP header blocks targeted at the node, and possibly insert new SOAP header blocks.

6 Routing

<S:Envelope
  xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
  <S:Header>
    <m:path xmlns:m="http://schemas.xmlsoap.org/rp/">
      <m:action>http://www.im.org/chat</m:action>
      <m:to>soap://D.com/some/endpoint</m:to>
      <m:fwd>
        <m:via>soap://B.com</m:via>
        <m:via>soap://C.com</m:via>
      </m:fwd>
      <m:rev>
        <m:via/>
      </m:rev>
      <m:from>mailto:henrikn@microsoft.com</m:from>
      <m:id>uuid:84b9f5d0-33fb-4a81-b02b-5b760641c1d6</m:id>
    </m:path>
  </S:Header>
  <S:Body>
    ...
  </S:Body>
</S:Envelope>

7 RPC-Style Web Services

7.1 RPC Responses

<s:Envelope xmlns:s="...">
  <s:Body>
    <checkResponse xmlns=".."
        s:encodingStyle="http://www.w3.org/2001/06/soap-encoding">
      <return xsi:type="string">return string</paramA>
    </checkResponse>
  </s:Body>
</s:Envelope>

8 HTTP Binding

POST /Charging HTTP/1.1
Host: travelcompany.example.org
Content-Type: application/soap; charset="utf-8"
Content-Length: nnnn

<?xml version='1.0' ?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope" >
  <env:Header>
    ::::::
  </env:Header> 
  <env:Body>
    <m:reserveAndCharge> 
      ::::::
    </m:reserveAndCharge>
  </env:Body>
</env:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap; charset="utf-8"
Content-Length: nnnn

<?xml version='1.0' ?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope" >
  <env:Header>
    ::::
  </env:Header> 
  <env:Body>
    ::::
  </env:Body>
</env:Envelope>
HTTP/1.1 500 Internal Server Error
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn

<?xml version='1.0' ?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
  <env:Body>
    <env:Fault>
      <faultcode>env:Receiver</faultcode>
      <faultstring>Processing Error</faultstring>
      <detail>
        <e:myfaultdetails xmlns:e="http://travelcompany.example.org/faults" >
          <message>Name does not match card number</message>
          <errorcode>999</errorcode>
        </e:myfaultdetails>
      </detail>
    </env:Fault>
  </env:Body>
</env:Envelope>

9 Email Binding

From: reservations@travelcompany.example.org
To: john.public@mycompany.example.com
Subject: Which NY airport?
Date: Thu, 29 Nov 2001 13:35:11 EST
Message-Id: <200109251753.NAA10655@travelcompany.example.org>
In-reply-to:<EE492E16A0B8D311AC490090276D208424960C0C@mycompany.example.com@gt;
<?xml version='1.0' ?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope"> 
  <env:Header>
    <m:reservation xmlns:m="http://travelcompany.example.org/reservation" 
      env:actor="http://www.w3.org/2001/12/soap-envelope/actor/next"
      env:mustUnderstand="true">
      <m:reference>uuid:093a2da1-q345-739r-ba5d-pqff98fe8j7d</reference>
        <m:dateAndTime>2001-11-29T13:35:00.000-05:00</m:dateAndTime>
      </m:reservation>
      <n:passenger xmlns:n="http://mycompany.example.com/employees"
        env:actor="http://www.w3.org/2001/12/soap-envelope/actor/next"
        env:mustUnderstand="true">
        <n:name>John Q. Public</n:name>
      </n:passenger>
  </env:Header>
  <env:Body>
    <p:itinerary xmlns:p="http://travelcompany.example.org/reservation/travel">
      <p:airportChoices>
        :::::
      </p:airportChoices>
    </p:itinerary>
  </env:Body>
</env:Envelope>

10 The End of SOAP?

URLs

  1. SOAP Version 1.2 Part 0: Primer, http://www.w3c.org/TR/soap12-part0/
  2. SOAP Version 1.2 Part 1: Messaging Framework, http://www.w3.org/TR/soap12-part1/
  3. Java and SOAP, http://www.amazon.com/exec/obidos/ASIN/0596001754/multiagentcom/
  4. wikipedia:Representational_State_Transfer, http://www.wikipedia.org/wiki/Representational_State_Transfer
  5. bad, http://www.somebits.com/weblog/tech/bad/whySoapSucks.html
  6. reputation, http://wanderingbarque.com/nonintersecting/2006/11/15/the-s-stands-for-simple/
  7. SOAP standard, http://www.w3c.org/TR/2001/WD-soap12-part0-20011217/
  8. WS-Routing, http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnglobspec/html/ws-routing.asp
  9. strong typing, http://www.somebits.com/weblog/tech/bad/whySoapSucks.html
  10. Its too complicated, http://www.eweek.com/c/a/Application-Development/The-Future-of-Programming-Less-Is-More/

This talk available at http://jmvidal.cse.sc.edu/talks/soap/
Copyright © 2009 José M. Vidal . All rights reserved.

14 April 2008, 11:11AM