5. Document/literal (2003): Forget all the fancy encoding rules
<?xml version="1.0"?>
<soap-env:envelope
soap-env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
<soap-env:header>
...
</soap-env:header>
<soap-env:body>
… your XML Schema compliant document goes here …
</soap-env:body>
</soap-env:envelope>
6. I want my, I want my RPC (rpc/literal)
<?xml version="1.0"?>
<soap-env:envelope
soap-env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
<soap-env:header>
... Namespace does not
</soap-env:header> have to be the same
<soap-env:body>
<m:doSomething xmlns:m=“http://lab49.com/”>
as the parameter values
<foo>
… XML Schema compliant value…
… XML Schema compliant value…
…
</foo> Argument elements don’t
<bar> even have a namespace
… XML Schema compliant value…
…
</bar>
</m:doSomething>
</soap-env:body>
</soap-env:envelope>
Lets you model procedure calls, but can’t validate SOAP body with an XML Schema
7. SOAP encoding convention line-up circa 2003
1. RPC/encoded (the original)
2. Document/literal (based on XML Schema, but doesn’t model RPC)
3. RPC/literal (adds RPC modeling, breaks XML Schema validation)
Can’t we model RPC without breaking Schema validation?
8. Wrapped document literal style (2005)
<?xml version="1.0"?>
<soap-env:envelope
soap-env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
<soap-env:header>
...
</soap-env:header>
<soap-env:body>
<m:doSomething xmlns:m=“http://lab49.com/”>
<m:foo>
… Entire body complies with an XML Schema
</m:foo>
<m:bar>
containing element doSomething containing
… a sequence of elements foo and bar
</m:bar>
</m:doSomething>
</soap-env:body>
</soap-env:envelope>
9. Handy summary
Scheme Rating Why?
rpc/encoded Because “encoded” means “section 5 encoding” and that hairy
BAD
(1998) scheme has been displaced by XML Schemas
doc/literal Send an XML Schema compliant document, get one back.
BEST
(2003) Awesome.
rpc/literal
BAD Failed attempt to reconcile document style with RPC.
(2003)
wrapped/literal
GOOD Successful attempt to reconcile document style with RPC.
(2005)
10. Web Service Definition Language (WSDL 1.1)
Wrapped style. Notice the operation
has one message part called “parameters”
which is an XML sequence of the args
12. Code first / WSDL first decision algorithm
Write code first and
use doc/literal style.
Will other projects i.e. Every method
No Are you in a No
be using these has one arg. Use
services? i.e. is this great hurry? annotations to name
part of an SOA? everything and
review
WSDL afterward.
Yes
Yes
Write code first in
wrapped/literal style, i.e. Use
annotations to name everything
and review WSDL afterward.
Write WSDL first.
Think through interfaces carefully, plan
for backward compatibility, write lots of
comments, and maintain in source control.
13. Goodies
• WS-Security (message integrity, confidentiality, and authentication)
• WS-ReliableMessaging
• WS-Routing (messaging patterns and routes)
• WS-Eventing (pub/sub)
• Many other incomprehensible extensions, collectively referred to as WS-*
18. Comparison points
• WSDL is a good idea for both SOAP and REST
(not a long-term differentiator)
• SOAP and REST both allow you to name resources with URIs
(also not a long-term differentiator)
• REST adds value to the entire web
(we don’t care)
• REST is easier to program
(not for long)
• SOAP provides better support for async messaging
• SOAP is better if developers and network administrators don’t
have a good relationship
19. In conclusion
For enterprise apps, default to SOAP.
But if (like Amazon.com) you
•are catering to people who are not making a large
investment in connecting to your service
•have control over your network
•are trying to reach a broad audience
… then go with REST.
Expires: Mon, 31 Mar 2008 20:00:00 GMT