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 |
<?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>
Envelope
element.Envelope
must contain exactly one
Body
element.Body
element may contain as many child
nodes as are required.Body
element are the
message.Envelope
contains a Header
element (it can't have more) it must appear as the first child
of the Envelope
.Header
and
Body
are application-dependent.encodingStyle
in the envelope tells how
the data is serialized Header
is called header block.
<?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>
actor
attribute has a value
of next
means that the header block should be
processed by the next intermediary.mustUnderstand
attribute specifies that the
receivers to what the block says, or fail.<?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>
Fault
element within Body
.faultcode
and
faultstring
sub-elements which must appear.faultcode
is a
QName
from XMLSchema. The
faultstring
's content is a human-readable
string.<?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>
soap-envelope
schema defines the
faultcodes: VersionMismatch
,
MustUnderstand
, DTDNotSupported
,
DataEncodingUnknown
, Sender
,
Receiver
.MustUnderstand
fault should also include
information about which element was not understood.<name>Sam</name>name is the accessor and Sam is the value.
int[3] iArray = {10, 20, 30};
becomes
<iArray xsi:type=SOAP-ENC:Array SOAP-ENC:arrayType="xsd:int[3]"> <val>10</val> <val>20</val> <val>30</val> </iArray>and the class
class Sample { public int iVal = 10; public java.lang.String sVal = "Ten"; } Sample samp = new Sample();becomes
<Sample> <iVal xsi:type="xsd:int">10</iVal> <sVal xsi:type="xsd:string">Ten</sVal> </Sample>
<mixedNuts xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:ur-type[3]"> <nut xsi:type="xsd:float">3.14</nut> <nut xsi:type="xsd:string">SOAP</nut> <nut xsi:type="xsd:int">1234321</nut> </mixedNuts>
<contestants xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[10]" SOAP-ENC:offset="[6]"> <name>rob</name> <name>arnold</name> <name>scott</name> </contestants>
<contestants xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[10]"> <name SOAP-ENC:posistion="[1]">rob</name> <name SOAP-ENC:posistion="[5]">arnold</name> <name SOAP-ENC:posistion="[8]">scott</name> </contestants>
id
attribute.<!--singlereferenced--> <people> <person name="Joe"/> </people> <!--multi-reference accessor--> <people> <person name="philip"> <address href="#address1"/> </person> <person name="agnes"> <address href="#address1"/> </person> </people> <adress id="address1"> <street>300 Main St.</street> <city>Columbia</city> <state>South Carolina</state> </address>
href
s can also be URLs.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>
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>
<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>
<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.-->
<SOAP-ENC:int xmlns="http://www.w3.org/2001/12/soap-encoding"> 36 </SOAP-ENC:int>
<value xsi:type="xsd:int">36</value>
href
.Address address = new Address(); Person person - new Person(); person.setAddress(address);
<Person> <Address href="#address1" /> </Person> <Address id="addres1" />
SOAP-ENC:Array
.arrayType
attribute.<some_array xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="se:string[3]"> <se:string>Frodo</se:string> <se:string>Bilbo</se:string> <se:string>Sam</se:string> </some_array>
http://www.w3.org/2001/12/soap-envelope/actor/actorname
.http://www.w3.org/2001/12/soap-envelope/actor/next
.none
, these are
meant for the final receiver.actor
attribute information item.mustUnderstand
attribute. If the value is "true" then the receiver must either
understand and process that element or generate a fault.<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>
structure
with each in or in-out parameter modeled
as a field in that structure.String check(String paramA, String paramB);will use the SOAP envelope
<s:Envelope xmlns:s="..."> <s:Body> <check xmlns=".." s:encodingStyle="http://www.w3.org/2001/06/soap-encoding"> <paramA xsi:type="string">abs123</paramA> <paramB xsi:type="string"> Bob's store </paramB> </check> </s:Body> </s:Envelope>
<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>
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>
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>
This talk available at http://jmvidal.cse.sc.edu/talks/soap/
Copyright © 2009 José M. Vidal
.
All rights reserved.
14 April 2008, 11:11AM