Nota Servico Atibaia NFs-e
Enviado: 24 Jul 2021 18:21
Boa Tarde
Gostaria de saber se alguém consegue me ajudar a fazer uma função para consumir o web service da prefeitura de Atibaia.
Encontre alguns exemplos na documentação do web service de atibia em outras linguagens.
Gostaria de saber se alguém consegue me ajudar a fazer uma função para consumir o web service da prefeitura de Atibaia.
Encontre alguns exemplos na documentação do web service de atibia em outras linguagens.
Código: Selecionar todos
LINGUAGEM C
LibCurl
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL,
"http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "postman-token: 26e44762-e741-d9bc-d1e4-200f018ad85f");
headers = curl_slist_append(headers, "cache-control: no-cache");
headers = curl_slist_append(headers, "content-type: application/xml");
headers = curl_slist_append(headers, "authorization: 999991-2EU2TPWLJBP2H57HL605K24778989PPP");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, " XML A SER ENVIADO");
CURLcode ret = curl_easy_perform(hnd);
cURL
curl -X POST \
http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula \
-H 'authorization: 999991-2EU2TPWLJBP2H57HL605K24778989PPP' \
-H 'cache-control: no-cache' \
-H 'content-type: application/xml' \
-H 'postman-token: 25a25272-851b-1763-f96f-6ac0017ad209' \
-d ' XML A SER ENVIADO'
C# Sharp
var client = new RestClient("http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula");
var request = new RestRequest(Method.POST);
request.AddHeader("postman-token", "f6645f63-84a0-36b8-0e37-b26a359830ae");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/xml");
request.AddHeader("authorization", "999991-2EU2TPWLJBP2H57HL605K24778989PPP");
request.AddParameter("application/xml", " XML A SER ENVIADO", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
LINGUAGEM JAVA
OK HTTP
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/xml");
RequestBody body = RequestBody.create(mediaType, " XML A SER ENVIADO");
Request request = new Request.Builder()
.url("http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula")
.post(body)
.addHeader("authorization", "999991-2EU2TPWLJBP2H57HL605K24778989PPP")
.addHeader("content-type", "application/xml")
.addHeader("cache-control", "no-cache")
.addHeader("postman-token", "dc16978a-e237-b880-24e4-3ca35eab00b3")
.build();
Response response = client.newCall(request).execute();
Unirest
HttpResponse<String> response =
Unirest.post("http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula")
.header("authorization", "999991-2EU2TPWLJBP2H57HL605K24778989PPP")
.header("content-type", "application/xml")
.header("cache-control", "no-cache")
.header("postman-token", "67b88492-17dd-7d35-e267-17f0aeccf5b8")
.body(" XML A SER ENVIADO")
.asString();
LINGUAGEM – JAVASCRIPT
JQUERY
var settings = {
"async": true,
"crossDomain": true,
"url": "http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula",
"method": "POST",
"headers": {
"authorization": "999991-2EU2TPWLJBP2H57HL605K24778989PPP",
"content-type": "application/xml",
"cache-control": "no-cache",
"postman-token": "aa7b25cd-9870-4605-7e15-a25ce549cbbc"
},
"data": " XML A SER ENVIADO"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
XHR
var data = " XML A SER ENVIADO";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula");
xhr.setRequestHeader("authorization", "999991-2EU2TPWLJBP2H57HL605K24778989PPP");
xhr.setRequestHeader("content-type", "application/xml");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.setRequestHeader("postman-token", "044267bc-306d-0093-f98f-e4124b4dbc44");
xhr.send(data);
LINGUAGEM – NODEJS
NATIVE
var http = require("http");
var options = {
"method": "POST",
"hostname": "webservice.giap.com.br",
"port": null,
"path": "/WSNfses/nfseresources/ws/v2/emissao/simula",
"headers": {
"authorization": "999991-2EU2TPWLJBP2H57HL605K24778989PPP",
"content-type": "application/xml",
"cache-control": "no-cache",
"postman-token": "6f3c611b-ef46-e723-82be-0bf804f35636"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(" XML A SER ENVIADO");
req.end();
REQUEST
var request = require("request");
var options = { method: 'POST',
url: 'http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula',
headers:
{ 'postman-token': '16baa6d5-7845-8a94-f6e6-881e6a98924a',
'cache-control': 'no-cache',
'content-type': 'application/xml',
authorization: '999991-2EU2TPWLJBP2H57HL605K24778989PPP' },
body: ' XML A SER ENVIADO' };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
UNIREST
var unirest = require("unirest");
var req = unirest("POST", "http://ws.prefeituradeatibaia.com.br/WSNfses/nfseresources/ws/v2/emissao/simula");
req.headers({
"postman-token": "07503d21-1a63-405e-d24e-84332f21cdd1",
"cache-control": "no-cache",
"content-type": "application/xml",
"authorization": "999991-2EU2TPWLJBP2H57HL605K24778989PPP"
});
req.send(" XML A SER ENVIADO");
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});