Workshop SOAP:style Semantics


For FeaturedNPOQueryService, we employed SOAP:style="document"; this is illustrated in the following WSDL fragment. The corresponding SOAP request and response messages were shown in Figure 8-12.

 <operation name="getCampaigns">     <soap:operation style="document"         soapAction="http://www.GreaterCause.com/getCampaigns"/>     <input>         <soap:body use="literal"/>     </input>     <output>         <soap:body use="literal"/>     </output> </operation> 

Recall that the request-response operation is an abstract notion; therefore the vendor implementation will dictate whether messages are sent within a single HTTP request-response, or as two independent HTTP requests. WebLogic Web service deployment descriptor allows you to specify an operation:invocation-style attribute that can take the values "one-way" or "request-response"; for FeaturedNPOQueryService, we use invocation-style="request-response". Note that the XML document "getCampaignsResponse" in the SOAP body in Figure 8-12 is converted to its Java equivalent by the deserialization mechanisms generated by the vendor tool; please refer to section "Creating Serialization Classes" for the type-mapping construct created by the tool. Document-oriented Web service operations use literal encoding, which implies that the message elements described in WSDL reference a concrete schema using the type attribute.

If we had employed SOAP:style="rpc", the resulting SOAP messages will follow the representation stated in section 7.1 of the SOAP specification; the data types marshalled across the wire follow a set of encoding rules described in Section 5 of the SOAP specification, which has the namespace identifier "http://schemas.xmlsoap.org/soap/encoding/" (also called SOAP encoding). Changing SOAP:style to "rpc" will yield the following response:

 <SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"    xmlns:xsd="http://www.w3.org/2001/XMLSchema"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">    <SOAP-ENV:Body       SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">       <m:getCampaignsResponse xmlns:m="http://www.GreaterCause.com/"          xmlns:types="http://www.GreaterCause.com/encodedTypes">          <getCampaignsResult SOAP-ENC:arrayType="types:FeaturedNPODTO[2]"             xsi:type="SOAP-ENC:Array">             <item>                <startDate xsi:type="xsd:string">2004-12-01</startDate>                <regionCode xsi:type="xsd:string">NORCAL</regionCode>                <ein xsi:type="xsd:string">94-0385620</ein>                <endDate xsi:type="xsd:string">2004-12-26</endDate>                <npoName                xsi:type="xsd:string">California Historical Society</npoName>             </item>             <item>                <startDate xsi:type="xsd:string">2004-01-01</startDate>                <regionCode xsi:type="xsd:string">NORCAL</regionCode>                <ein xsi:type="xsd:string">94-3045430</ein>                <endDate xsi:type="xsd:string">2004-04-30</endDate>                <npoName                xsi:type="xsd:string">American Red Cross Bay Area</npoName>             </item>          </getCampaignsResult>       </m:getCampaignsResponse>    </SOAP-ENV:Body> </SOAP-ENV:Envelope> 

Because other encoding schemes are possible for representing data types, the SOAP ‘encodingStyle’ attribute can be used to indicate the encoding style of the method call and the response. Using SOAP for RPC is orthogonal to the SOAP protocol binding (please refer to the Sample WSDL discussed previously for FeaturedNPOQueryService). When using HTTP as the protocol binding, an RPC call maps to an HTTP request and an RPC response maps to an HTTP response.




Practical J2ee Application Architecture
Practical J2EE Application Architecture
ISBN: 0072227117
EAN: 2147483647
Year: 2003
Pages: 111
Authors: Nadir Gulzar

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net