Consume Web Service SGS Central Bank Brazil - Dollar Quotation

2

I was able to generate the (java) client in Eclipse, using the WSDL available at link .

The following classes have been generated:

package br.gov.bcb.pec.sgs.casosdeuso.ws.comum;  
    WSValorSerieVO  
    WSSerieVO  

package br.gov.bcb.www3.wssgs.services.FachadaWSSGS  
    interface FachadaWSSGS   
    interface FachadaWSSGSService  
    classe FachadaWSSGSServiceLocator  
    classe FachadaWSSGSProxy  
    classe FachadaWSSGSSoapBindingStub 

My question now is how to instantiate these classes and use the service. My goal is to get the dollar quote on a specific date dd-mm-aaaa

Can anyone give a force?

I think it would be something close to:

public class main {
public static void main(String[] args) throws ServiceException {    
    FachadaWSSGSProxy proxy = new FachadaWSSGSProxy();
    FachadaWSSGSServiceLocator service = new FachadaWSSGSServiceLocator();
    FachadaWSSGSSoapBindingStub stub = (FachadaWSSGSSoapBindingStub) service.getPort(proxy.getEndpoint(),FachadaWSSGSService.class );       
    try {
        System.out.println(stub.getValor (1,"24/01/2017").toString());
    } catch (RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

}

But this does not work.

    
asked by anonymous 24.01.2017 / 18:28

1 answer

3

I generated a JAR containing the classes available in: ( link ), and then instantiated normally the WSC query object, passing the desired parameters .

System.out.println(" dolar: "+(String.valueOf(new WSConsulta().getCotacao(Indice.DOLAR_COMPRA, LocalDate.of(2017, 01, 10)))));

It worked perfectly.

OBs: Beware of queries on non-working days, as it returns null.

    
27.01.2017 / 18:39