br.com.swconsultoria.mdfe.util.WebServiceMdfeUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-mdfe Show documentation
Show all versions of java-mdfe Show documentation
API Java para consumo do WebService de MDFe
The newest version!
/**
*
*/
package br.com.swconsultoria.mdfe.util;
import br.com.swconsultoria.mdfe.dom.ConfiguracoesMDFeInterface;
import br.com.swconsultoria.mdfe.exception.MdfeException;
import org.ini4j.Wini;
import java.io.IOException;
import java.io.InputStream;
/**
* @author Samuel Oliveira
*/
public class WebServiceMdfeUtil {
public static String getUrl(ConfiguracoesMDFeInterface config, String tipo, String servico) throws MdfeException {
try {
InputStream is = WebServiceMdfeUtil.class.getResourceAsStream("/WebServicesMdfe.ini");
Wini ini = new Wini(is);
String secao = tipo + "_" + (config.getAmbiente().equals(ConstantesMDFe.AMBIENTE.HOMOLOGACAO) ? "H" : "P");
String url = ini.get(secao, servico);
if (config.isLog()) {
System.out.println("Versão Mdfe: " + ConstantesMDFe.VERSAO.V3_00 + " - WebService: " + url);
}
return url;
} catch (IOException e) {
throw new MdfeException(e.getMessage());
}
}
}