Looking to Reprint this content?
By David A. Chappell, Tyler Jewell
Price: $39.95 USD
£28.50 GBP
Cover | Table of Contents | Colophon
An architecture that uses a distributed, discovery-based execution environment to expose and manage a collection of service-oriented software assets.
http://www.ibm.com/developerWorks). Since
then, this group has used it as a way to extol the virtues of web
services to nontechnical users. The SOA is an instance of a composite
computing model, and thus something that can be used to further our
understanding of it.
POST /StockQuote HTTP/1.1 Host: www.example.org Content-Type: text/xml; charset="utf-8" Content-Length: nnnn SOAPAction: "http://example.org/2001/06/quotes" <env:Envelope xmlns:env="http://www.w3.org/2001/09/soap-envelope" > <env:Body> <m:GetLastTradePrice env:encodingStyle="http://www.w3.org/2001/09/soap-encoding" xmlns:m="http://example.org/2001/06/quotes"> <symbol>DIS</symbol> </m:GetLastTradePrice> </env:Body> </env:Envelope>
GetLastTradePrice, and its parameter, the ticker
symbol DIS.
SOAP messages are fundamentally one-way transmissions from a SOAP sender to a SOAP receiver; however, SOAP messages are often combined to implement patterns such as request/response.SOAP implementations can be optimized to exploit the unique characteristics of particular network systems. For example, the HTTP binding ... provides for SOAP response messages to be delivered as HTTP responses, using the same connection as the inbound request.
<?xml version="1.0" encoding="UTF-8"?>
<PurchaseOrder xmlns="urn:oreilly-jaws-samples">
<shipTo country="US">
<name>Joe Smith</name>
<street>14 Oak Park</street>
<city>Bedford</city>
<state>MA</state>
<zip>01730</zip>
</shipTo>
<items>
<item partNum="872-AA">
<productName>Candy Canes</productName>
<quantity>444</quantity>
<price>1.68</price>
<comment>I want candy!</comment>
</item>
</items>
</PurchaseOrder>java SimpleGenericHTTPSoapClient -df ./PO.xml
_________________________________________________________
Starting SimpleGenericHTTPSoapClient:
host url = http://localhost:8080/examples/servlet/SimpleHTTPReceive
data file = ./PO.xml
_________________________________________________________
Sent SOAP Message with Apache HTTP SOAP Client.
Waiting for response....
HTTP POST was successful.Received request.
-----------------------
SOAPAction = "urn:oreilly-jaws-samples"
Host = localhost
Content-Type = text/xml; charset=utf-8
Content-Length = 695
-----------------------
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org
/1999/XMLSchema">
<SOAP-ENV:Body>
<PurchaseOrder xmlns="urn:oreilly-jaws-samples">
<shipTo country="US">
<name>Joe Smith</name>
<street>14 Oak Park</street>
<city>Bedford</city>
<state>MA</state>
<zip>01730</zip>
</shipTo>
<items>
<item partNum="872-AA">
<productName>Candy Canes</productName>
<quantity>444</quantity>
<price>1.68</price>
<comment>I want candy!</comment>
</item>
</items>
</PurchaseOrder>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
____________________________http://localhost:8080/soap/servlet/messagerouter
or http://localhost:8080/soap/servlet/rpcrouter.
These special URLs point to Apache's routing and
dispatching mechanism. This mechanism looks at the content of the
SOAP envelope and decides which class to load and which method to
call within that class. Apache refers to this destination as a
service
.
The service is registered with the servlet engine in a two-step
process. First, an XML deployment descriptor is created, specifying
details about the class name of the service, its associated method
call, and the target URI. Then a special
org.apache.soap.server.ServiceManagerClient class
is invoked to register the service with Apache SOAP.
public void anyMessageMethod(Envelope requestEnvelope,
SOAPContext requestContext, SOAPContext responseContext)SimpleHTTPReceive servlet is
an excellent way of dumping raw output to the screen. A more
convenient way to see the raw output from the sender and the receiver
is to use the TunnelGui included with Apache SOAP. TunnelGui is a
simple utility that intercepts the HTTP request, displays it in a
window on the screen, and forwards the request to the ultimate
destination. It's a great tool for analyzing and
debugging problems that have to do with unexpected output. To launch
the Apache TunnelGui utility, issue the following command:
<PurchaseOrderWithAttachment>. The other
modification we have made is the addition of an element with the name
of attachment. This element contains an
href attribute:
<attachment href="cid:the-attachment"/>
java GenericHTTPSWAClient -df ./poWithAttachment.xml -at attachment.txt
Content-ID = the-attachment The attachment is... This is an attachment.
http://www.xmethods.net. Let's start
by running the client and examining its output:
java GetBookPrice
_________________________________________________________
Starting GetBookPrice:
service url = http://services.xmethods.com:80/soap/servlet/rpcrouter
ISBN# = 0596000685
_________________________________________________________
The price for O'Reilly's The Java Message Service book is 34.95http://www.xmethods.net. Let's start
by running the client and examining its output:
java GetBookPrice
_________________________________________________________
Starting GetBookPrice:
service url = http://services.xmethods.com:80/soap/servlet/rpcrouter
ISBN# = 0596000685
_________________________________________________________
The price for O'Reilly's The Java Message Service book is 34.95<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:
xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/
XMLSchema">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring>Test Fault</faultstring>
<faultactor>/soap/servlet/rpcrouter</faultactor>
<detail>
<stackTrace>[SOAPException: faultCode=SOAP-ENV:Server; msg=Test Fault]
at StockQuantity.getQty(StockQuantity.java:21)
at java.lang.reflect.Method.invoke(Native Method)
at org.apache.soap.server.RPCRouter.invoke(RPCRouter.java:146)
...
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(
ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:498)
</stackTrace>
</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope><faultcode> and
<faultstring> elements are required. The
<faultactor> and
<detail> elements are optional. Table 4-1 lists the possible values for the faultcodes
and their meanings.
|
Faultcode
|
Meaning
|
|---|---|
VersionMismatch
|
The SOAP node processing the request encountered a version mismatch.
The namespace identifier of the SOAP envelope determines version
compatibility.
|
MustUnderstand
|
actor attribute may be used to specify which
blocks of information are intended for each step in the process. Each
node in a multihop process is responsible for digesting and
interpreting the meaning of the actor attribute
for each SOAP block and possibly re-inserting it into the SOAP block
and forwarding it on to the next node for processing. Any SOAP
receiver that encounters a header block without an
actor attribute, or an actor
attribute equivalent to the special URI http://www.w3.org/2001/09/soap-envelope/actor/next,
has to interpret that header block as being intended for it (the
current SOAP node). If the current SOAP node cannot fulfill the
mustUnderstand requirements, it must generate a
SOAP Fault.
actor attribute with the special value of
http://www.w3.org/2001/09/soap-envelope/actor/none
indicates that this header is not targeted at anything in particular.
This indication is useful for sharing header information across
multiple nodes.
<definitions>
<import>*
<types>
<schema></schema>*
</types>
<message>*
<part></part>*
</message>
<PortType>*
<operation>*
<input></input>
<output></output>
<fault></fault>*
</operation>
</PortType>
<binding>*
<operation>*
<input></input>
<output></output>
</operation>
</binding>
<service>*
<port></port>*
</service>
</definitions><definitions>
element in a WSDL document acts as a container for the service
description. It provides a place to do global declarations of
namespaces that are intended to be visible throughout the rest of the
document. Here is the <definitions> element
from the XML Encoding Rules. Note that some of the namespaces defined
in this element have prefixes (xsd,
soap, soapenc,
xer, etc.), and some do not. These prefixes are
bound to a particular namespace but do not govern which schemas are
actually available to a schema processor: