Each PTV xServer module comes with an API documentation that lists elements by kind.
Operations are grouped by web service (modelled as xService
classes). For instance, the XMap
service may define an operation renderMap. Operations may take parameters and return a result object or an exception.
For SOAP, the web service expects the so-called document/literal wrapped web service style. Each operation is represented by two complex types: one defining the request structure, and one defining the response structure. The operation is selected within the request. Names of parameters in SOAP request bodies do not match the ones in the documentation: They are enumerated using their type name and their position in the methods signature. If you create SOAP clients directly from the WSDL you will only see these names. The convenience Java and C#/.NET clients bundled with the PTV xServer are generated independently from the WSDL, and their parameters retain their original name.
For JSON, the services use a REST-like RPC style: each operation is represented by a unique end point (URL) and parameters are sent in one (anonymous) JSON request object. JSON objects include all names but few or no types.
Objects are structured and contain attributes with primitive values, enum values, or other objects.
Inside the WSDL you will find objects represented as complex types, and every array is represented with a wrapper element.
In JSON notation, objects are noted with curly brackets {}
, and arrays are directly represented with square brackets []
.
The deserializer will interpret a left out (undefined) attribute as having the default value.
Unless stated differently in the documentation, the default depends on the type: null, 0,
or false
.
The order of the attributes is not relevant in JSON objects. In standard JSON, all attribute names have to be quoted, and an extra comma at the end of a list is not valid. White space outside strings is optional and should be left out for transmission; examples in this manual contain extra white space only for readability.
The primitive value types used within the API have straight-forward mappings to SOAP, JSON, and most programming languages.
String, boolean, int, double
are well-known.
Boolean, Integer
and Double
are so-called boxed types which can be null
as well.
The type byte[]
used for binary data is treated as a Base64-encoded String.
The type Calendar
is serialized as a String in the xsd:dateTime
format, a subset of the ISO 8601 standard format.
Caution: Please make sure to always set all of the available properties to avoid errors based on misleadingly expected default values.
Enums are enumerations of legal values. The WSDL models enums as restricted strings. JSON also uses strings to represent enumeration values.
Exceptions define the error states that clients must deal with. There are typically three kinds of exception thrown by xServices:
Unmarshal Exception
This exception is thrown if the request does not match the defined schema. The exception does not contain detailed description of the error position.
xService Exception
An xService Exception will occur if the server rejects calls (due to overload detection), or runs into an error. If an xService Exception occurs and you are sure that there is no significant load, please check if the server is running and that there is no configuration problem.
SOAP represents exceptions as SOAP Faults. The sub-elements faultcode and faultstring contain the error key and the original error message. The detail element contains the original exception object in xml notation, which is used by the Java and C# clients to deserialize the exception. In JSON mode, exceptions are returned as anonymous JSON objects with the following attributes:
Attribute Name | Description |
---|---|
errorMessage
|
The original error message |
errorKey |
The error key |
exceptionType |
The exception type, e.g. Service Exception, xService Exception or JsonParseException |
errorLine |
In case of a JsonParseException this attribute holds the line number where the error occurred |
errorColumn |
In case of a JsonParseException this attribute holds the column number where the error occurred |
In contrast to SOAP where object properties are typed but are not named, objects in JSON are named but not typed. This brings a challenge for the polymorphic types that are part of the PTV xServer API.
In many cases, the type is obvious to the human eye, since instances of inherited types often have unique attributes that identify them unambiguously. Assigning a type according to observed names or values is called duck typing: If it looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck. Unfortunately, duck typing only works for cases when objects of different types do differ in attributes, and this is not always guaranteed in the current PTV xServer API.
Thus, the JSON web service falls back to type hinting. In all places where a polymorphic type is expected, there has to be a specially named property $type, providing the (unqualified) type name. We abstained from mixing type hinting and duck typing to avoid confusion and the necessity to write a type deserializer from scratch: currently, JSON frameworks do not handle duck typing well.
Type hints are only mandatory to indicate a subtype of the expected type for an attribute. If the concrete type matches the expected type (and is either a leaf type of the type hierarchy or a concrete base type), the type hint can be omitted. The following example shows a TourPointDesc
that tells the service that it is not a mere WaypointDesc
. A WaypointDesc
would not need a type annotation.
{ "$type": "TourPointDesc", "coords": [ { "point": { "x": 676437, "y": 6448604 } } ], "linkType": "NEXT_SEGMENT", "completeServiceInIntervals": true, "servicePeriod": 100, "useServicePeriodForRecreation": false }
The CallerContext is a set of properties that can be set for each request as an additional argument after the business parameters, similar to the RequestOptions
object as defined in the common
package.
Attribute Name | Type | Description |
---|---|---|
properties |
Key-Value list with keys and values from RequestOptions |
The request options to be used for this request. |
log1, log2, log3
|
String
|
Optional log strings that will be passed directly to the logging infrastructure, so that client requests may be aggregated by category name in the logs. |
There are a few noteworthy specialities:
The key
attributes of all properties
entries are capitalized.
ResponseGeometry
: You can make other geometries formats appear in the response object, by providing one of the following values, or a comma-separated list of them:
PLAIN
: the response should contain classic geometry objectsWKB
: Open-GIS Well Known Binary FormatWKT
: Open-GIS Well Known Text FormatKML
: Keyhole Markup Language FormatIf no geometry is set, the default is PLAIN
.
The value of the Profile
key is the name of a profile configured at the server with pre-set parameter values.
Many parameters can be set in the request too, in which case these values overwrite those defined in the profile.
The default profile is default
.
If a non-existing profile is requested this is used as a fallback, unless you specify failOnIllegalProfile=true
in the conf/xserver.properties
.
A TransactionId
(small d) can be provided by the client in order to be able to delete this specific request. Requests can be deleted manually in the PTV xServer Management Console, or programmatically by accessing URL http://<host>:<port>/<modulename>/pages/moduleCommand.jsp?deleteRequest=<transactionId>
.
This mechanism is deprecated for job transactions, you should use deleteJob
instead.
The key TenantId
sets a tenant name that serves as namespace for distance matrix ids (only for PTV xDima Server and PTV xTour Server).
Legal values for the property CoordFormat
are listed by the CoordFormat
enumeration.
An exception is the value OG_SRID
, which is implicitly set when a Spatial Reference Identifier as specified by the Open Geospatial Consortium (OGC) is set, such as EPSG:4326
. All codes of the EPSG Geodetic Parameter Dataset V7.9
maintained by the Geodesy Subcommittee of OGP are supported.
The coordinate format OG_GEODECIMAL and the SRID EPSG:4326 are equivalent.
Caution: Currently, EPSG codes can be set in the CallerContext only, they cannot be set in geodatasource configurations or XML profiles.
Example for a code snippet of a SOAP request with the caller context element:
<callerContext_5 log1="company name" log2="sector" log3=""> <wrappedProperties xmlns="http://baseservices.service.jabba.ptvag.com"> <CallerContextProperty key="CoordFormat" value="PTV_MERCATOR" /> <CallerContextProperty key="ResponseGeometry" value="PLAIN"/> <CallerContextProperty key="Profile" value="default" /> </wrappedProperties> </CallerContext_5>
Example for the Java client code corresponding to this SOAP request:
XLocateRemoteInterface xLocateClient = (XLocateRemoteInterface)ClientFactory.createClient(XLocateRemoteInterface.class, RemoteType.DOCSTYLE_CXF,"","",url); CallerContext ctx = new CallerContext(); ctx.setLog1("company name"); ctx.setLog2("sector"); CallerContextProperty ctxprop1 = new CallerContextProperty(); ctxprop1.setKey("CoordFormat"); ctxprop1.setValue("PTV_MERCATOR"); CallerContextProperty ctxprop2 = new CallerContextProperty(); ctxprop2.setKey("ResponseGeometry"); ctxprop2.setValue(GeometryEncoding.PLAIN.getValue()); CallerContextProperty ctxprop3 = new CallerContextProperty(); ctxprop3.setKey("Profile"); ctxprop3.setValue("default"); CallerContextProperty[] prop = { ctxprop1, ctxprop2, ctxprop3 }; ctx.setProperties(prop); xLocateClient.setCallerContext(ctx);
Entities marked as deprecated will be removed with the next major release (2.0, 3.0, ...).
There are functional alternatives available you can use instead. You should not use deprecated operations or options when you write new code.
Deprecated operations or options will not be extended but will still receive bug fixes and are still supported.
Copyright © 2024 PTV Logistics GmbH All rights reserved. | Imprint