This file contains hidden or 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 org.wso2.governance.sample.executor; | |
| import java.util.Map; | |
| import org.apache.commons.logging.Log; | |
| import org.apache.commons.logging.LogFactory; | |
| import org.wso2.carbon.governance.registry.extensions.interfaces.Execution; | |
| import org.wso2.carbon.registry.core.exceptions.RegistryException; | |
| import org.wso2.carbon.registry.core.jdbc.handlers.RequestContext; |
This file contains hidden or 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
| <api xmlns="http://ws.apache.org/ns/synapse" name="TerritoryAPI" context="/debug"> | |
| <resource methods="GET" uri-template="/" protocol="http"> | |
| <inSequence> | |
| <log/> | |
| <script language="js"><![CDATA[ | |
| importPackage(Packages.java.net); | |
| importPackage(Packages.org.apache.log4j); | |
| try { | |
| var addr = InetAddress.getLocalHost(); | |
| if (addr != null) { |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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); |