Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

This document describes the structure and functionality in TermWebs XML-RPC API. For more information about XML-RPC see XML-RPC.com.

Introduction

The API usage from XML-RPC directly is basically the same as when using the Java API client as described in the Javadocs. First you call initSession to create a session in TermWeb and retrieve a session ID. Then you call any of the available methods described below and pass your session ID as argument to the method. Close your session by calling the close method.

Configuration

To configure the API with TermWeb you need to add a servlet configuration to TermWeb's web.xml file:

<servlet>
  <servlet-name>TermWebAPI</servlet-name>
  <servlet-class>org.termweb.api.internal.TermWebAPIServlet</servlet-class>
</servlet>

And then a mapping for the servlet:

<servlet-mapping>
  <servlet-name>TermWebAPI</servlet-name>
  <url-pattern>/api</url-pattern>
</servlet-mapping>

Connection example

The TermWeb API is configured at the URI /termweb/api by default, so if your TermWeb is installed at http://myserver.example.com/termweb the API is found at http://myserver.example.com/termweb/api.

The TermWeb API uses the prefix termwebapi2 for all methods.

Example code

Connect to the TermWeb server

connect('http://myserver.example.com/termweb/api');

Create a new session (as guest user)

<?xml version="1.0"?>
<methodCall>
   <methodName>termwebapi2.initSession</methodName>
   <params>
   </params>
</methodCall>

The response:

<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
  <params>
    <param><value>123456789abc</value></param>
  </params>
</methodResponse>

Close the session

<?xml version="1.0"?>
<methodCall>
   <methodName>termwebapi2.close</methodName>
   <params>
     <param><value><string>123456789abc</string></value></param>
   </params>
</methodCall>

The response:

<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
  <params>
    <param><value>0</value></param>
  </params>
</methodResponse>

Types

TermWeb XML-RPC API uses only data types from the original XML-RPC specification. The data types are listed in the table below. TermWeb objects are represented by <struct>s where the first <member> contains the type of the object.

Java TypeXML Tag Name
Integeri4 or int
Booleanboolean
Stringstring
Doubledouble
java.util.DatedateTime.iso8601
byte[]base64
java.util.Mapstruct
Object[] java.util.Listarray

Example of a Dictionary object:

  <value><struct>
    <member>
      <name>__objtype</name>
      <value>Dictionary</value>
    </member>
    <member>
      <name>id</name>
      <value>4212</value>
    </member>
    <member>
      <name>name</name>
      <value>My Dictionary</value>
    </member>
    <member>
      <name>description</name>
      <value>A test dictionary</value>
    </member>
  </struct></value>

Methods

Method nameArgumentsReturnsDescription
getTermWebVersionNoneVersion stringReturns the version string from TermWeb
initSessionNoneSession IDCreates a session as auto-login guest
initSessionclient, user, passwordSession IDCreates a session as for specified client and user
closesessionID-Closes the session
getAllsessionID, object typeArray of TermWeb objectsRetrieves all available objects of specified type. The possible types are dictionary, domain
setAllSelectedsessionID, object type-Selects all available objects of specified type. The possible types are section, domain
setSelectedsessionID, object type, ID-Select object with specified type and ID. The possible types are dictionary, language, domain, section
setSelectedsessionID, object type, array of IDs-Select all objects with specified type and IDs. The possible types are domain, section
getSelectedsessionID, object typeThe selected objectReturns the selected object of specified type. The possible types are dictionary
getIndexTermssessionID, search stringA list of index termsReturns the index terms that matches the search expression.
getIndexTermssessionID, search condition mapA list of index termsReturns the index terms that matches the search conditions
getIndexTermssessionID, search condition map, target languageA list of index termsReturns index terms for the specified target language corresponding to the index terms that matches the search conditions
getConceptEntrysessionID, conceptEntryIDA concept entry

Returns the concept entry with specified ID.

getSourceLanguagesessionIDA language codeReturns the ISO 639-2 language code for the currently selected source language
setSourceLanguagesessionID, language code-Sets the currently selected source language
getObjectsessionID, object type, idA TermWeb objectReturns the object with specified type and id
getObjectByNamesessionID, object type, nameA TermWeb objectReturns the object with specified type and name
createsessionID, object-Creates a new TermWeb object in the current context

Error handling

If an error occurs during processing of a method, an error message containing a description of the error together with an error code is returned.

Example: Failed to invoke method getAll in class org.termweb.api.internal.XmlRpcReceiver: The session has expired. (Code:1300)

The errors and codes are as follows:

CodeTypeError
1000Authentication




The max number of concurrent users is reached
1001The user account is disabled
1002

The client account is disabled

1003User is logged in from another IP address
1005No auto-login guest account exists
1006Unknown client account
1007Wrong login or password
1008API is disabled
1100AuthorizationUser is not authorized to perform this operation
1200Unknown objectNo such object (for specified ID or name)
1300Session expiredThe user's session has expired
1400Unsupported objectWrong object type for an argument in this method call
1500Not validatingObject is not complete or contains illegal values


  • No labels