By James Snell, Doug Tidwell, Pavel Kulchenko
Book Price: $34.95 USD
£24.95 GBP
PDF Price: $27.99
Cover | Table of Contents | Colophon
http://www.w3c.org). This book assumes you
are familiar with these specifications, at least on a cursory level,
and will not spend time discussing them. The only exception is a
quick introduction to the XML Schema data types in Appendix B.
http://www.w3c.org). This book assumes you
are familiar with these specifications, at least on a cursory level,
and will not spend time discussing them. The only exception is a
quick introduction to the XML Schema data types in Appendix B.
http://www.w3.org/2001/06/soap-envelope namespace.
This XML namespace identifier points to an XML Schema that defines
the structure of what a SOAP message looks like.
<s:Envelope
xmlns:s="http://www.w3.org/2001/06/soap-envelope">
<s:Header>
<m:transaction xmlns:m="soap-transaction"
s:mustUnderstand="true">
<transactionID>1234</transactionID>
</m:transaction>
</s:Header>
<s:Body>
<n:purchaseOrder xmlns:n="urn:OrderService">
<from><person>Christopher Robin</person>
<dept>Accounting</dept></from>
<to><person>Pooh Bear</person>
<dept>Honey</dept></to>
<order><quantity>1</quantity>
<item>Pooh Stick</item></order>
</n:purchaseOrder>
</s:Body>
</s:Envelope>
<s:Envelope>, the topmost container that
comprises the SOAP message; the optional
<s:Header>, which contains additional blocks
of information about how the body payload is to be processed; and the
mandatory <s:Body> element that contains the
actual message to be processed.
<s:Envelope xmlns:s="...">
<s:Body>
<s:Fault>
<faultcode>Client.Authentication</faultcode>
<faultstring>
Invalid credentials
</faultstring>
<faultactor>http://acme.com</faultactor>
<details>
<!-- application specific details -->
</details>
</s:Fault>
</s:Body>
</s:Envelope>
http://www.w3.org/2001/06/soap-envelope namespace.
These are described here:
structure with each in or in-out parameter modeled
as a field in that structure.
String checkStatus(String orderCode,
String customerID);
result = checkStatus("abc123", "Bob's Store")
<s:Envelope xmlns:s="...">
<s:Body>
<checkStatus xmlns="..."
s:encodingStyle="http://www.w3.org/2001/06/soap-encoding">
<orderCode xsi:type="string">abc123</orderCode>
<customerID xsi:type="string">
Bob's Store
</customerID>
</checkStatus>
</s:Body>
</s:Envelope>
xsi:type explicit data typing.
They are, however, widely used and will be what we describe.
structure with a field for each in-out or
out parameter in the method signature. If the
checkStatus method we called earlier returned the
string new, the SOAP response might be something
like Example 2-13.
<s:Envelope xmlns:s="...">
<s:Body>
<checkStatusResponse
s:encodingStyle="http://www.w3.org/2001/06/soap-encoding">
<return xsi:type="xsd:string">new</return>
</checkStatusResponse>
</SOAP:Body>
</SOAP:Envelope>firstname is an accessor, and
Joe is a value:
<firstname> Joe </firstname>
<SOAP-ENC:int>36</SOAP-ENC:int> <value xsi:type="xsd:int">36</value>
<SOAP-ENC:int>42</SOAP-ENC:int> <SOAP-ENC:int>42</SOAP-ENC:int>
tweak(&i, &i);
POST /StockQuote HTTP/1.1 Content-Type: text/xml Content-Length: nnnn SOAPAction: "urn:StockQuote#GetQuote" <s:Envelope xmlns:s="http://www.w3.org/2001/06/soap-envelope"> ... </s:Envelope>
http://www.soaplite.com or http://www.soapware.org. There are
SOAP
toolkits for all the popular programming languages and environments
(Java, C#, C++, C, Perl, PHP, and Python, just to name a few).
http://www.cpan.org. See http://www.cpan.org/misc/cpan-faq.html#How_install_Perl_modules
for information on installing Perl modules.
C:\book>perl -MCPAN -e shell cpan shell—CPAN exploration and modules installation (v1.59_54) cpan> install SOAP::Lite
We are about to install SOAP::Lite and for your convenience will provide you with list
of modules and prerequisites, so you'll be able to choose only modules you need for
your configuration.
XMLRPC::Lite, UDDI::Lite, and XML::Parser::Lite are included by default. Installed
transports can be used for both SOAP::Lite and XMLRPC::Lite.
Client (SOAP::Transport::HTTP::Client) [yes]
Client HTTPS/SSL support
(SOAP::Transport::HTTP::Client, require OpenSSL) [no]
Client SMTP/sendmail support (SOAP::Transport::MAILTO::Client) [yes]
Client FTP support (SOAP::Transport::FTP::Client) [yes]
Standalone HTTP server (SOAP::Transport::HTTP::Daemon) [yes]
Apache/mod_perl server (SOAP::Transport::HTTP::Apache, require Apache)[no]
FastCGI server (SOAP::Transport::HTTP::FCGI, require FastCGI) [no]
POP3 server (SOAP::Transport::POP3::Server) [yes]
IO server (SOAP::Transport::IO::Server) [yes]
MQ transport support (SOAP::Transport::MQ) [no]
JABBER transport support (SOAP::Transport::JABBER) [no]
MIME messages [required for POP3, optional for HTTP]
(SOAP::MIMEParser) [no]
SSL support for TCP transport (SOAP::Transport::TCP) [no]
Compression support for HTTP transport (SOAP::Transport::HTTP) [no]
Do you want to proceed with this configuration? [yes]http://jakarta.apache.org/tomcat/).
http://xml.apache.org/soap/index.html, has
links to both source-only and precompiled distributions of the
toolkit. Installing the precompiled binary distribution is as simple
as downloading a Zip archive and extracting it into a directory.
http://xml.apache.org/xerces-j/).
set CLASSPATH = %CLASSPATH%;%SOAP_LIB%\soap.jar set CLASSPATH = %CLASSPATH%;%SOAP_LIB%\mail.jar set CLASSPATH = %CLASSPATH%;%SOAP_LIB%\activation.jar
CLASSPATH = $CLASSPATH;$SOAP_LIB/soap.jar CLASSPATH = $CLASSPATH;$SOAP_LIB/mail.jar CLASSPATH = $CLASSPATH;$SOAP_LIB/activation.jar
http://msdn.microsoft.com. This free
distribution contains everything you need to create and run any .NET
application, including .NET Web Services.
C:\book>start java org.apache.soap.util.net.TcpTunnelGui 8080
localhost 80
localhost:8080.
C:\book>perl hello_client1.pl James
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>
System.Web.Services.Protocols.SoapException: Server did
not recognize the value of HTTP Header SOAPAction:
urn:Example#sayHello.
at System.Web.Services.Protocols.SoapServerProtocol.Initialize( )
at System.Web.Services.Protocols.ServerProtocolFactory.Create(
Type type, HttpContext context, HttpRequest request,
HttpResponse response)
</faultstring>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>http://www.soap-wrc.com). This service
demonstrates techniques for implementing more complicated forms of
web services. It builds on the Hello World example from Chapter 3.
public Interface Publisher {
public boolean register (String email,
String password,
String firstName,
String lastName,
String title,
String company,
String url);
public boolean modify (String email,
String newemail,
String password,
String firstName,
String lastName,
String title,
String company,
String url);
public AuthInfo login {String id,
String password);
public int post (AuthInfo authinfo,
Str