Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

ETranslation Connect To Webservice

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

How to submit a translation request via the CEF

eTranslation webservice
CEF Automated Translation Internal

Exported on  10/22/2018


CEF Automated Translation Internal  –  How to submit a translation request via the CEF eTranslation webservice

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

2 Accessing the web service


To obtain the credentials needed to access the service you will need to request them from CEF-AT@ec.europa.eu1.

1 mailto:CEF-AT@ec.europa.eu

Accessing the web service  –  5


CEF Automated Translation Internal  –  How to submit a translation request via the CEF eTranslation webservice

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.

The structure of the XML message to send a request is below.


Sample translation request for a a text snippet :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cef="http://


cef.dgt.ec.europa.eu">
<soapenv:Header/>
<soapenv:Body>
<cef:translate>
<arg0>
<!--Optional:-->
<priority>0</priority>
<!--Optional:-->
<external-reference>clientRequestId</external-reference>
<caller-information>
<application>CLIENT_APPLICATION_NAME</application>
<username>toto</username>
<!--Optional:-->
<institution>eu.europa.ec</institution>
<!--Optional:-->
<department-number>DGT.R.3.002</department-number>
</caller-information>
<text-to-translate>Hello World!</text-to-translate>
<source-language>DE</source-language>
<target-languages>

2 https://etranslation.ec.testa.eu/etranslation/
3 https://webgate.ec.europa.eu/etranslation/si/WSEndpointHandlerService?WSDL

WSEndPointHandlerService and SecuredWSEndPointHandlerService   –  6


CEF Automated Translation Internal  –  How to submit a translation request via the CEF eTranslation webservice

<!--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>

Sample translation request for a FTP or SFTP reference to a document  :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cef="http://


cef.dgt.ec.europa.eu">
<soapenv:Header/>
<soapenv:Body>
<cef:translate>
<arg0>
<!--Optional:-->
<priority>0</priority>
<!--Optional:-->
<external-reference>clientRequestId</external-reference>
<caller-information>
<application>CLIENT_APPLICATION_NAME</application>
<username>toto</username>
<!--Optional:-->
<institution>eu.europa.ec</institution>
<!--Optional:-->
<department-number>DGT.R.3.002</department-number>
</caller-information>
<document-to-translate-path>ftp://user:pass@server:port/path...../file.doc</document-to-
translate-path>
<source-language>DE</source-language>
<target-languages>
<!--Zero or more repetitions:-->
<target-language>EN</target-language>

WSEndPointHandlerService and SecuredWSEndPointHandlerService   –  7


CEF Automated Translation Internal  –  How to submit a translation request via the CEF eTranslation webservice

<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:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cef="http://


cef.dgt.ec.europa.eu">
<soapenv:Header/>
<soapenv:Body>
<cef:translate>
<arg0>
<!--Optional:-->
<priority>0</priority>
<!--Optional:-->
<external-reference>clientRequestId</external-reference>
<caller-information>
<application>CLIENT_APPLICATION_NAME</application>
<username>toto</username>
<!--Optional:-->
<institution>eu.europa.ec</institution>
<!--Optional:-->
<department-number>DGT.R.3.002</department-number>
</caller-information>
<document-to-translate-base64>
<content>0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAOwADAP7/CQAGAAAAAAAAAAAAAAABAAAAEAAAAAAAAAAA
EAAAAgAAAAEAAAD+////
AAAAAAAAAAD/////////////////////////////////////////////
AGkAbwBuAAAAAAAAAAAAAAA4AAIA////////////////
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
....

WSEndPointHandlerService and SecuredWSEndPointHandlerService   –  8


CEF Automated Translation Internal  –  How to submit a translation request via the CEF eTranslation webservice

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.

WSEndPointHandlerService and SecuredWSEndPointHandlerService   –  9


CEF Automated Translation Internal  –  How to submit a translation request via the CEF eTranslation webservice

 For text snippet requests, the translated text will be provided directly in the requester-callback response if
specified

• document-to-translate-path : the FTP or SFTP path of the document to translate


Example: ftp://user:password@ftp_server_name:21/mypath/myfile.doc
• document-to-translate-base64 : contains two mandatory and one optional tag which are described below:
1. content: base 64 content
2. format: format of the document. Accepted format are odt, ods,odp,odg, ott, ots, otp, otg, rtf, doc,
docx, xls, xlsx, ppt, ppts, pdf, txt, htm, html, xhtml, xml, xlf, xliff, sdlxliff, tmx, rdf
3. file-name: (optional) File name of the translated document without extension. It will be suffix by an
underscore en target language ISO code in uppercase - dot - chosen output format.

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>

 text-to-translate or document-to-translate-path and document-to-translate-base64 are mutually exclusive


which means if text-to-translate is filled the former two tags cannot be send. An validation error is
generated for such a scenario.

• priority: optional - Priority of the request. The default value is 0


Values must be between 0 and 9, with 9 being the highest priority. Requests with the highest priority will be
processed first. Depending on your profile, you will be granted a maximum priority level.
Example: 5
• external-reference: optional - external request ID. This parameter is the unique identifier of the request as
defined by the client application. It can be set to any value by the calling application.
Example: 123456789
• requester-callback: optional - This parameter specifies the URL that will be called at the end of the
translation process when the translation has finished successfully. This URL is called with the HTTP POST

WSEndPointHandlerService and SecuredWSEndPointHandlerService   –  10


CEF Automated Translation Internal  –  How to submit a translation request via the CEF eTranslation webservice

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

WSEndPointHandlerService and SecuredWSEndPointHandlerService   –  11


CEF Automated Translation Internal  –  How to submit a translation request via the CEF eTranslation webservice

<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>

WSEndPointHandlerService and SecuredWSEndPointHandlerService   –  12


CEF Automated Translation Internal  –  How to submit a translation request via the CEF eTranslation webservice

<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>

WSEndPointHandlerService and SecuredWSEndPointHandlerService   –  13


CEF Automated Translation Internal  –  How to submit a translation request via the CEF eTranslation webservice

4 Secured Web Services (SOAP and REST)


The secured version of the web service uses Digest access authentication. The service contract (WSDL) address is
still reachable without authentication.
The login is the same value that is passed in the <application> parameter. The password is the one provided by the
eTranslation team.
If you already have access to eTranslation, all that is required is to update the WSDL address with "https://
webgate.ec.testa.eu/etranslation/si/SecuredWSEndpointHandlerService?WSDL" and add the
"username' (application name) and "password" to your authentication request header. 
The behaviour of this type of authentication can be seen using SOAP-UI : in the "Auth" tab, enter authentication
information and send the request.

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.

Secured Web Services (SOAP and REST)  –  14


CEF Automated Translation Internal  –  How to submit a translation request via the CEF eTranslation webservice

5 Sample SOAP call


This example shows how to call the secured web service with Java :

public static long callWS(Translate translate) {


String login = ..... ;
String password = ..... ;
WebServiceTemplate template = new WebServiceTemplate();
try {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("eu.europa.ec.dgt.cef.core.model.generated");

template.setMarshaller(marshaller);
template.setUnmarshaller(marshaller);
template.setDefaultUri(URI);

Credentials credentials = new UsernamePasswordCredentials(login, password);


HttpComponentsMessageSender sender = new HttpComponentsMessageSender();
sender.setCredentials(credentials);
sender.afterPropertiesSet();
template.setMessageSender(sender);
JAXBElement<TranslateResponse> response = (JAXBElement<TranslateResponse>)
template.marshalSendAndReceive(URI, translate);
return response.getValue().getReturn();
} catch (Exception e) {
e.printStackTrace();
}
return -1;
}

Sample SOAP call  –  15


CEF Automated Translation Internal  –  How to submit a translation request via the CEF eTranslation webservice

6 RESTful Secured Web Service


eTranslation exposes a secured RESTful web service available at this address: https://webgate.ec.europa.eu/
etranslation/si/translate.
Authentication follows the approach taken for the SOAP web service.
The RESTful service must be called using POST, and the request body must contain the translation request as JSON
format.
Not all destinations are required. For snippets, the translated text is returned in the requesterCallback parameter.
Sample translation request for a a text snippet :

{
"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"]
}
}

Sample translation request for a FTP or SFTP reference to a document  :

{
"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" : {

RESTful Secured Web Service  –  16


CEF Automated Translation Internal  –  How to submit a translation request via the CEF eTranslation webservice

"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"]
}

Sample translation request for base64 encoded document in attachment :

{
"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"]
}
}

RESTful Secured Web Service  –  17


CEF Automated Translation Internal  –  How to submit a translation request via the CEF eTranslation webservice

7 Sample REST call (Java)

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 {

private static String createTranslationRequest(String fileName, String sourceLanguage) {


return new JSONObject().put("priority", 1)
.put("externalReference", "123")
.put("callerInformation", new JSONObject()
.put("application", "MY_APPLICATION")
.put("username", "toto"))
.put("textToTranslate", "this is a test")
.put("sourceLanguage", sourceLanguage)
.put("targetLanguages", new JSONArray().put(0, "FR"))
.put("domain", "SPD")
.toString();
}

public static void main(String[] args) {


try {
String url = "https://webgate.ec.europa.eu/etranslation/si/translate";
String userName = "*****";
String password ="*****";
DefaultHttpClient client = new DefaultHttpClient();
client.getCredentialsProvider().setCredentials(AuthScope.ANY,new
UsernamePasswordCredentials(userName, password));
HttpPost post = new HttpPost(url);
post.setEntity(new StringEntity(createTranslationRequest(null, "EN"),
ContentType.APPLICATION_JSON, "UTF-8"));
HttpClientParams.setRedirecting(post.getParams(), false);
HttpResponse response = client.execute(post);
System.out.println(response.getStatusLine().getStatusCode());
} catch (Exception e) {
e.printStackTrace();
}
 
}
 
}

Sample REST call (Java)  –  18


CEF Automated Translation Internal  –  How to submit a translation request via the CEF eTranslation webservice

Sample REST call (Java)  –  19


CEF Automated Translation Internal  –  How to submit a translation request via the CEF eTranslation webservice

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.

-20000 Source language not specified

-20001 Invalid source language

-20002 Target language(s) not specified

-20003 Invalid target language(s)

-20004 Priority out of range 0 -> 9

-20005 Caller information not specified

-20006 Missing application name

-20007 Application not authorized to access the service

-20008 Bad format for ftp address

-20009 Bad format for sftp address

-20010 Bad format for http address

-20011 Bad format for email address

-20012 Translation request must be text type, document path type or document base64 type and not several
at a time

-20013 Language pair not supported by the domain

-20014 Username parameter not specified

-20015 Extension invalid compared to the MIME type

-20016 Allowed priority exceeded

-20017 Username parameter too long

-20018 Invalid output format

-20019 Institution parameter too long

-20020 Department number too long

-20021 Text to translate too long

Error codes :   –  20


CEF Automated Translation Internal  –  How to submit a translation request via the CEF eTranslation webservice

-20022 Too many FTP destinations

-20023 Too many SFTP destinations

-20024 Too many HTTP destinations

-20025 Missing destination

-20026 Bad requester callback protocol

-20027 Bad error callback protocol

-20028 Concurrency quota exceeded

-20029 Document format not supported

-20030 Text to translate is empty

-20031 Missing text or document to translate

-20032 Email address too long

-20033 Cannot read stream

-20034 Output format not supported

-20035 Email destination tag is missing or empty

-20036 HTTP destination tag is missing or empty

-20037 FTP destination tag is missing or empty

-20038 SFTP destination tag is missing or empty

-20039 Document to translate tag is missing or empty

-20040 Format tag is missing or empty

-20041 The content is missing or empty

-20042 Source language defined in TMX file differs from request

-20043 Source language defined in XLIFF file differs from request

-40010 Too many segments to translate

-90000 Cannot connect to FTP

-90001 Cannot retrieve file at specified FTP address

Error codes :   –  21


CEF Automated Translation Internal  –  How to submit a translation request via the CEF eTranslation webservice

-90002 File not found at specified address on FTP

-90007 Malformed FTP address

-90012 Cannot retrieve file content on SFTP

-90013 Cannot connect to SFTP

-90014 Cannot store file at specified FTP address

-90015 Cannot retrieve file content on SFTP

-90016 Cannot retrieve file at specified SFTP address

Error codes :   –  22

You might also like