One Star

Passing Variable from tXMLMap to tSendMail

Hi Talend Masters,
I have problem when passing parameters/variable from tXMLMap to tSendMail.
I suppose to set mail input such as To, From, etc from Web Service Consumer then Received and map using tXMLMap then send the variable to tJavaFlex before the variable is setted to tSendMail.
On tXMLMap, I got the request like as follows:
<?xml version="1.0" encoding="UTF-8"?>
<tns:MailServiceOperationRequest xmlns:tns="http://www.talend.org/service/"><from>theTalend@abc.com</from><to>theTalend@abc.com</to><cc>theTalen...>
then I set to tJavaFlex:
String from = context.getProperty("from");
String to = context.getProperty("to");
String cc = context.getProperty("cc");
String attachment = context.getProperty("attachment");
String message = context.getProperty("from");
then I set to tSendMail All those as variable.
I got error like this:
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:344)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:310)
at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:72)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:943)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:879)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
at org.eclipse.jetty.server.Server.handle(Server.java:345)
at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:441)
at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:936)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:801)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:224)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at commonservice1.mailserviceoperation_0_1.MailServiceOperation.tESBProviderRequest_1_LoopProcess(MailServiceOperation.java:2299)

Please help!!
Thanks a lot
1 REPLY
Community Manager

Re: Passing Variable from tXMLMap to tSendMail

Hi
After tXMLMap, you need to use a tExtractXMLField to extract the value of the elements such as To, From etc.
The job looks like:
....tXMLMap--tExtractXMLField--tJavaRow
|
onsubjobok
|
tSendMail
on tJavaRow, set the value to context variables like:
context.to=input_row.TO;
Please read this online user manual to learn tExtractXMLField component.
https://help.talend.com/search/all?query=tExtractXMLField&content-lang=en
Let me know if you have any troubles!
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business