Web services component with https problem

One Star

Web services component with https problem

I'm using TOS 3.2.3 to develop a job for getting import/export data through web services from the Brazilian Central Bank. I'm having a problem which might have something to do with the fact that this web service works over https. I had no problems running the "weather" demo web service.
The web service is described here:
https://www3.bcb.gov.br/sgspub/JSP/sgsgeral/sgsAjuda.jsp#SA (description)
https://www3.bcb.gov.br/sgspub/JSP/sgsgeral/FachadaWSSGS.wsdl
If anybody wants to look t this description or wsdl, you may have to paste this into the browser twice because this site redirects to the home page the first time.
When I run my job for the GetValor() method I get the following error:
tarting job tWebServiceSGS at 12:57 18/01/2010.
connecting to socket on port 3541
connected
Exception in component tWebServiceInput_1
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1611)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:187)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:181)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1035)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:124)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:516)
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:454)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:884)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1112)
disconnected
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1139)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1123)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:434)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.jav...)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1049)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:677)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:186)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:225)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:283)
at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:369)
at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:420)
at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:482)
at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:361)
at java.lang.Thread.run(Thread.java:619)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:285)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:191)
at sun.security.validator.Validator.validate(Validator.java:218)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:126)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:209)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:249)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1014)
... 23 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:174)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:238)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:280)
... 29 more
Job tWebServiceSGS ended at 12:57 18/01/2010.

I'm attaching a screen shot of my job definition.
I think this may have to do with the "trust server with SSL" setting but I'm not sure since in there it wants a password. I read elsewhere some posts that make me think that I have to reference some certificates there.
What am I dong wrong?
Thanks.
One Star

Re: Web services component with https problem

You haven't checked the 'Need Authentication?' box and input the username & password/key.
One Star

Re: Web services component with https problem

You're right, thanks a lot. I investigated some more and I found this good article about key stores:
http://java.sun.com/j2se/1.3/docs/tooldocs/win32/keytool.html
which I used to import the certificate I downloaded from the site. I used IE to save the .cer file because I couldn't find where Firefox lets me save the certificate as a file. I saved it in base64 format for import.
My component now looks like the new attached image
There I have:
TrustStore file="/home/konsultex/.keystore"
password = "mypassword"
I'm still not able to get the BigDecimal return value. :-( I get this log output:
Starting job tWebServiceSGS at 15:26 18/01/2010.
connecting to socket on port 4162
connected
Exception in component tWebServiceInput_1
java.io.IOException: Type {http://www.w3.org/2001/XMLSchema}Array is referenced but not defined.
at org.apache.axis.wsdl.symbolTable.SymbolTable.checkForUndefined(SymbolTable.java:665)
at org.apache.axis.wsdl.symbolTable.SymbolTable.add(SymbolTable.java:545)
at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:518)
at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:495)
at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:361)
at java.lang.Thread.run(Thread.java:619)
disconnected
Job tWebServiceSGS ended at 15:26 18/01/2010.
Any ideas about what else needs to be defined?
Thanks.
One Star

Re: Web services component with https problem

I'va made some progress with my analysis of the problem. When I put this into the web browser:
https://www3.bcb.gov.br/wssgs/services/FachadaWSSGS?method=getValor&codigoSerie=2947&data=01/12/2009
I get back this reply:
<soapenv:Envelope>
?
<soapenv:Body>
?
<getValorResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<getValorReturn href="#id0"/>
</getValorResponse>
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:decimal">4730137128</multiRef>
</soapenv:Body>
</soapenv:Envelope>
This has the value I need (soapenc:decimal) of 4730137128 for December, 2009. I notice that this result is inside a <multiRef> tag. maybe that's the reason I get a "Array is referenced but not defined" error in my job. What's the right way to define this return in the web services job schema?
One Star

Re: Web services component with https problem

I think all your parameters need to be in quotes. Also I think your schema should be defined as string as the xml message that is returned. You then need to use tExtractXMLField to get the data field out.
One Star

Re: Web services component with https problem

I wasn't able to get this web service component to work. No matter what I did I still got the error about the array. I solved the problem by using a tJavaFlex component with this code (for testing):
// imports(advanced tab)
import java.math.BigDecimal;
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
// start code
System.out.println("## START\n#");
long serie = 3001;
String data = "01/12/2009";
String metodo = "getValor";
String local = "https://www3.bcb.gov.br/wssgs/services/FachadaWSSGS";
// para usar https com o certificado do Banco Central
System.setProperty("javax.net.ssl.trustStoreType", "JKS");
System.setProperty("javax.net.ssl.trustStore", "/home/konsultex/.keystore")
// main code
// Criando e configurando o serviço
Call call = (Call) new Service().createCall();
// Configurando o endereço onde está o web service
call.setTargetEndpointAddress(local);
// Marcando o método a ser chamado.
call.setOperationName(metodo);
// parametros para o método
Object[] param = new Object[]{serie, data};
// Retorno do serviço
BigDecimal valor = (BigDecimal)call.invoke(param);
// end code
System.out.println("Valor da série " + serie + ": " + valor);
System.out.println("#\n## END");
I load the 4 required jars with 4 separate tLibraryLoad components first. They are:
axis.jar
jaxrpc.jar
commons-logging-1.0.4.jar
commons-discovery-0.2.jar
It took me a while to figure out what to code but in the end it's pretty easy. This tutorial helped me a lot:
http://ws.apache.org/axis/java/user-guide.html#ConsumingWebServicesWithAxis
Thanks for all the ideas and help.

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch