One Star

XML file input to an operation of SOAP web service using tESBConsumer

Hi all,
I have to call a web service with this operation "call(string):string". This operation takes as input a string. Right?
But the input must be a XML file like this:
  <?xml version="1.0"?>
<Input>
<OpenSession>
<input1>hello</input1>
<input2>world</input2>
<input3>bye</input3>
</OpenSession>
</Input>

So I need to pass the XML file as text to tESBConsumer...
The flow is this:

tFixedInputFlow is linked to tMap component. The tMap component is sets in this way:

with expression:
TalendString.replaceSpecialCharForXML("<?xml version=\"1.0\" ?><Input><OpenSession><input1>")+ row3.input1+TalendString.replaceSpecialCharForXML("</input1><input2>")+row3.input2+TalendString.replaceSpecialCharForXML("</input2><input3>")+row3.input3+TalendString.replaceSpecialCharForXML("</input3></OpenSession></Input>")

But I get a compilation error "type mismatch: impossible convert from a String to a Document" on tESBConsumer, though the operation should take a string....
I'm new to Taled, so I don't now if this is the correctly way to do what I want. If there are other way...please tell me.
Thanks all.
9 REPLIES
One Star

Re: XML file input to an operation of SOAP web service using tESBConsumer

Hi Vincentdj,
Use txmlmap instead of tmap..Go with the following link for your reference
http://www.talendforge.org/tutorials/tutorial.php?idTuto=94.

Thanks,
One Star

Re: XML file input to an operation of SOAP web service using tESBConsumer

Hi
now I use tXMLMap as described. The job connects to webservice, but I get this error:
Fault {string: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.; code:{http://schemas.xmlsoap.org/soap/envelope/}Server.userException; detail:<?xml version="1.0" encoding="UTF-8"?>
Community Manager

Re: XML file input to an operation of SOAP web service using tESBConsumer

Hi
Do you really need tESBConsumer component to call your common SOAP web service?
The operation "call(string):string" requires a string input, you can use a tWriteXMLField to output a string with XML format, and use tWebservice or tSOAP component to call your SOAP webservice, the job looks like:
tFixedFlowInput--main--tWriteXMLField--main--tWebserviceInput(or tSOAP)--maign-->tLogRow
Refer to the component manual of tWriteXMLField component:
https://help.talend.com/search/all?query=tWriteXMLField&content-lang=en
Shon
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: XML file input to an operation of SOAP web service using tESBConsumer

Hi,
I tried with tWriteXMLField, both with tWebService and tSoap, but now I get a different error for each way.
with tWebService:
Inizio job provaforumwebser: 09:25 28/05/2014.
connecting to socket on port 3507
connected
Exception in component tWebService_1
java.lang.NullPointerException
at org.apache.cxf.common.util.Compiler.useJava6Compiler(Compiler.java:190)
at org.apache.cxf.common.util.Compiler.compileFiles(Compiler.java:144)
at org.apache.cxf.common.util.Compiler.compileFiles(Compiler.java:139)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.compileJavaSrc(DynamicClientFactory.java:599)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:367)
at org.talend.webservice.helper.ServiceInvokerHelper.createClient(ServiceInvokerHelper.java:143)
at org.talend.webservice.helper.ServiceInvokerHelper.getClient(ServiceInvokerHelper.java:134)
at org.talend.webservice.helper.ServiceInvokerHelper.invoke(ServiceInvokerHelper.java:235)
at test.provaforumwebser_0_1.provaforumwebser.tWriteXMLField_1_InProcess(provaforumwebser.java:1372)
at test.provaforumwebser_0_1.provaforumwebser$1ThreadXMLField_tWriteXMLField_1_Out.run(provaforumwebser.java:559)
disconnected
Job provaforumwebser ended at 09:25 28/05/2014.

while with tSOAP:
Inizio job provaforum: 09:46 28/05/2014.
connecting to socket on port 3663
connected
||<soapenv:Fault xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>soapenvSmiley Frustratederver.userException</faultcode><faultstring>org.xml.sax.SAXException: Bad envelope tag: Input</faultstring><detail><ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">appvmtest.sangiovannieruggi.it</ns1:hostname></detail></soapenv:Fault>
disconnected
Job provaforum ended at 09:46 28/05/2014.

Please, I tried in three way...but no work
Community Manager

Re: XML file input to an operation of SOAP web service using tESBConsumer

Hi
Exception in component tWebService_1
java.lang.NullPointerException
at org.apache.cxf.common.util.Compiler.useJava6Compiler(Compiler.java:190)

The tWebservice components requires a JDK to work. Please select a JDK java.exe in the Preferences/Talend/Java interpreter in the studio. It's not a bug, see this jira issue:
https://jira.talendforge.org/browse/TDI-25565
org.xml.sax.SAXException: Bad envelope tag: Input

It looks like you don't write a right SOAP message, you don' escape the double quotes with backslash "\", here I attach an example screenshot.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: XML file input to an operation of SOAP web service using tESBConsumer

I
have selected JDK java.exe, but now get this error:
Exception in component tWebService_1
java.lang.IllegalStateException: no source files
at com.sun.tools.javac.main.Main.error(Main.java:173)
at com.sun.tools.javac.main.Main.compile(Main.java:397)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:132)
at org.apache.cxf.common.util.Compiler.internalJava6Compile(Compiler.java:232)
at org.apache.cxf.common.util.Compiler.useJava6Compiler(Compiler.java:194)
at org.apache.cxf.common.util.Compiler.compileFiles(Compiler.java:144)
at org.apache.cxf.common.util.Compiler.compileFiles(Compiler.java:139)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.compileJavaSrc(DynamicClientFactory.java:599)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:367)
at org.talend.webservice.helper.ServiceInvokerHelper.createClient(ServiceInvokerHelper.java:143)
at org.talend.webservice.helper.ServiceInvokerHelper.getClient(ServiceInvokerHelper.java:134)
at org.talend.webservice.helper.ServiceInvokerHelper.invoke(ServiceInvokerHelper.java:235)
at test.provaforumwebser_0_1.provaforumwebser.tWriteXMLField_1_InProcess(provaforumwebser.java:1372)
at test.provaforumwebser_0_1.provaforumwebser$1ThreadXMLField_tWriteXMLField_1_Out.run(provaforumwebser.java:559)
disconnected
Job provaforumwebser ended at 10:47 28/05/2014.

while with tSOAP, I use a message from the input schema, because the flow is TFixedFowInput->tWriteXMLFiedl->TSOAP->tLogRow, so I use the output column of tWriteXML Field.
The wsdl is this (the soapAction is empty):
<wsdl:definitions xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://-----/JBFService" xmlns:intf="http://-----/JBFService" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://-----/JBFService">
<wsdl:message name="callResponse">
<wsdlSmiley Tongueart name="callReturn" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="callRequest">
<wsdlSmiley Tongueart name="xml" type="xsd:string"/>
</wsdl:message>
<wsdlSmiley TongueortType name="DefaultWebService">
<wsdlSmiley Surprisedperation name="call" parameterOrder="xml">
<wsdl:input message="impl:callRequest" name="callRequest"/>
<wsdlSmiley Surprisedutput message="impl:callResponse" name="callResponse"/>
</wsdlSmiley Surprisedperation>
</wsdlSmiley TongueortType>
<wsdl:binding name="JBFServiceSoapBinding" type="implSmiley Very HappyefaultWebService">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdlSmiley Surprisedperation name="call">
<wsdlsoapSmiley Surprisedperation soapAction=""/>
<wsdl:input name="callRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://services.PSGExt" use="encoded"/>
</wsdl:input>
<wsdlSmiley Surprisedutput name="callResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://------/JBFService" use="encoded"/>
</wsdlSmiley Surprisedutput>
</wsdlSmiley Surprisedperation>
</wsdl:binding>
<wsdl:service name="DefaultWebServiceService">
<wsdlSmiley Tongueort binding="impl:JBFServiceSoapBinding" name="JBFService">
<wsdlsoap:address location="http://-----/JBFService"/>
</wsdlSmiley Tongueort>
</wsdl:service>
</wsdl:definitions>
One Star

Re: XML file input to an operation of SOAP web service using tESBConsumer

someone can help me? please
Six Stars

Re: XML file input to an operation of SOAP web service using tESBConsumer

I would use SoapUI to find out what your complete message needs to look like in order to not generate any faults. Once you have a working example in SoapUI, you can build that message using the tXMLMap/tESBConsumer.
One Star

Re: XML file input to an operation of SOAP web service using tESBConsumer

Can anyone offer some tips please? I'm trying to follow the example posted in this thread
This is how a request must be made to the webservice , it's waiting for an xml string inside <XMLIN>
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="" xmlns:xsi="" xmlns:xsd=""><soap:Body><logicarxft xmlns=""><XMLIN>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;&lt;Transaction xmlns:xsi="" Target="Prod" TimeStamp="2013-10-30T09:57:10+01:00" xsi:type="TransactionRequestType"&gt;&lt;Control&gt;&lt;Requester Code="XXXX"&gt;&lt;Agency&gt;&lt;Code Value="ADMIN" /&gt;&lt;Agent Uid="XXXX" Pwd="XXXX" /&gt;&lt;/Agency&gt;&lt;/Requester&gt;&lt;/Control&gt;&lt;Action Purpose="Get" Code="FCLIENTS" /&gt;&lt;Code Owner="XXXX" /&gt;&lt;dynamic-array service="ListeTRi" operation="MajTri"&gt;&lt;Codes&gt;&lt;Code Value="700004" /&gt;&lt;/Codes&gt;&lt;/dynamic-array&gt;&lt;/Transaction&gt;</XMLIN></logicarxft></soap:Body></soap:Envelope>


I put the request in the tFixedFlowInput , a single table colum XMLIN with the value
"&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;&lt;Transaction xmlns:xsi="" Target="Prod" TimeStamp="2013-10-30T09:57:10+01:00" xsi:type="TransactionRequestType"&gt;&lt;Control&gt;&lt;Requester Code="XXXX"&gt;&lt;Agency&gt;&lt;Code Value="ADMIN" /&gt;&lt;Agent Uid="XXXX" Pwd="XXXX" /&gt;&lt;/Agency&gt;&lt;/Requester&gt;&lt;/Control&gt;&lt;Action Purpose="Get" Code="FCLIENTS" /&gt;&lt;Code Owner="XXXX" /&gt;&lt;dynamic-array service="ListeTRi" operation="MajTri"&gt;&lt;Codes&gt;&lt;Code Value="700004" /&gt;&lt;/Codes&gt;&lt;/dynamic-array&gt;&lt;/Transaction&gt;"

This is how my tXMLMAP looks like
onedrive.live.com/redir?resid=77E8039C68438481!444&authkey=!AAL_bJwdrc6zE58&v=3&ithint=photo%2cpng
 
I'm getting this error
 Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    XML_API_tXMLMap_1 cannot be resolved to a type
    XML_API_tXMLMap_1 cannot be resolved to a type
    Syntax error, insert ";" to complete BlockStatements
    at alim_logicar.esbconsumerlogicar_0_1.esbconsumerlogicar.tFixedFlowInput_1Process(esbconsumerlogicar.java:1501)
    at alim_logicar.esbconsumerlogicar_0_1.esbconsumerlogicar.runJobInTOS(esbconsumerlogicar.java:2723)
    at alim_logicar.esbconsumerlogicar_0_1.esbconsumerlogicar.main(esbconsumerlogicar.java:2580)