One Star

Data from and to a webservice

Hi everybody,
I know that with Talend, you can easily design a job and then call it via a web-service.
My question is: can we pass data to this job, and then receive data from it?
To make my point clearer, let's imagine a situation where I have a simple form with 2 or 3 fields. Each time this form is submitted, i want to send the entered data (using a webservice call) to a Talend job that will store the data in the proper databases, and then I want the job to send a confirmation response back.
Can I use Talend to implement this situation?
Thanks

15 REPLIES
Community Manager

Re: Data from and to a webservice

Hi Ihab
Can I use Talend to implement this situation?

yes, it can implement this situation with TOS. You can use the tWebServiceInput or another internet component to get data from web-service. and then, use the tSendMail component to send a confirmation response back.
I wonder what kind of data will you get from web-service. Please show more detailed information and what is your expected result. So, we can give you more precise response.
Feel free to post your question.
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Data from and to a webservice

Thanks for your prompt response,
However, what I am trying to say is that i need to pass arguments(data) to the talend job when I call it as a webService ( And not call a webService from the talend job to get the data).
For the moment, I only succeded to call it as a webservice( by simply exporting it as a webService) without passing any arguments(data) to it.
In the same perspective, I need to be able to send a soap response(and not a mail response) that contains some data.
Is this possible?
Thanks again
One Star

Re: Data from and to a webservice

Hi,
I had the same problem and finally found an awkward way to solve it. For the context-parameter named 'fileName1' call it like this and it works:
http://localhost/talend/services/MyFirstJob?method=runJob&args=--context_param%20fileName1=xxx
%20 = whitespace
Kind regards
Akapella.
PS: Have look into the source-code of your job-definitino (e.g. MyJob.java); at the end of the file you will find the method evalParam which reads parameters!
One Star

Re: Data from and to a webservice

hi ihab
you can try this code it runs correctly:



<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="org.apache.axis.client.Call" %>
<%@ page import="org.apache.axis.client.Service" %>




type="text/css">
t1.jsp


<%
try {
String endpoint = "http://localhost:8080/base/services/process";

Service service = new Service();
Call call = (Call) service.createCall();

call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName("runJob");
String to = request.getParameter("to");
String from = request.getParameter("from");
String cc = request.getParameter("cc");
String sujet = request.getParameter("sujet");
String message = request.getParameter("message");

Object[] myParams = new Object;
myParams = (Object) new String("--context_param to="+to);
myParams = (Object) new String("--context_param from="+from);
myParams = (Object) new String("--context_param cc="+cc);
myParams = (Object) new String("--context_param sujet="+sujet);
myParams = (Object) new String("--context_param message="+message);
String returns = (String) call.invoke(myParams);

System.out.println("Return: " + returns);
%>
Message enregistré<%
} catch (Exception e) {
System.err.println("erreur : "+e.toString());
}
%>

Fin du traitement
One Star

Re: Data from and to a webservice

Hi everybody
I have also a data-flow project.
Getting some runtime parameters to the job via Args seems feasible but how to send back data?
I think the SendMail is not really what should happen here. File is out of question and database is also not the solution, neither the console - what is left ?
My question: How far away is a tWebServiceOutput Component ? Has anybody done it yet ?
Comments welcome
Benjamin
One Star

Re: Data from and to a webservice

Hi Folks,
I'm with Benjamin on this topic. Is there a tWebServiceOutput component on the Talend component development schedule? If so, when is it scheduled to be completed.
If not, are you looking for the community to create one? This may not be a bad thing but if there is no agenda to create such a component, it would be best to give that information to the talend community so someone can start looking into creating such a component.
Simply put, I want to send results from this wonderful tool to my webservices and the tWebServiceOutput seems to be the answer. Thoughts or comments? (rants?)
Cheers
Darren
Employee

Re: Data from and to a webservice

Have look at Export a job as webservice and tell us if it fits your need.
One Star

Re: Data from and to a webservice

@Darren
you wrote: "... results from this wonderful tool to my webservices.." this would mean, Talend is the webservices client. This works already.
in the meantime I got a hint to use tBufferOutput . This component does produce a SOAP Output as used in Webservices, but it doesn't produces the according wsdl definition file...
So we have to create a job which ends in tBufferOutput, export that job as a webservice and deploy it on a webserver. If you use .../RunJob, you will see the results.
Arguments are passed as usual.
@plegall
Your answer is not targeting the question / problem. Maybe my explanation above makes it clearer.
Thanks for your Input
& cheers
B.
One Star

Re: Data from and to a webservice

Thanks for the quick reply.
We took a look at the wiki and it describes how to create a webservice. We are looking to talk to an existing webservice (as a client).
For example, I have a talend job which gives me currency exchange rate values. I want to call a webservice in an external application and send it the currency exchange rate information. Let's assume that I do not have control of the external web service application and I do not have access to its database.
The talend job already exists and the external web service which accepts the currency exchange rate already exists but we need to link the two together.
Simply put, we are looking to take data from a talend job and send it to a NON-talend web service. We are looking for the opposite of tWebserviceInput; a simple way of calling a webservice and sending it data. There are complementary tFileInput/tFileOutput components but webservices has only an input component.
We looked a the tWebserviceInput component and it appears that for simple output it may be able to be used. However, the interface has no helpers and it generally assume a very simple call interface which is not appropriate for complex situations.
Thought and comments are always welcome.
Thanks everyone.
Darren
One Star

Re: Data from and to a webservice

Hi everyone,
Is tWebServiceOutput available in next release? I don't see this component available in 3.0.3.
Thanks,
CC
One Star

Re: Data from and to a webservice

Hi all,
I use Talend to create two different kind of jobs :
- batch launched with a .sh file
- webservices called by other applications.
In those batches jobs I use context variables in order to determine datas needed for the database connection. No problem !
But in my webservices I would like to pass some parameters like a name or something else. Should I use context variables too or is there something else ?
I would like to distinguish system parameters (parameters for the database) and functional parameters (the real webservice parameters).

Sorry for my english ...
Thx in advance
One Star

Re: Data from and to a webservice

I have a same question , I have job data base in talend and have to pass data from talend data base to web services through which i can create a data in mine data base
please suggest how can proceed for this
Thanks!
One Star

Re: Data from and to a webservice

I have similar problem and I cannot fin the information in the forum.
My question is regarding in more details the usage of the web-service call (see the attached picture)
My web service have a method who takes two parameters like in the following exemple:





CHF

EUR



I want these two parameters to be injected from a DB table (a view in fact).
I cannot find the place where I can define FromCurrency and ToCurrency in the webservice_input component.
Are the values passed by order (the 1st one will be FromCurrency, and the 2nd mapped to ToCurrency implicitely)
I tried like this but I got an error :
Exception in component tWebServiceInput_1
java.lang.RuntimeException: not know how to convert 'CHF' into org.apache.axis.client.Call@1f54c5f
at org.talend.DynamicInvoker.getParamData(DynamicInvoker.java:370)
...
Like the parameters are not in the right type (the values are String in DB and iterated from the mySqlInput)
Note that with SOAPUI, the service is working fine.
I tried to follow the instruction from this post: http://www.talendforge.org/forum/viewtopic.php?pid=11201#p11201
Thanks in advance for your help.

Patrick
One Star

Re: Data from and to a webservice

any update on this one? i seem to have the same need:
user input query in a web page --> talend exported job as web service --> call to database --->|
display db data as tables/db structure not SOAP <-- talend exported job as web service<-- returned db data <--- |
One Star

Re: Data from and to a webservice

Hi All,
Even am also looking for the same.
Can anyone please help ?
Thanks,
Arun