This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http:Response clientResponse = {}; | |
clientResponse, err = httpConnector.post("/SigepMasterJPA/AtendeClienteService/AtendeCliente", req); | |
println("Convertendo XML para JSON "); | |
var xmlRetornavel, _ = <xml> clientResponse.getXmlPayload(); | |
json respostaComoJSON = {"logradouro": xmlRetornavel.toJSON({})["soap:Envelope"]["soap:Body"]["ns2:consultaCEPResponse"]["return"]}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource consultacep (http:Request req, http:Response res, string cep) { | |
xml soapRequest = xml `<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" | |
xmlns:cli="http://cliente.bean.master.sigep.bsb.correios.com.br/"> | |
<soapenv:Header/> | |
<soapenv:Body> | |
<cli:consultaCEP> | |
<cep>{{cep}}</cep> | |
</cli:consultaCEP> | |
</soapenv:Body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ballerina.net.http; | |
@http:configuration {basePath:"/soap"} | |
service<http> cepservice { | |
endpoint | |
<http:HttpClient> httpConnector{ | |
create http:HttpClient("https://apps.correios.com.br", {}); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[54] → http http://localhost:9090/soap/cep/67133100 | |
HTTP/1.1 200 OK | |
Content-Type: application/json | |
content-encoding: gzip | |
transfer-encoding: chunked | |
{ | |
"logradouro": { | |
"bairro": "Cidade Nova", | |
"cep": "67133100", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ballerina.net.http; | |
@http:configuration {basePath:"/soap"} | |
service<http> cepservice { | |
endpoint | |
<http:HttpClient> httpConnector{ | |
create http:HttpClient("https://apps.correios.com.br", {}); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gateways; | |
import ballerina.net.http; | |
@http:configuration {basePath:"/soap"} | |
service<http> temperatureService { | |
endpoint | |
<http:HttpClient> httpConnector{ | |
create http:HttpClient("http://www.webservicex.net/", {}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gateways; | |
import ballerina.net.http; | |
@http:configuration {basePath:"/fipe"} | |
service<http> fipe { | |
endpoint | |
<http:HttpClient> httpConnector{ | |
create http:HttpClient("https://fipe.parallelum.com.br/api/v1", {}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@http:resourceConfig { | |
methods:["GET"], | |
path:"/marcas/{tipoVeiculo}" | |
} | |
resource marcas (http:Request req, http:Response res, string tipoVeiculo) { | |
// https://fipe.parallelum.com.br/api/v1/{carros}/marcas {motos, caminhoes, carros} | |
http:Response clientResponse = {}; | |
clientResponse, err = httpConnector.get("/"+ tipoVeiculo +"/marcas", {}); | |
println("GET request: Marca Veiculos "); | |
res.forward(clientResponse); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gateways; | |
import ballerina.net.http; | |
@http:configuration {basePath:"/fipe"} | |
service<http> fipe { | |
endpoint | |
<http:HttpClient> httpConnector{ | |
create http:HttpClient("https://fipe.parallelum.com.br/api/v1", {}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mine; | |
import ballerina.net.http; | |
@http:configuration {basePath:"/dolar"} | |
service<http> dolar { | |
endpoint | |
<http:HttpClient> httpConnector{ | |
create http:HttpClient("http://api.bcb.gov.br/dados/serie/bcdata.sgs.1/dados/ultimos", {});} |