<?xml version="1.0"?>
<!--
SmartClientOperations Web Services API Version 1.0

Copyright 2005 Isomorphic Software, Inc.
-->

<definitions name="SmartClientOperations" 
             targetNamespace="urn:operations.smartclient.com"
             xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"

             xmlns:tns="urn:operations.smartclient.com"
             xmlns:fns="urn:operations.smartclient.com"
             xmlns="http://schemas.xmlsoap.org/wsdl/">

    <types>
        <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:operations.smartclient.com">
            <!-- RPC response codes:  See the documentation for the RPCResponse class in the
                 reference docs for more information on the fields below. -->
            <xsd:simpleType name="StatusCode">
                <restriction base="xsd:string">
                    <enumeration value="STATUS_SUCCESS"/>
                    <enumeration value="STATUS_FAILURE"/>
                    <enumeration value="STATUS_VALIDATION_ERROR"/>
                </restriction>
            </xsd:simpleType>

            <!-- DSRequest:  See the documentation for the DSRequest class the reference docs
                 for more information on the fields below. -->
            <xsd:complexType    name="DSRequest">
                <xsd:sequence>
                    <!-- name of the datasource this request will act on -->
                    <xsd:element    name="dataSource"       type="xsd:string"/>
                
                    <!-- type of operation being performed "fetch", "add", "remove", or
                         "update" -->
                    <xsd:element    name="operationType"    type="xsd:string"/>

                    <!--  The operationId serves as an identifier you can use to create
                          variations on the basic DataSource operations that are used by
                          different components in different parts of your application. -->
                    <xsd:element    name="operationId"      type="xsd:string" minOccurs="0"/>

                    <!-- startRow/endRow apply to the "fetch" operationType only and is
                         optional.  If these values are set, the server is expected to return
                         just the requested rows and set startRow/endRow on the DSResponse with
                         the actual row boundaries, but *may* return the entire matching
                         dataset include (the client handles this automatically).
                         If a partial dataset is returned, the field and sort direction
                         indicated by the sortBy parameter must be respected, otherwise,
                         unsorted results are fine (client-side sorting kicks in)
                     -->
                    <xsd:element    name="startRow"         type="xsd:long" minOccurs="0"/>
                    <xsd:element    name="endRow"           type="xsd:long" minOccurs="0"/>
                    <xsd:element    name="sortBy"           type="xsd:string" minOccurs="0"/>

                    <!-- textMatchStyle applies to the "fetch" operationType only and
                         is optional.  This value applies only to the SQLDataSource built in to
                         the ISC server.  If passed as "substring", the SQLDataSource will use
                         case-insensitive substring match for filter values on String fields.
                         If you implement a custom "fetch" operation, you can ignore this
                         setting, and interpret criteria however you want to -->
                    <xsd:element    name="textMatchStyle" type="xsd:string" minOccurs="0"/>

                    <!-- For operationType "fetch" and "remove" this is the criteria.  For
                         "add" and "update" these are the new values. -->
                    <xsd:element name="data" minOccurs="0" maxOccurs="1">
                       <xsd:complexType>
                          <xsd:sequence>
                             <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
                          </xsd:sequence>
                       </xsd:complexType>
                    </xsd:element>
                </xsd:sequence>
            </xsd:complexType>


            <!-- DSResponse:  See the documentation for the DSResponse class the reference docs
                 for more information on the fields below. -->
            <xsd:complexType    name="DSResponse">
                <xsd:sequence>
                    <!-- execution status (see StatusCode) -->
                    <xsd:element    name="status"           type="tns:StatusCode"/>
                
                    <!-- Optional flag that can be set by the server to force ResultSets to
                         drop any caches of records from the DataSource that was the target of
                         the operation. -->
                    <xsd:element    name="invalidateCache"  type="xsd:boolean"  minOccurs="0"/>

                    <!-- List of records as saved in the persistence store (if any).  So,
                         for operationType "update" this should return the values as saved. -->
                    <xsd:element name="data" minOccurs="0" maxOccurs="1">
                       <xsd:complexType>
                          <xsd:sequence>
                             <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
                          </xsd:sequence>
                       </xsd:complexType>
                    </xsd:element>

                    <!-- startRow/endRow apply to the "fetch" operationType only.  If the
                         DSRequest specified startRow/endRow, then the DSResponse must set them
                         as well.  Note that the DSResponse startRow/endRow may differ from the
                         DSRequest startRow/endRow if the dataset has fewer than the requested
                         number of rows -->
                    <xsd:element    name="startRow"         type="xsd:long" minOccurs="0"/>
                    <xsd:element    name="endRow"           type="xsd:long" minOccurs="0"/>

                    <!-- totalRows applies to the "fetch" operationType only.  Set this to the
                         total number of records available in this dataSource.  This is an
                         optional parameter that's used by some UI components.  For example,
                         the ListGrid uses it to control the size of the vertical scrollbar
                         based on the recordHeight.  If this value is omitted, the UI component
                         will still be fully usable, but may give an incorrect visual
                         indictication to the user. -->
                    <xsd:element    name="totalRows"        type="xsd:long" minOccurs="0"/>

                    <!-- if the DSResponse status is STATUS_VALIDATION_FAILURE then then errors
                         in an array of of validation errors.  Each entry is a map from the
                         fieldName to a list of errors for that field.  -->
                    <xsd:element name="errors" minOccurs="0" maxOccurs="1">
                       <xsd:complexType>
                          <xsd:sequence>
                             <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
                          </xsd:sequence>
                       </xsd:complexType>
                    </xsd:element>
                </xsd:sequence>
            </xsd:complexType>

            <xsd:element name="fetchRequest" type="tns:DSRequest"/>
            <xsd:element name="fetchResponse" type="tns:DSResponse"/>
            <xsd:element name="addRequest" type="tns:DSRequest"/>
            <xsd:element name="addResponse" type="tns:DSResponse"/>
            <xsd:element name="removeRequest" type="tns:DSRequest"/>
            <xsd:element name="removeResponse" type="tns:DSResponse"/>
            <xsd:element name="updateRequest" type="tns:DSRequest"/>
            <xsd:element name="updateResponse" type="tns:DSResponse"/>
        </xsd:schema>
    </types>

    <message name="fetchRequest">
        <part name="fetchRequest"      element="tns:fetchRequest"/>
    </message>
    <message name="fetchResponse">
        <part name="fetchResponse"      element="tns:fetchResponse"/>
    </message>
    <message name="addRequest">
        <part name="addRequest"      element="tns:addRequest"/>
    </message>
    <message name="addResponse">
        <part name="addResponse"      element="tns:addResponse"/>
    </message>
    <message name="removeRequest">
        <part name="removeRequest"      element="tns:removeRequest"/>
    </message>
    <message name="removeResponse">
        <part name="removeResponse"      element="tns:removeResponse"/>
    </message>
    <message name="updateRequest">
        <part name="updateRequest"      element="tns:updateRequest"/>
    </message>
    <message name="updateResponse">
        <part name="updateResponse"      element="tns:updateResponse"/>
    </message>

    <portType name="SmartClientOperationsPort">
        <operation name="fetch">
            <input message="tns:fetchRequest"/>
            <output message="tns:fetchResponse"/>
        </operation>
        <operation name="add">
            <input message="tns:addRequest"/>
            <output message="tns:addResponse"/>
        </operation>
        <operation name="remove">
            <input message="tns:removeRequest"/>
            <output message="tns:removeResponse"/>
        </operation>
        <operation name="update">
            <input message="tns:updateRequest"/>
            <output message="tns:updateResponse"/>
        </operation>
    </portType>

    <!-- multiop -->
    <binding name="SmartClientOperationsBinding" type="tns:SmartClientOperationsPort">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="fetch">
            <soap:operation soapAction="urn:operations.smartclient.com#fetch"/>
            <input>
                <soap:body use="literal"/>
            </input>
            <output>
                <soap:body use="literal"/>
            </output>
        </operation>
        <operation name="add">
            <soap:operation soapAction="urn:operations.smartclient.com#add"/>
            <input>
                <soap:body use="literal"/>
            </input>
            <output>
                <soap:body use="literal"/>
            </output>
        </operation>
        <operation name="remove">
            <soap:operation soapAction="urn:operations.smartclient.com#remove"/>
            <input>
                <soap:body use="literal"/>
            </input>
            <output>
                <soap:body use="literal"/>
            </output>
        </operation>
        <operation name="update">
            <soap:operation soapAction="urn:operations.smartclient.com#update"/>
            <input>
                <soap:body use="literal"/>
            </input>
            <output>
                <soap:body use="literal"/>
            </output>
        </operation>
    </binding>

    <!-- Soap Service Endpoint -->
    <service name="SmartClientOperations">
        <port name="SmartClientOperations" binding="tns:SmartClientOperationsBinding">
            <soap:address location="/isomorphic/services/1.0/SmartClientOperations"/>
        </port>
    </service>
</definitions>
