ETranslation Connect To Webservice
ETranslation Connect To Webservice
ETranslation Connect To Webservice
eTranslation webservice
CEF Automated Translation Internal
Table of Contents
1 Introduction ............................................................................................................. 3
2 Accessing the web service ....................................................................................... 5
3 WSEndPointHandlerService and SecuredWSEndPointHandlerService ............... 6
4 Secured Web Services (SOAP and REST) .............................................................. 14
5 Sample SOAP call................................................................................................... 15
6 RESTful Secured Web Service................................................................................ 16
7 Sample REST call (Java) ........................................................................................ 18
8 Error codes : ........................................................................................................... 20
– 2
CEF Automated Translation Internal – How to submit a translation request via the CEF eTranslation webservice
1 Introduction
This page describes how to submit a translation request to the CEF Automated Translation internal service
("eTranslation") via a Web Service call. This is a typical B2B integration scenario, where a client application needs
to send an automated translation request and receive the result. The interaction with the CEF Web Service
is asynchronous. This means that the client sends a translation request and is notified back at a later point in time
when the text snippet or document is translated. Thus, calling the web service doesn't block the client. However,
the client needs to expose a callback URL, where it receives a notification that a certain translation job is
completed. After translation is completed, eTranslation sends the translated text or document to the destination
URL specified by the Client.
The following steps illustrate this interaction:
1. The client sends a translation request to the eTranslation web service ;
2. eTranslation web service translates the text or document for all requested target languages ;
3. Each translated text or document is sent back to the target location and the client can be notified separately
for each target language via the callback URL.
4. eTranslation web service replies synchronously with the eTranslation request ID (positive number) or an
error code (negative number) ;
The above approach decouples the client from the eTranslation server. It's the responsibility of the Client to submit
the initial request, and react to the callback notification from the eTranslation server. eTranslation accepts and
sends back an external reference that allows the client to associate the callbacks with the translation requests that
the client sent earlier. This way the client knows to which translation request a callback refers to. A better approach
we recommend is for the client to use the request ID generated by eTranslation and sent with the translated text or
document. The Client should keep track of all pending translation requests by means of an internal list of external
references ("external-reference") - or eTranslation request ID ("request-id") and validate all callbacks to the
callback URL which corresponds to pending translation requests.
Introduction – 3
CEF Automated Translation Internal – How to submit a translation request via the CEF eTranslation webservice
Any post-processing of the translated text (e.g. applying naming convention or invoking further processing steps)
should be done in the client callback handler which is called by eTranslation server. eTranslation - being a generic
Translation Service - does not implement any client specific logic, in terms of naming conventions or bespoke
translation files. Because such requirements are known only by the client, any such post-processing operations
needs to be perform by the client service.
All requests for translation will be handled by a single Web Service, called WSEndpointHandlerService.
Introduction – 4
CEF Automated Translation Internal – How to submit a translation request via the CEF eTranslation webservice
1 mailto:CEF-AT@ec.europa.eu
3 WSEndPointHandlerService and
SecuredWSEndPointHandlerService
The service is accessible via the following URL on the Testa-NG network: https://webgate.ec.testa.eu/etranslation/
2
si/WSEndpointHandlerService?WSD3L or https://webgate.ec.testa.eu/etranslation/si/
SecuredWSEndpointHandlerService?WSDL for the secured version.
or via a standard Internet address: https://webgate.ec.europa.eu/etranslation/si/WSEndpointHandlerService?
WSDL or https://webgate.ec.europa.eu/etranslation/si/SecuredWSEndpointHandlerService?WSDL for the secured
version.
The entry point of the service conforms to the SOAP protocol.
It is a good idea to carry out some initial tests of translation requests using the SOAP UI tool available here:
https://www.soapui.org/
If you are unfamiliar with this tool, see https://www.soapui.org/soap-and-wsdl/getting-started.html for
basic instructions.
2 https://etranslation.ec.testa.eu/etranslation/
3 https://webgate.ec.europa.eu/etranslation/si/WSEndpointHandlerService?WSDL
<target-language>FR</target-language>
</target-languages>
<domain>SPD</domain>
<!--Optional:-->
<requester-callback>http://my-client-server/my-client-context/my-success-handler</requester-
callback>
<!--Optional:-->
<error-callback>http://my-client-server/my-client-context/my-error-handler</error-callback>
<destinations>
<!--Zero or more repetitions:-->
<email-destination>toto@ec.europa.eu</email-destination>
<!--Zero or more repetitions:-->
<http-destination>http://my-client-server/my-client-context/</http-destination>
<!--Zero or more repetitions:-->
<ftp-destination>ftp://user:password@ftp_server_name:2021/mycallback/</ftp-destination>
<!--Zero or more repetitions:-->
<sftp-destination>sftp://user:password@sftp_server_name:2021/mycallback/</sftp-destination>
</destinations>
</arg0>
</cef:translate>
</soapenv:Body>
</soapenv:Envelope>
Sample translation request for a base64 encoded document in the request body:
AAAAAAAAAAAAAAAAXwAAAHQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////////8AAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD+////AAAAAAAAAAA=
</content>
<format>doc</format>
<file-name>myfile</file-name>
</document-to-translate-base64>
<source-language>DE</source-language>
<target-languages>
<!--Zero or more repetitions:-->
<target-language>EN</target-language>
<target-language>FR</target-language>
</target-languages>
<domain>SPD</domain>
<!--Optional:-->
<requester-callback>http://my-client-server/my-client-context/my-success-handler</requester-
callback>
<!--Optional:-->
<error-callback>http://my-client-server/my-client-context/my-error-handler</error-callback>
<destinations>
<!--Zero or more repetitions:-->
<email-destination>toto@ec.europa.eu</email-destination>
<!--Zero or more repetitions:-->
<http-destination>http://my-client-server/my-client-context/</http-destination>
<!--Zero or more repetitions:-->
<ftp-destination>ftp://user:password@ftp_server_name:2021/mycallback/</ftp-destination>
<!--Zero or more repetitions:-->
<sftp-destination>sftp://user:password@sftp_server_name:2021/mycallback/</sftp-destination>
</destinations>
</arg0>
</cef:translate>
</soapenv:Body>
</soapenv:Envelope>
If you wish to avoid using an ftp server, one approach would be to:
1) Submit the document in the content parameter of the request in base64.
2) Specify an http destination in the list <destinations>.
The translation will be included in the request body of the HTTP call, as base64 encoded content.
Definition of Parameters:
• text-to-translate: the text to translate.
For text snippet requests, the translated text will be provided directly in the requester-callback response if
specified
Example:
<document-to-translate-base64>
<content>0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAOwADAP7/CQAGAAAAAAAAAAAAAAABAAAAEAAAAAAAAAAA
EAAAAgAAAAEAAAD+////
AAAAAAAAAAD/////////////////////////////////////////////
AGkAbwBuAAAAAAAAAAAAAAA4AAIA////////////////
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
....
AAAAAAAAAAAAAAAAXwAAAHQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////////8AAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD+////AAAAAAAAAAA=
</content>
<format>doc</format>
<file-name>myfile</file-name>
</document-to-translate-base64>
method.
The following parameters will be included in the POST request:
• target-language: If the original request contained more than one target language, this parameter is
set to the language of the delivered document. The callback URL will be called once for each target
language in the request.
• translated-text (optional): Translated text in the case of text snippet request.
• request-id: the request id
• external-reference (optional): if the external reference was provided into the initial request
requester-callback can also be a FTP or SFTP file address. In this case, a new file will be created which
contains the previous four parameters in JSON format. The file will be delivered to the FTP address specified.
Example: http://my-client-server/my-client-context/my-success-handler?my_own_requestID=1234567894
Example : ftp://user:password@ftp_server_name:2021/mycallback/5
• error-callback: optional - This parameter specifies the URL that will be called in case an error occurred
during the translation process.
This URL can be an HTTP address. In this case, this URL is called with the HTTP POST method.
The following parameters will be included in the POST request:
• error-code: Numeric code of the error.
• error-message: The description of the error.
• target-languages: Target language codes of the failed translation process.
• request-id: the eTranslation request id
• external-reference (optional): if the external reference was provided into the initial request
error-callback can also be an FTP or SFTP file address. In this case, a new file will be created which contains
the previous five parameters in JSON format. The file will be delivered to the FTP address specified.
Example : http://my-client-server/my-client-context/my-success-handler?my_own_requestID=123456789
Example : ftp://user:password@ftp_server_name:2021/mycallback/6
• source-language : Original language ISO 639-1 language code7 for the document to translate.
Example : EN
• target-languages : contains a one to many target-language tag, each with the ISO 639-1 language code8.
Example : <target-language>FR</target-language>
• caller-information: contains two mandatory tags and two optional described below:
1. application: Name of the client application. This parameter is used by the service to check if the
application is an allowed client. Any application name needs to be authorized by the CEF service
before it can be used.
2. username: the username of the submitter. This is free text that can be used as an additional
identifier.
3. institution: (Optional) parameter used to monitor the translation request. The parameter must be
an institution's domain name.
4. department-number : (Optional) parameter used to monitor the translation request. It may be the
department number of the connected user.
Example:
4 http://my-client-server/my-client-context/my-success-handler?my_own_requestID=123456789_
5 ftp://user:password@ftp_server_name:2021/mydocs/hello.doc
6 ftp://user:password@ftp_server_name:2021/mydocs/hello.doc
7 https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
8 https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
<caller-information>
<application>MY_APPLICATION_THAT_USES_THE_eTranslation_SERVICE</application>
<username>toto</username>
<!--Optional:-->
<institution>eu.europa.ec</institution>
<!--Optional:-->
<department-number>DGT.R.3.002</department-number>
</caller-information>
If you do not have a dedicated application name or if you encounter a problem with access rights, please
contact the eTranslation team (CEF-AT@ec.europa.eu)
• domain (optional): this makes it possible to choose translation engines that are tailored for certain
subjects. Generally available domains are:
• SPD: for neural and speed-optimized statistical engines on the cloud. This is the default.
• ALL: for the legacy MT@EC engines running in the data centre. These are statistical engines
optimised for quality.
• TRIS: Engines built using data from the technical regulation information system.
Use SPD unless you have a reason to choose otherwise. Some clients may also have specific engines only
available to them.
Example: SPD
• output-format (optional) : Used only for document translation (document-to-translate-path or document-
to-translate-base64 parameter specified). File extension of the translated file. If not specified, translated
files will have the same format as the input document. Note that sdlxliff is not supported as an output
format due to its proprietary nature. You can request xliff instead.
Example: doc
• destinations (optional if "text-to-translate" is present, mandatory for "document-to-translate-path"
or "document-to-translate-base64"): Clients can choose from four methods of delivery to receive their
translations:
1. email-destination (0 or unlimited repetition): the email address where the eTranslation server will
send the translated text snippet or document to the client.
2. http-destination (0 to 5 repetition) : the http URL to be called by the eTranslation server. Please
note the translation will be encoded in base 64 will be attached to the request body, or plain text if
original request is a text snippet. This also support https.
3. ftp-destination (0 to 5 repetition): the ftp address where will be put the translation. The
destination must be an ftp directory. The "/" at the end is optional. If the folder does not exist on the
ftp address a new one will be created.
4. sftp-destination (0 to 5 repetition) : the sftp address where will be put the translation. The
destination must be an sftp directory. The "/" at the end is optional. If the folder doesn't exist on the
sftp address a new one will be created.
Example:
<destinations>
<email-destination>toto@ec.europa.eu</email-destination>
<http-destination>http://my-client-server/my-client-context/</http-destination>
<ftp-destination>ftp://user:password@ftp_server_name:2021/mydestination/</ftp-destination>
<sftp-destination>sftp://user:password@sftp_server_name:2021/mydestination/</sftp-destination>
</destinations>
When the request is sent, the following logs are displayed in the "http logs" tab.
• Fri Jan 19 14:21:52 CET 2018:DEBUG:>> "POST /etranslation/si/SecuredWSEndpointHandlerService HTTP/
1.1[\r][\n]"
• Fri Jan 19 14:21:52 CET 2018:DEBUG:<< "HTTP/1.1 401 Unauthorized[\r][\n]"
• Fri Jan 19 14:21:52 CET 2018:DEBUG:<< "WWW-Authenticate: Digest realm="Contacts Realm via Digest
Authentication", qop="auth",
nonce="MTUxNjM2ODQxMjg2NTphYTEzYWViNjJjZWZjY2EyNGMzNzQ3YzNhMDQxZGM2MA=="[\r][\n]"
• ------------
• Fri Jan 19 14:21:52 CET 2018:DEBUG:>> "POST /etranslation/si/SecuredWSEndpointHandlerService HTTP/
1.1[\r][\n]"
• Fri Jan 19 14:21:52 CET 2018:DEBUG:<< "HTTP/1.1 200 OK[\r][\n]"
The initial call is not accepted, but is subsequently authenticated with the nonce.
template.setMarshaller(marshaller);
template.setUnmarshaller(marshaller);
template.setDefaultUri(URI);
{
"priority" : 0,
"externalReference" : "123",
"callerInformation" : {
"application" : .....,
"username" : .....
},
"textToTranslate" : "This is a small house",
"sourceLanguage" : "EN",
"targetLanguages" : [ "FR", "DE" ],
"domain" : "SPD",
"requesterCallback" : "http://my-client-server/my-client-context/my-success-handler",
"errorCallback" : "http://my-client-server/my-client-context/my-error-handler",
"destinations" : {
"httpDestinations" : ["http://my-client-server/my-client-context/"],
"ftpDestinations" : ["ftp://user:password@ftp_server_name:2021/mycallback/"],
"sftpDestinations" : ["sftp://user:password@sftp_server_name:2021/mycallback/"],
"emailDestinations" : ["toto@ec.europa.eu"]
}
}
{
"priority" : 0,
"externalReference" : "123",
"callerInformation" : {
"application" : .....,
"username" : .....
},
"documentToTranslatePath" : "ftp://mtservice:mtservice@gypsophila.cc.cec.eu.int:4021/Non-
Regression_Testing/eTR_Original_Source_Documents/FRDOC.doc",
"sourceLanguage" : "EN",
"targetLanguages" : [ "FR", "DE" ],
"domain" : "SPD",
"requesterCallback" : "http://my-client-server/my-client-context/my-success-handler",
"errorCallback" : "http://my-client-server/my-client-context/my-error-handler",
"destinations" : {
"httpDestinations" : ["http://my-client-server/my-client-context/"],
"ftpDestinations" : ["ftp://user:password@ftp_server_name:2021/mycallback/"],
"sftpDestinations" : ["sftp://user:password@sftp_server_name:2021/mycallback/"],
"emailDestinations" : ["toto@ec.europa.eu"]
}
{
"priority" : 0,
"externalReference" : "123",
"callerInformation" : {
"application" : .....,
"username" : .....
},
"documentToTranslateBase64" : {
"content" : "0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAOwADAP7/CQAGAAAAAAAAAAAAAAABAAAAEAAAAAAAAAAA
EAAAAgAAAAEAAAD+////AAAAAAAAAAD/////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
……
cgBkAEQAbwBjAHUAbQBlAG4AdAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAGgACAP///////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACYA
AAAkDgAAAAAAAAUARABvAGMAdQBtAGUAbgB0AFMAdQBtAG0AYQByAHkASQBuAGYAbwByAG0AYQB0
AGkAbwBuAAAAAAAAAAAAAAA4AAIA////////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAXwAAAHQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////////8AAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD+////AAAAAAAAAAA=",
"format" : "doc",
"fileName" : "out"
},
"sourceLanguage" : "EN",
"targetLanguages" : [ "FR", "DE" ],
"domain" : "SPD",
"requesterCallback" : "http://my-client-server/my-client-context/my-success-handler",
"errorCallback" : "http://my-client-server/my-client-context/my-error-handler",
"destinations" : {
"httpDestinations" : ["http://my-client-server/my-client-context/"],
"ftpDestinations" : ["ftp://user:password@ftp_server_name:2021/mycallback/"],
"sftpDestinations" : ["sftp://user:password@sftp_server_name:2021/mycallback/"],
"emailDestinations" : ["toto@ec.europa.eu"]
}
}
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.params.HttpClientParams;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONObject;
public class Test {
8 Error codes :
The below list displays all error codes and their description which the client could receive synchronously in case the
request is invalid. Please note the error code is a negative number. We choose to do that to make the difference
between valid request which is a positive number and invalid request which is a negative number.
-20012 Translation request must be text type, document path type or document base64 type and not several
at a time