AWS Choreography Example

This document shows the process of answering a SPARQL query against a set of operations described in a wsdl document and annotated with SPDL.

This document includes samples of SPDL annotations, along with explanations of their purposes.

Introduction

The WSDL document has SPARQL Annotations associating elements in the WSDL-described messages with a SPARQL graph pattern. These annotations are parsed and stored in a ruleset. Each rule associates an operation with its input and output graph patterns. The example annotated WSDL (abbreviated for simplicity of presentation) produces rules for two operations, ItemSearch and ItemLookup from its annotations.

These rules are combined with a user-supplied query to produce a set of ways to solve that query. This document includes traces of a sample query execution, demonstrating how these rules combine with data provided in the user's query and other rules in the system to construct service request documents.

Finally, the annotations provide the necessary mapping to bring the information in the service responses into the query results.

Example Annotation

    <xs:element name="ItemSearch">
        ...
          <xs:element name="SubscriptionId" spat:SPAT='?req tns:id xpath("tns:SubscriptionId")' type="xs:string" minOccurs="0"/>
        ...
    </xs:element>

This is one of several annotations associating query graph patterns with triples in the PATHPATTERN. The above is a query PATHPATTERN; that is, it is used to contruct the request given variable bindings. Other patterns map the web service response to SPARQL variables:

<... spat:SPAT="?X tns:title xpath("tns:Title")" ... >

A variety of triggers my cause the query engine to construrct and XML query document and invoke the service implied by the SPARQL query pattern. In this case, constants in the query are mapped to XPaths in the PATHPATTERN. For instance, the constant "0FWYBWB91M5S26YBE382" is the object of the tns:id predicate. Mapping this back to a PATHPATTERN, we substitute this contant into the XML identified by the XPath in the pattern.

        <ItemSearch xmlns="">
            <SubscriptionId xsi:type="xsd:string">0FWYBWB91M5S26YBE382</SubscriptionId>
            <Request>
                <Keywords xsi:type="xsd:string">Weaving</Keywords>
                <SearchIndex xsi:type="xsd:string">Books</SearchIndex>
            </Request>
        </ItemSearch>

A similar process extracts the values from the response and binds the values to SPARQL variables. Given a response:

        <ItemSearchResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2005-10-05">
            <OperationRequest>
                ...
            <Items>
                <Request>
                   ...
                </Request>
                </Item>
                <Item>
                    <ASIN>0205459404</ASIN>
                    <DetailPageURL>http://www.amazon.com/exec/obidos/redirect?tag=ws%26link_code=sp1%26camp=2025%26creative=165953%26path=http://www.amazon.com/gp/redirect.html%253fASIN=0205459404%2526tag=ws%2526lcode=sp1%2526cID=2025%2526ccmID=165953%2526location=/o/ASIN/0205459404%25253FSubscriptionId=0FWYBWB91M5S26YBE382</DetailPageURL>
                    <ItemAttributes>
                        <Author>Craig A Cunningham</Author>
                        <Author>Marty Billingsley</Author>
                        <ProductGroup>Book</ProductGroup>
                        <Title>Curriculum Webs : Weaving the Web into Teaching and Learning (2nd Edition)</Title>
                    </ItemAttributes>
                </Item>

the XPath "tns:Title" maps the title into the ?title variable in our SPARQL query.

Please see the accompanying example service description for the fully annotated WSDL.

Rule Construction

The SPARQL Annotations annotating the input of the messages of an operation are aggregated together to form rule body ("ask" below) and the output annotations form the rule head ("body"). SPAT XPaths in the input graph are treated as variables, and XPaths in the output side are treated as constructed blank nodes.

ItemSearch

┌ op {http://webservices.amazon.com/AWSECommerceService/2004-11-10}ItemSearch: 
│     fwrule ask(?req this:id XPath(., 8b45348) && 
│                ?req this:keywords XPath(tns:Keywords, 9115940) && 
│                ?req this:index XPath(tns:SearchIndex, 9115940))
│            assert(?req this:reqId _:<>:19.XPath(., 9211c38) && 
│                   ?req this:asin _:<>:20.XPath(tns:ASIN, 920b2b0) && 
│                   ?req this:title _:<>:21.XPath(tns:Title, 9298a50))
│               -->{<qname:{http://webservices.amazon.com/AWSECommerceService/2004-11-10}ItemSearch>}

ItemLookup

┌ op {http://webservices.amazon.com/AWSECommerceService/2004-11-10}ItemLookup: 
│     fwrule ask(?req this:id XPath(., 91642dc) && 
│                ?req this:asin XPath(., 919d638))
│            assert(?req this:page _:<>:8.XPath(this:Items/this:Item/this:DetailPageURL, 91d37c8) && 
│                   ?req this:reqId _:<>:9.XPath(., 9211c38) && 
│                   ?req this:asin _:<>:10.XPath(tns:ASIN, 920b2b0) && 
│                   ?req this:title _:<>:11.XPath(tns:Title, 9298a50))
│               -->{<qname:{http://webservices.amazon.com/AWSECommerceService/2004-11-10}ItemLookup>}

These rules are stored with other rules in the system, for instance, those used to execute RDF Schema or OWL inferences, or do ontology mappings.

SPARQL Query

The rules described above enable the system to infer the possible graph patterns that it can conclude given appropriate user or system-supplied data. User-supplied data comes, in this case, in the form of a SPARQL query:

PREFIX tns: <http://dev.w3.org/cvsweb/perl/modules/W3C/SPDL/descriptions/AWSECommerceService-SAWSDL-item-terms.ttl#>
SELECT ?title ?page WHERE {
_:b tns:id "0FWYBWB91M5S26YBE382" ;
    tns:keywords "Weaving" ;
    tns:index "Books" ;

    tns:asin ?asin ;
    tns:title ?title ;
    tns:page ?page . }

The top portion of the query (though the order is unimportant) supplies some constants that happen to trigger the ItemLookup rule. This produces four intermediate inferences:

_:22  this:page   _:8.XPath(this:Items/this:Item/this:DetailPageURL, 91d37c8) ;
      this:reqId  _:9.XPath(., 9211c38) ;
      this:asin   _:10.XPath(tns:ASIN, 920b2b0) ;
      this:title  _:11.XPath(tns:Title, 9298a50) .

These do not supply the user with the requested data, but do inform the system how to acquire that data as they are associated with the operation that can obtain the useful bindings for this data.

These assertions can, in turn, trigger other operations, for instance, ItemSearch operation. These rules, and your ontology mapping rules, produce a rule closure that includes RDF graph representations of all of the "potential knowledge" obtainable by invoking the services.

Query Solutions

The query can then be executed on the knowledge base to find, from the closure of "potential knowledge" the solutions pertinent to the user-supplied query. The query above, when executed over this rule closure, finds two ways to solve the user's question. One involves using the binding for asin that comes from results of an ItemLookup operation, and the other uses the asin from the ItemSearch operation. (The difference between these two solutions will be shown to be immaterial as both require the invocation of the same operations.)

Each solution in the table below includes it's attribution. These can be simple assertions, whose attribution is abbreviated to "<>", and rules executed against assertions.

titlepage_:basin
_:21.XPath(tns:Title, 9302a7c)
_:8.XPath(this:Items/this:Item/this:DetailPageURL, 9262250)
_:22
_:20.XPath(tns:ASIN, 92caa54)
_:22 this:id "0FWYBWB91M5S26YBE382" .
-->{<>}
_:22 this:keywords "Weaving" .
-->{<>}
_:22 this:index "Books" .
-->{<>}
_:22 this:asin _:20.XPath(tns:ASIN, 92caa54) .
-->{
[
fwrule ask(?req this:id XPath(., 8b4f4e4) && ?req this:keywords XPath(tns:Keywords, 919cc14) && ?req this:index XPath(tns:SearchIndex, 919cc14)) assert(?req this:reqId _:19.XPath(., 9238158) && ?req this:asin _:20.XPath(tns:ASIN, 92caa54) && ?req this:title _:21.XPath(tns:Title, 9302a7c)) -->{AWSECommerceService:ItemSearch}
_:22 this:index "Books" .
-->{<>}
_:22 this:id "0FWYBWB91M5S26YBE382" .
-->{<>}
_:22 this:keywords "Weaving" .
-->{<>}
]
}
_:22 this:title _:21.XPath(tns:Title, 9302a7c) .
-->{
[
fwrule ask(?req this:id XPath(., 8b4f4e4) && ?req this:keywords XPath(tns:Keywords, 919cc14) && ?req this:index XPath(tns:SearchIndex, 919cc14)) assert(?req this:reqId _:19.XPath(., 9238158) && ?req this:asin _:20.XPath(tns:ASIN, 92caa54) && ?req this:title _:21.XPath(tns:Title, 9302a7c)) -->{AWSECommerceService:ItemSearch}
_:22 this:index "Books" .
-->{<>}
_:22 this:id "0FWYBWB91M5S26YBE382" .
-->{<>}
_:22 this:keywords "Weaving" .
-->{<>}
]
}
_:22 this:page _:8.XPath(this:Items/this:Item/this:DetailPageURL, 9262250) .
-->{
[
fwrule ask(?req this:id XPath(., 9196e80) && ?req this:asin XPath(., 9229db8)) assert(?req this:page _:8.XPath(this:Items/this:Item/this:DetailPageURL, 9262250) && ?req this:reqId _:9.XPath(., 9238158) && ?req this:asin _:10.XPath(tns:ASIN, 92caa54) && ?req this:title _:11.XPath(tns:Title, 9302a7c)) -->{AWSECommerceService:ItemLookup}
_:22 this:asin _:20.XPath(tns:ASIN, 92caa54) .
-->{
[
fwrule ask(?req this:id XPath(., 8b4f4e4) && ?req this:keywords XPath(tns:Keywords, 919cc14) && ?req this:index XPath(tns:SearchIndex, 919cc14)) assert(?req this:reqId _:19.XPath(., 9238158) && ?req this:asin _:20.XPath(tns:ASIN, 92caa54) && ?req this:title _:21.XPath(tns:Title, 9302a7c)) -->{AWSECommerceService:ItemSearch}
_:22 this:index "Books" .
-->{<>}
_:22 this:id "0FWYBWB91M5S26YBE382" .
-->{<>}
_:22 this:keywords "Weaving" .
-->{<>}
]
}
_:22 this:id "0FWYBWB91M5S26YBE382" .
-->{<>}
]
}
_:21.XPath(tns:Title, 9302a7c)
_:8.XPath(this:Items/this:Item/this:DetailPageURL, 9262250)
_:22
_:10.XPath(tns:ASIN, 92caa54)
_:22 this:id "0FWYBWB91M5S26YBE382" .
-->{<>}
_:22 this:keywords "Weaving" .
-->{<>}
_:22 this:index "Books" .
-->{<>}
_:22 this:asin _:10.XPath(tns:ASIN, 92caa54) .
-->{
[
fwrule ask(?req this:id XPath(., 9196e80) && ?req this:asin XPath(., 9229db8)) assert(?req this:page _:8.XPath(this:Items/this:Item/this:DetailPageURL, 9262250) && ?req this:reqId _:9.XPath(., 9238158) && ?req this:asin _:10.XPath(tns:ASIN, 92caa54) && ?req this:title _:11.XPath(tns:Title, 9302a7c)) -->{AWSECommerceService:ItemLookup}
_:22 this:asin _:20.XPath(tns:ASIN, 92caa54) .
-->{
[
fwrule ask(?req this:id XPath(., 8b4f4e4) && ?req this:keywords XPath(tns:Keywords, 919cc14) && ?req this:index XPath(tns:SearchIndex, 919cc14)) assert(?req this:reqId _:19.XPath(., 9238158) && ?req this:asin _:20.XPath(tns:ASIN, 92caa54) && ?req this:title _:21.XPath(tns:Title, 9302a7c)) -->{AWSECommerceService:ItemSearch}
_:22 this:index "Books" .
-->{<>}
_:22 this:id "0FWYBWB91M5S26YBE382" .
-->{<>}
_:22 this:keywords "Weaving" .
-->{<>}
]
}
_:22 this:id "0FWYBWB91M5S26YBE382" .
-->{<>}
]
}
_:22 this:title _:21.XPath(tns:Title, 9302a7c) .
-->{
[
fwrule ask(?req this:id XPath(., 8b4f4e4) && ?req this:keywords XPath(tns:Keywords, 919cc14) && ?req this:index XPath(tns:SearchIndex, 919cc14)) assert(?req this:reqId _:19.XPath(., 9238158) && ?req this:asin _:20.XPath(tns:ASIN, 92caa54) && ?req this:title _:21.XPath(tns:Title, 9302a7c)) -->{AWSECommerceService:ItemSearch}
_:22 this:index "Books" .
-->{<>}
_:22 this:id "0FWYBWB91M5S26YBE382" .
-->{<>}
_:22 this:keywords "Weaving" .
-->{<>}
]
}
_:22 this:page _:8.XPath(this:Items/this:Item/this:DetailPageURL, 9262250) .
-->{
[
fwrule ask(?req this:id XPath(., 9196e80) && ?req this:asin XPath(., 9229db8)) assert(?req this:page _:8.XPath(this:Items/this:Item/this:DetailPageURL, 9262250) && ?req this:reqId _:9.XPath(., 9238158) && ?req this:asin _:10.XPath(tns:ASIN, 92caa54) && ?req this:title _:11.XPath(tns:Title, 9302a7c)) -->{AWSECommerceService:ItemLookup}
_:22 this:asin _:20.XPath(tns:ASIN, 92caa54) .
-->{
[
fwrule ask(?req this:id XPath(., 8b4f4e4) && ?req this:keywords XPath(tns:Keywords, 919cc14) && ?req this:index XPath(tns:SearchIndex, 919cc14)) assert(?req this:reqId _:19.XPath(., 9238158) && ?req this:asin _:20.XPath(tns:ASIN, 92caa54) && ?req this:title _:21.XPath(tns:Title, 9302a7c)) -->{AWSECommerceService:ItemSearch}
_:22 this:index "Books" .
-->{<>}
_:22 this:id "0FWYBWB91M5S26YBE382" .
-->{<>}
_:22 this:keywords "Weaving" .
-->{<>}
]
}
_:22 this:id "0FWYBWB91M5S26YBE382" .
-->{<>}
]
}

The provenance for the rules derived from operations require further resolution. Each solution represents a choreography; a way to solve the given query. This system finds the closure of all the potential information (at any cost) so each solution is expanded to include the data bound by matching the XPath against the results of invoking the appropriate query. (A system that included costs could chose from solutions by examining costs associated with the web services implied by the proofs.)

When exploring the proofs, the inner-most proof represents the first rule to fire, and therefore, the first service to execute. In this case, ItemSearch must be executed in order to get the asin necessary to invoke ItemLookup. Executing this service provides a set of zero or more new bindings. Each solution invoking that service is examined, replacing the solution with the number of new bindings coming from the invocation. The next outermost service is invoked, once for each of the input bindings in te solution set.

A. Related Resources