5.2. Extending The MathPortType: A New WSDL file

We will now write and deploy a new service that exposes all the WS-ResourceProperty portTypes through compositional inheritance. What is compositional inheritance? Basically copying & pasting operations from the WSRP portTypes to the MathPortType. Our client application will, in turn, make a call to some of these portTypes.

In this chapter we must use a new WSDL file because we want to extend from new portTypes, which necessarily changes our service's interface. In this WSDL the "getValueRP" operation has been removed. The GetResourceProperty, SetResourceProperty, GetMultipleResourceProperties, and QueryResourceProperties operations were copied from their respective WSRP portTypes into the MathPortType. In theMathBinding we also need to define each new operation.


<?xml version="1.0" encoding="UTF-8"?>
<definitions name="MathServiceRP"
    targetNamespace="http://www.globus.org/namespaces/examples/core/MathService_instance_rp" (1)
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://www.globus.org/namespaces/examples/core/MathService_instance_rp"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:wsrp="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.xsd"
    xmlns:wsrpw="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.wsdl" (2)
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    
<wsdl:import (3)
    namespace=
    "http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.wsdl"
    location="wsrf/properties/WS-ResourceProperties.wsdl" />

   
<!--============================================================

                      T Y P E S

  ============================================================-->
<types>
<xsd:schema targetNamespace="http://www.globus.org/namespaces/examples/core/MathService_instance_rp"
    xmlns:tns="http://www.globus.org/namespaces/examples/core/MathService_instance_rp"
    xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">

        <!-- IMPORT WS-ADDRESSING -->
        <xsd:import namespace="http://schemas.xmlsoap.org/ws/2004/03/addressing"
             schemaLocation="http://schemas.xmlsoap.org/ws/2004/03/addressing"/>

        <!-- REQUESTS AND RESPONSES -->

        <xsd:element name="add" type="xsd:int"/>
        <xsd:element name="addResponse">
                <xsd:complexType/> 
        </xsd:element>
        <xsd:element name="subtract" type="xsd:int"/>
        <xsd:element name="subtractResponse">
                <xsd:complexType/>
        </xsd:element>
      
        <xsd:element name="create">
                <xsd:complexType/>
        </xsd:element>
        <xsd:element name="createResponse">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element ref="wsa:EndpointReference"/>
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>

        <!-- MathService Resource Properties -->

        <xsd:element name="Value" type="xsd:int"/>
        <xsd:element name="LastOp" type="xsd:string"/>
        <xsd:element name="MathResourceProperties">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element ref="tns:Value"/>
                    <xsd:element ref="tns:LastOp"/>
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>

</xsd:schema>
</types>
 
<!--============================================================

                       M E S S A G E S

  ============================================================-->
<message name="AddInputMessage">
        <part name="parameters" element="tns:add"/>
</message>
<message name="AddOutputMessage">
        <part name="parameters" element="tns:addResponse"/>
</message>

<message name="SubtractInputMessage">
        <part name="parameters" element="tns:subtract"/>
</message>
<message name="SubtractOutputMessage">
        <part name="parameters" element="tns:subtractResponse"/>
</message>

<message name="CreateInputMessage">
        <part name="parameters" element="tns:create"/>
</message>
<message name="CreateOutputMessage">
        <part name="parameters" element="tns:createResponse"/>
</message>


<!--============================================================

                       P O R T T Y P E

  ============================================================-->

<portType name="MathPortType" 
    wsrp:ResourceProperties="tns:MathResourceProperties">

	<operation name="add"> (4)
		<input message="tns:AddInputMessage"/>
		<output message="tns:AddOutputMessage"/>
	</operation>
        
	<operation name="subtract">
		<input message="tns:SubtractInputMessage"/>
		<output message="tns:SubtractOutputMessage"/>
	</operation>

	<operation name="createResource">
		<input message="tns:CreateInputMessage"/>
		<output message="tns:CreateOutputMessage"/>
	</operation>

	<operation name="GetResourceProperty"> (5)
		<input name="GetResourcePropertyRequest" 
                    message="wsrpw:GetResourcePropertyRequest" 
                    wsa:Action="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties/GetResourceProperty"/>
                <output name="GetResourcePropertyResponse" 
                    message="wsrpw:GetResourcePropertyResponse" 
                    wsa:Action="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties/GetResourcePropertyResponse"/>
                <fault name="InvalidResourcePropertyQNameFault" 
                    message="wsrpw:InvalidResourcePropertyQNameFault"/>
                <fault name="ResourceUnknownFault" 
                    message="wsrpw:ResourceUnknownFault"/>
	</operation>

    <operation name="GetMultipleResourceProperties"> (6)
      <input name="GetMultipleResourcePropertiesRequest" message="wsrpw:GetMultipleResourcePropertiesRequest" wsa:Action="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties/GetMultipleResourceProperties"/>
      <output name="GetMultipleResourcePropertiesResponse" message="wsrpw:GetMultipleResourcePropertiesResponse" wsa:Action="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties/GetMultipleResourcePropertiesResponse"/>
      <fault name="InvalidResourcePropertyQNameFault" message="wsrpw:InvalidResourcePropertyQNameFault"/>
      <fault name="ResourceUnknownFault" message="wsrpw:ResourceUnknownFault"/>
    </operation>

    <operation name="SetResourceProperties"> (7)
      <input name="SetResourcePropertiesRequest" message="wsrpw:SetResourcePropertiesRequest" wsa:Action="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties/SetResourceProperties"/>
      <output name="SetResourcePropertiesResponse" message="wsrpw:SetResourcePropertiesResponse" wsa:Action="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties/SetResourcePropertiesResponse"/>
      <fault name="InvalidResourcePropertyQNameFault" message="wsrpw:InvalidResourcePropertyQNameFault"/>
      <fault name="UnableToModifyResourcePropertyFault" message="wsrpw:UnableToModifyResourcePropertyFault"/>
      <fault name="SetResourcePropertyRequestFailedFault" message="wsrpw:SetResourcePropertyRequestFailedFault"/>
      <fault name="ResourceUnknownFault" message="wsrpw:ResourceUnknownFault"/>
      <fault name="InvalidSetResourcePropertiesRequestContentFault" message="wsrpw:InvalidSetResourcePropertiesRequestContentFault"/>
    </operation>

    <operation name="QueryResourceProperties"> (8)
      <input name="QueryResourcePropertiesRequest" message="wsrpw:QueryResourcePropertiesRequest" wsa:Action="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties/QueryResourceProperties"/>
      <output name="QueryResourcePropertiesResponse" message="wsrpw:QueryResourcePropertiesResponse" wsa:Action="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties/QueryResourcePropertiesResponse"/>
      <fault name="UnknownQueryExpressionDialectFault" message="wsrpw:UnknownQueryExpressionDialectFault"/>
      <fault name="InvalidResourcePropertyQNameFault" message="wsrpw:InvalidResourcePropertyQNameFault"/>
      <fault name="QueryEvaluationErrorFault" message="wsrpw:QueryEvaluationErrorFault"/>
      <fault name="InvalidQueryExpressionFault" message="wsrpw:InvalidQueryExpressionFault"/>
      <fault name="ResourceUnknownFault" message="wsrpw:ResourceUnknownFault"/>
    </operation>
	
</portType>

<!--============================================================

                       B I N D I N G

  ============================================================-->
<binding name="MathBinding" type="MathPortType"> (9)
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

    <wsdl:operation name="add">
      <soap:operation soapAction=""/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>

    <wsdl:operation name="subtract">
      <soap:operation soapAction=""/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>

    <wsdl:operation name="createResource">
      <soap:operation soapAction=""/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>

    <wsdl:operation name="GetResourceProperty">
      <soap:operation soapAction=""/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>

    <wsdl:operation name="GetMultipleResourceProperties">
      <soap:operation soapAction=""/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>

    <wsdl:operation name="SetResourceProperties">
      <soap:operation soapAction=""/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>

    <wsdl:operation name="QueryResourceProperties">
      <soap:operation soapAction=""/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
</binding>

<!--============================================================

                       S E R V I C E

  ============================================================-->
<service name="MathService">
    <port name="MathPort" binding="MathBinding">
       <soap:address location="http://localhost:8080/wsrf/services/"/>
    </port>
</service>

</definitions>

Note

Copy & Paste WSDL definition to "/tmp/MathRPService.wsdl".

(1)
Notice how we declare a new target namespace for our new WSDL interface.
(2)
This namespace declaration (wsrpw) was already present in previous examples. We need to declare the WS-ResourceProperties namespace if we want to use the messages associated with the WSRP portTypes defined in that specification.
(3)
We must import the WS-ResourceProperties WSDL file, where the portTypes and associated messages are actually defined. Futhermore this WSDL file must exist at the location specified in the import.
(4)
Our example exposes the add, subtract, and createResource operations in addition to the WS-ResourceProperty portType operations.
(5)
We've eliminated the GetValueRP operation (although not shown above, the WSDL file also lacks the corresponding GetValueRP messages and elements). Since we are now going to use the GetResourceProperty portType, there is no need to expose an explicit GetValueRP operation.
(6)
GetMultipleResourceProperties portType operation.
(7)
SetResourceProperties portType operation.
(8)
QueryResourceProperties portType operation.
(9)
We need to add each additional operation to the MathBinding, this can be accomplished by simply copying one of the other operations and changing the name attribute.