TopQuadrant - SPARQLMotion - Example DBPediaCallingCodes Service products

SPARQLMotion Example DBPediaCallingCodes Service

This SPARQLMotion script defines a Web Service that can be called to get the name of the country for a given calling code. The script takes a calling code as input and then runs a query against the DBPedia SPARQL end point to retrieve the label of the first place with this calling code. Then, it constructs a response string and sends it back as text.

To try this example, download the file below into your TopBraid Composer (Maestro) workspace, then open the file to activate the services registry at Maestro's internal web server, and then open a URL such as the following in your web browser:

http://localhost:8083/tbl/servlet?action=sparqlmotion&id=FindByCallingCode&callingCode=61

Example response: 61 is the calling code of Australia.

Download in N3 format (2008-03-11)

DBPedia Calling Codes Service graph

Details on the steps (in order to execution from top to bottom) follow.

Get calling code (type: Bind with parameter) serves as entry point of this Web Service. It will receive the parameter callingCode from the HTTP request and bind it into the SPARQLMotion variable callingCode. It will convert the type of the parameter into an xsd:integer variable so that it can be handled as a number in the rest of the script. Get Calling code form
Get country from DBPedia (type: Bind by select) performs a SPARQL SELECT query on the DBPedia SPARQL end point (specified in the FROM clause). The query already has the value for callingCode bound with the parameter from the first step. It will first ask for the country with the given calling code and then get the label of that country. The label will be assigned to the variable label and passed to the next modules. Get country from DBPedia form
Construct response (type: Bind literal value) creates a single text value by inserting the callingCode and the label into a template. The text variable has the same name as the input variable of the next module and therefore will serve as input to the final step. Construct response form
Find by calling code (type: Return text) takes the text as input and returns it to the client. The URI, qname or rdfs:label of this service act as identifier when the service is called on the TopBraid Live server from the outside. Find by calling code form