• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » tWebService with array parameter

#1 2012-06-25 15:04:40

vincent13
Guest

tWebService with array parameter

Tags: [development]

Help please, I am new to TOS and have little java. I cant figure out how to use the tWebService with an array parameter.

The web service function has 3 params, two booleanst, a array of string.
I dont know how to fill transmit all of the array parameter.

The data for the array parameter comes from a table in a database each item in the array is a record in the database. A member of the class comes from a column in the database. i can query the database and get the rows, but how do I get the rows into the array parameter at the same time I get the other two params?

Is there some example I can see?


I saw this post of 2011-06-15:
Hi
Define a array on tJava, and set each item to array, the job looks like:
tMysqlInput--row1-->tFlowToIterate--iterate--tJava--oncomponent--tWebservice--main--tLogRow

on tJava:
Code:

String[] s=new String [2];
s[0]=row1.columnName1;
s[1]=row1.columnName2;
globalMap.put("array",s);
//set other parameters to global variable like that.

in the expression of array parameter on tWebService:
(String[])globalMap.get("array")

Best regards
Shong



but i don't know where put the line (String[])globalMap.get("array")   in what component Tjava, Twebservice

#2 2012-06-26 04:21:52

pedro
Member
Registered: 2011-11-17
Posts: 3682

Re: tWebService with array parameter

Hi

Just type the expression as the following image.

Regards,
Pedro


Uploaded Images


Only Paranoid Survive.

Offline

#3 2012-06-26 13:22:36

vincent13
Guest

Re: tWebService with array parameter

thank you very much

best regards

#4 2012-06-26 14:11:21

vincent13
Guest

Re: tWebService with array parameter

i've tried your solution but i've always error during execution: 

---------------------------------------------------------
Exception in component tWebService_3
java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.String;
    at ensosp.webservicegf4_0_1.WebServiceGF4.tWebService_3Process(WebServiceGF4.java:11465)
    at ensosp.webservicegf4_0_1.WebServiceGF4.tMysqlInput_3Process(WebServiceGF4.java:10642)
    at ensosp.webservicegf4_0_1.WebServiceGF4.tWarn_1Process(WebServiceGF4.java:1421)
    at ensosp.webservicegf4_0_1.WebServiceGF4.runJobInTOS(WebServiceGF4.java:15335)
    at ensosp.webservicegf4_0_1.WebServiceGF4.main(WebServiceGF4.java:15092)

--------------------------------------------------------

this is my wsdl file:

  <?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions targetNamespace="http://av08s-fin01:7020/gfprod/services/CreationTiers" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://av08s-fin01:7020/gfprod/services/CreationTiers" xmlns:intf="http://av08s-fin01:7020/gfprod/services/CreationTiers" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="CreationTiers" xmlns:tns2="http://bean.ws.framework.civitas.fr" xmlns:tns3="http://exception.metier.framework.civitas.fr" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <!--
WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)

  -->
- <wsdl:types>
- <schema targetNamespace="CreationTiers" xmlns="http://www.w3.org/2001/XMLSchema">
  <import namespace="http://av08s-fin01:7020/gfprod/services/CreationTiers" />
  <import namespace="http://exception.metier.framework.civitas.fr" />
  <import namespace="http://bean.ws.framework.civitas.fr" />
  <import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
- <complexType name="TiersWSBean">
- <sequence>
  <element name="code_banque" nillable="true" type="soapenc:string" />
  <element name="code_bic" nillable="true" type="soapenc:string" />
  <element name="code_btq" nillable="true" type="soapenc:string" />
  <element name="code_cle" nillable="true" type="soapenc:string" />
  <element name="code_compte" nillable="true" type="soapenc:string" />
  <element name="code_guichet" nillable="true" type="soapenc:string" />
  <element name="code_iban" nillable="true" type="soapenc:string" />
  <element name="code_mail" nillable="true" type="soapenc:string" />
  <element name="code_mode_paiement" nillable="true" type="soapenc:string" />
  <element name="code_pays" nillable="true" type="soapenc:string" />
  <element name="code_postal" nillable="true" type="soapenc:string" />
  <element name="code_siret_tiers" nillable="true" type="soapenc:string" />
  <element name="code_telephone" nillable="true" type="soapenc:string" />
  <element name="code_tiers" nillable="true" type="soapenc:string" />
  <element name="complement_adresse" nillable="true" type="soapenc:string" />
  <element name="descriptif_tiers" nillable="true" type="soapenc:string" />
  <element name="ets_cod" nillable="true" type="soapenc:string" />
  <element name="libelle_tiers" nillable="true" type="soapenc:string" />
  <element name="nom_rue" nillable="true" type="soapenc:string" />
  <element name="nom_ville" nillable="true" type="soapenc:string" />
  <element name="tie_dat_maj" nillable="true" type="xsd:date" />
  <element name="type_tiers" nillable="true" type="soapenc:string" />
  </sequence>
  </complexType>
- <complexType name="MessagesWSBean">
- <sequence>
  <element name="code" nillable="true" type="soapenc:string" />
  <element name="libelle" nillable="true" type="soapenc:string" />
  <element name="type" nillable="true" type="soapenc:string" />
  </sequence>
  </complexType>
- <complexType name="RetourTiersWSBean">
- <complexContent>
- <extension base="tns2:RetourWSBean">
- <sequence>
  <element name="listeTiersWSBean" nillable="true" type="impl:ArrayOf_tns1_TiersWSBean" />
  </sequence>
  </extension>
  </complexContent>
  </complexType>
  </schema>
- <schema targetNamespace="http://av08s-fin01:7020/gfprod/services/CreationTiers" xmlns="http://www.w3.org/2001/XMLSchema">
  <import namespace="http://exception.metier.framework.civitas.fr" />
  <import namespace="CreationTiers" />
  <import namespace="http://bean.ws.framework.civitas.fr" />
  <import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
- <complexType name="ArrayOf_tns1_TiersWSBean">
- <complexContent>
- <restriction base="soapenc:Array">
  <attribute ref="soapenc:arrayType" wsdl:arrayType="tns1:TiersWSBean[]" />
  </restriction>
  </complexContent>
  </complexType>
- <complexType name="ArrayOf_tns1_MessagesWSBean">
- <complexContent>
- <restriction base="soapenc:Array">
  <attribute ref="soapenc:arrayType" wsdl:arrayType="tns1:MessagesWSBean[]" />
  </restriction>
  </complexContent>
  </complexType>
  </schema>
- <schema targetNamespace="http://bean.ws.framework.civitas.fr" xmlns="http://www.w3.org/2001/XMLSchema">
  <import namespace="http://av08s-fin01:7020/gfprod/services/CreationTiers" />
  <import namespace="http://exception.metier.framework.civitas.fr" />
  <import namespace="CreationTiers" />
  <import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
- <complexType name="RetourWSBean">
- <sequence>
  <element name="etat" type="xsd:boolean" />
  <element name="messagesWSBean" nillable="true" type="impl:ArrayOf_tns1_MessagesWSBean" />
  </sequence>
  </complexType>
  </schema>
- <schema targetNamespace="http://exception.metier.framework.civitas.fr" xmlns="http://www.w3.org/2001/XMLSchema">
  <import namespace="http://av08s-fin01:7020/gfprod/services/CreationTiers" />
  <import namespace="CreationTiers" />
  <import namespace="http://bean.ws.framework.civitas.fr" />
  <import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
- <complexType abstract="true" name="MetierException">
  <sequence />
  </complexType>
  </schema>
  </wsdl:types>
- <wsdl:message name="creerTiersRequest">
  <wsdl:part name="code_interface" type="soapenc:string" />
  <wsdl:part name="listeTiers" type="impl:ArrayOf_tns1_TiersWSBean" />
  </wsdl:message>
- <wsdl:message name="MetierException">
  <wsdl:part name="fault" type="tns3:MetierException" />
  </wsdl:message>
- <wsdl:message name="creerTiersResponse">
  <wsdl:part name="creerTiersReturn" type="tns1:RetourTiersWSBean" />
  </wsdl:message>
- <wsdl:portType name="WebServiceTiersServiceImpl">
- <wsdl:operation name="creerTiers" parameterOrder="code_interface listeTiers">
  <wsdl:input message="impl:creerTiersRequest" name="creerTiersRequest" />
  <wsdl:output message="impl:creerTiersResponse" name="creerTiersResponse" />
  <wsdl:fault message="impl:MetierException" name="MetierException" />
  </wsdl:operation>
  </wsdl:portType>
- <wsdl:binding name="CreationTiersSoapBinding" type="impl:WebServiceTiersServiceImpl">
  <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="creerTiers">
  <wsdlsoap:operation soapAction="" />
- <wsdl:input name="creerTiersRequest">
  <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://impl.service.ti.commun.metier.civitas.fr" use="encoded" />
  </wsdl:input>
- <wsdl:output name="creerTiersResponse">
  <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://av08s-fin01:7020/gfprod/services/CreationTiers" use="encoded" />
  </wsdl:output>
- <wsdl:fault name="MetierException">
  <wsdlsoap:fault encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" name="MetierException" namespace="http://av08s-fin01:7020/gfprod/services/CreationTiers" use="encoded" />
  </wsdl:fault>
  </wsdl:operation>
  </wsdl:binding>
- <wsdl:service name="WebServiceTiersServiceImplService">
- <wsdl:port binding="impl:CreationTiersSoapBinding" name="CreationTiers">
  <wsdlsoap:address location="http://av08s-fin01:7020/gfprod/services/CreationTiers" />
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>


my components are    source(mysql/oracle) -> tflowtoiterate    ->  iterate ->   tjava    -> oncomponentok   -> twebservice


in TJAVA components with code:

String[] s=new String [20]; 

s[0]=Maj_Sans_Accent.ets_cod;
s[1]=Maj_Sans_Accent.code_tiers;
s[2]=Maj_Sans_Accent.code_siret_tiers;
s[3]=Maj_Sans_Accent.libelle_tiers;
s[4]=Maj_Sans_Accent.descriptif_tiers;
s[5]=Maj_Sans_Accent.code_postal;
s[6]=Maj_Sans_Accent.nom_ville;
s[7]=Maj_Sans_Accent.nom_rue;
s[8]=Maj_Sans_Accent.code_btq;
s[9]=Maj_Sans_Accent.code_pays;
s[10]=Maj_Sans_Accent.complement_adresse;
s[11]=Maj_Sans_Accent.code_telephone;
s[12]=Maj_Sans_Accent.code_mail;
s[13]=Maj_Sans_Accent.code_banque;
s[14]=Maj_Sans_Accent.code_guichet;
s[15]=Maj_Sans_Accent.code_compte;
s[16]=Maj_Sans_Accent.code_cle;
s[17]=Maj_Sans_Accent.code_mode_paiement;
s[18]=Maj_Sans_Accent.code_iban;
s[19]=Maj_Sans_Accent.code_bic;

globalMap.put("listetiers",s[1]);
globalMap.put("tiersWSBean",s); 

globalMap.put("code_interface","aaaa");




in the options of twebservice, i have     :
expression                                                element
(String[])globalMap.get("code_interface")         code_interfcace
(String[])globalMap.get("listetiers")                 |--listeTiers
(String[])globalMap.get("tiersWSBean")           |--listeTiers.soapenc:arrayType

Wehre is my error ???


thank you

#5 2012-06-27 08:48:08

pedro
Member
Registered: 2011-11-17
Posts: 3682

Re: tWebService with array parameter

Hi

[Ljava.lang.String represents String[].
The value of globalMap.get("code_interface") is a String. But your expression is (String[])globalMap.get("code_interface") .
The vaule of globalMap.get("listetiers") is a String. But your expression is (String[])globalMap.get("listetiers").
These two expressions will convert String to String[]. Then you get this exception.

Regards,
Pedro


Only Paranoid Survive.

Offline

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » tWebService with array parameter

Board footer

Powered by FluxBB