One Star

[resolved] tRESTRequest - Payload Data Not Visible via Http POST method

Hi All,
I want to establish and use a Talend REST Service to retrieve and update sensitive information.  
I don’t want this information to be in clear-text in the URI of the service call.  To accomplish this, it is my understanding that the tRestRequest End Point should use the HTTP POST instead of HTTP GET and all sensitive parameters can be delivered as a separate XML payload.
The problem I am having is that the Payload Data coming from the Rest Client is not being referenced properly by the service End Point and therefore not being propagated through the process.  To demonstrate this issue in the simplest fashion, I have constructed a couple of simple Talend jobs. 
Server Job:
   
  
Server Output:
Starting job readPayLoadTest at 09:45 08/12/2014.
connecting to socket on port 3473
connected
: org.apache.cxf.endpoint.ServerImpl - Setting the server's publish address to be 
: org.eclipse.jetty.server.Server - jetty-8.1.15.v20140411
: org.eclipse.jetty.server.AbstractConnector - Started SelectChannelConnector@127.0.0.1:8090
: org.apache.cxf.interceptor.LoggingInInterceptor - Inbound Message
----------------------------
ID: 1
Address: 
Encoding: ISO-8859-1
Http-Method: POST
Content-Type: application/xml
Headers: {Accept=, Cache-Control=, connection=, Content-Length=, content-type=, Host=, Pragma=, User-Agent=}
Payload: <?xml version="1.0" encoding="UTF-8"?>
<root><id>1</id></root>                                      <--- Data Coming from Client
--------------------------------------
: org.apache.cxf.interceptor.LoggingOutInterceptor - Outbound Message
---------------------------
ID: 1
Response-Code: 200
Content-Type: application/xml
Headers: {Content-Type=, Date=}
Payload: <?xml version="1.0" encoding="UTF-8"?>
<root><id/></root>                                        <--- Data not propagated to response      
--------------------------------------
Client Job:
  
Client Output:
Starting job testPost at 09:46 08/12/2014.
connecting to socket on port 3937
connected
: org.apache.cxf.interceptor.LoggingOutInterceptor - Outbound Message
---------------------------
.----------+---------------------------------------------------------+------.
|                                 tLogRow_1                                 |
|=---------+---------------------------------------------------------+-----=|
|statusCode|body                                                     |string|
|=---------+---------------------------------------------------------+-----=|
|200       |<?xml version="1.0" encoding="UTF-8"?>
<root><id/></root>|null  |                                        <--- Data not propagated to response      
'----------+---------------------------------------------------------+------'
disconnected
Job testPost ended at 09:46 08/12/2014.
CURL Output:
$ curl -X POST -H "Content-Type: application/xml" -H "Accept: application/xml" -d "<root><id>1</id></root>" "http://localhost:8090/services/customers/customer"
<?xml version="1.0" encoding="UTF-8"?>
<root><id/></root>                                              <--- Data not propagated to response  
As you can see from the output data above, the data is successfully being passed to the Server with the HTTP POST method but is not being propagated to the response.
For what it's worth, the example in Scenario 3 in the Documention at help.talend.com/display/TalendOpenStudioComponentsReferenceGuide55EN/tRESTRequest basically eliminates the benefits of an HTTP POST request by putting identifying information in URI.  This, in my opinion is no better than an HTTP GET Method.
Please advise..
System Info:
      Talend Version: "Talend Open Studio for ESB" Version: 5.6.0 Build id: V5.6.0_20141024_1545
Operating System: Windows 8.1 Enterprise 64-bit (6.3, Build 9600) (9600.winblue_r3.140827-1500)
           Processor: Intel(R) Xeon(R) CPU E5-2690 v2 @ 3.00GHz (4 CPUs), ~3.0GHz
              Memory: 8192MB RAM
1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: [resolved] tRESTRequest - Payload Data Not Visible via Http POST method

You don't define the schema of tRestRequest correctly, the data type should be Document and set the same payload structure on tXMLMap as input schema of tRestClient.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
2 REPLIES
Community Manager

Re: [resolved] tRESTRequest - Payload Data Not Visible via Http POST method

You don't define the schema of tRestRequest correctly, the data type should be Document and set the same payload structure on tXMLMap as input schema of tRestClient.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] tRESTRequest - Payload Data Not Visible via Http POST method

Thank you Shong!
Per your recommendations, I was able to get this working by changing the tRESTRequest input schema and tXMLMap in the server job as shown below respectively:
 
Here's the new output:
Starting job readPayLoadTest at 09:29 09/12/2014.
connecting to socket on port 3932
connected
: org.apache.cxf.endpoint.ServerImpl - Setting the server's publish address to be 
: org.eclipse.jetty.server.Server - jetty-8.1.15.v20140411
: org.eclipse.jetty.server.AbstractConnector - Started SelectChannelConnector@127.0.0.1:8090
: org.apache.cxf.interceptor.LoggingInInterceptor - Inbound Message
----------------------------
ID: 1
Address: 
Encoding: ISO-8859-1
Http-Method: POST
Content-Type: application/xml
Headers: {Accept=, Cache-Control=, connection=, Content-Length=, content-type=, Host=, Pragma=, User-Agent=}
Payload: <?xml version="1.0" encoding="UTF-8"?>
<root><id>1</id></root>
--------------------------------------
: org.apache.cxf.interceptor.LoggingOutInterceptor - Outbound Message
---------------------------
ID: 1
Response-Code: 200
Content-Type: application/xml
Headers: {Content-Type=, Date=}
Payload: <?xml version="1.0" encoding="UTF-8"?>
<root><id>1</id></root>                          <---Data successfully read from Payload and propagated to REST Response.
--------------------------------------