How to consume webservice (WSDL) mails with javascript

Asked

Viewed 3,598 times

3

I would like to use this web-service provided by mail for a small personal project (from the beginning, only return address by the ZIP code): https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente?wsdl

it is possible to consume it via javascript (pure or jquery)?

The only time I used web-services was on a platform that practically mounted everything automatic. Taking advantage of the question: What’s the difference of WS extensions? I noticed that some are WSDL and others like asmx.

  • My answer helped you ? Did it work? abs.

  • Look at Node: https://github.com/vpulim/node-soap There are still other Libs you can use on js

2 answers

2

You have many options, with JSON (more practical and easy) would look like this (using Jquery), in my example I am using VIACEP, works well too :)

$.getJSON('https://viacep.com.br/ws/11441080/json/', function(data) {         
    //informações do endereço (objeto data)
});

Full html:

<html>
 <head>
    <title>JqueryCEP</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
    <script type="text/javascript">
       $.getJSON('https://viacep.com.br/ws/11441080/json/', function(data) {
       var bairro = data.bairro;
       alert(bairro); 
});

    </script>
</head>
<body>
    <h3>
        JqueryCEP :)
    </h3>
</body>
</html>

Resultado

  • Those who return a Json are actually more practical, but I would like to learn how to use and manipulate the mail itself.

0

I believe the official documentation will answer your questions. It’s only 32 pages; and you will download and read in PDF. It has everything you need to assemble your system. Best of all it is official: directly from the Post Office.

Link: Click here

Browser other questions tagged

You are not signed in. Login or sign up in order to post.