Implement Vbscript Post Reverse Logistics Webservice

Asked

Viewed 927 times

3

I am trying to implement the mail reverse logistics webservice in vbscript but always receive as response the error "Error Reading Xmlstreamreader."

Follow the code that is being used. I am still in development environment.

Dim MdbFilePath,ConnectionString,SQL,estado, sSoap


response.expires=-1

Server.ScriptTimeout = 60000
sSoap = "<?xml version=""1.0"" encoding=""utf-8""?>"
sSoap = sSoap & "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:web=""http://webservice.scol.correios.com.br/"">"
 sSoap = sSoap & "<soapenv:Header/>"
sSoap = sSoap & "<soapenv:Body>"
 sSoap = sSoap & "<ser:solicitarPostagemReversa>"

 sSoap = sSoap & "<codAdministrativo>08082650</codAdministrativo>"
sSoap  = sSoap & "<codigo_servico>41076</codigo_servico>"
 sSoap = sSoap & "<cartao>0057018901</cartao>"
 sSoap = sSoap & "<destinatario>"
 sSoap = sSoap & "<nome>Fulano</nome>"
 sSoap = sSoap & "<logradouro>Rua Humaita</logradouro>"
 sSoap = sSoap & "<numero>266</numero>"
 sSoap = sSoap & "<complemento>802</complemento>"
 sSoap = sSoap & "<bairro>Humaita</bairro>"
 sSoap = sSoap & "<referencia></referencia>"
 sSoap = sSoap & "<cidade>Rio de Janeiro</cidade>"
 sSoap = sSoap & "<uf>RJ</uf>"
 sSoap = sSoap & "<cep>22261001</cep>"
 sSoap = sSoap & "<ddd>61</ddd>"
 sSoap = sSoap & "<telefone>34261111</telefone>"
 sSoap = sSoap & "<email>[email protected]</email>"
 sSoap = sSoap & "</destinatario>"
 sSoap = sSoap & "<coletas_solicitadas>"

 sSoap = sSoap & "<tipo>A</tipo>"
 sSoap = sSoap & "<id_cliente></id_cliente>"
 sSoap = sSoap & "<valor_declarado></valor_declarado>"
 sSoap = sSoap & "<descricao></descricao>"

 sSoap = sSoap & "<cklist></cklist>"
 sSoap = sSoap & "<documento></documento>"
 sSoap = sSoap & "<remetente>"
 sSoap = sSoap & "<nome>Ciclano</nome>"
 sSoap = sSoap & "<logradouro>Praia de Botafogo</logradouro>"
 sSoap = sSoap & "<numero>516</numero>"
 sSoap = sSoap & "<complemento>1101</complemento>"
 sSoap = sSoap & "<bairro>Botafogo</bairro>"
 sSoap = sSoap & "<referencia></referencia>"
 sSoap = sSoap & "<cidade>Rio de Janeiro</cidade>"
 sSoap = sSoap & "<uf>RJ</uf>"
 sSoap = sSoap & "<cep>22250040</cep>"
 sSoap = sSoap & "<ddd>61</ddd>"
 sSoap = sSoap & "<telefone>34262222</telefone>"
 sSoap = sSoap & "<email>[email protected]</email>"
 sSoap = sSoap & "<identificacao></identificacao>"
 sSoap = sSoap & "<ddd_celular>61</ddd_celular>"
 sSoap = sSoap & "<celular>92236666</celular>"
 sSoap = sSoap & "<sms>S</sms>"
 sSoap = sSoap & "</remetente>"
 sSoap = sSoap & "<produto>"
 sSoap = sSoap & "<codigo>116600063</codigo>"
 sSoap = sSoap & "<tipo>0</tipo>"
 sSoap = sSoap & "<qtd>1</qtd>"
 sSoap = sSoap & "</produto>"

 sSoap = sSoap & "<numero></numero>"
 sSoap = sSoap & "<ag></ag>"
 sSoap = sSoap & "<cartao></cartao>"
 sSoap = sSoap & "<servico_adicional></servico_adicional>"
 sSoap = sSoap & "<ar></ar>"
 sSoap = sSoap & "<obj_col>"

 sSoap = sSoap & "<item>1</item>"
 sSoap = sSoap & "<desc></desc>"
 sSoap = sSoap & "<entrega></entrega>"
 sSoap = sSoap & "<num></num>"
 sSoap = sSoap & "<id>553366</id>"
 sSoap = sSoap & "</obj_col>"
 sSoap = sSoap & "</coletas_solicitadas>"
 sSoap = sSoap & "</ser:solicitarPostagemReversa>"
 sSoap = sSoap & "</soapenv:Body>"
    sSoap = sSoap & "</soapenv:Envelope>"


set oXmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
sSoapServer =      "https://apphom.correios.com.br/logisticaReversaWS/logisticaReversaService/logisticaReversaWS?wsdl"


oXmlHttp.open "POST", sSoapServer, false, "empresacws", "123456"
oXmlHttp.setRequestHeader "soapAction","solicitarPostagemReversa"
oXmlHttp.setRequestHeader "Content-Type", "text/xml"
oXmlHttp.send(sSoap)

sReturn = oXmlHttp.responseText


response.write sReturn

Set oXmlHttp= Nothing

Follow the link in the post office manual

http://www2.correios.com.br/orders/servicosonline/Manual/Manual%20de%20Implementacao%20do%20Web%20Service%20Logistica%20Reversa.pdf

1 answer

2


Hello, I was able to make the connection. Your code is right, but in XML still define the "to be:" (which goes in the TAG <ser:solicitarPostagemReversa>).

Your Envelope Tag should look like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.logisticareversa.correios.com.br/" xmlns:web="http://webservice.scol.correios.com.br/">

I hope I’ve helped.

  • Thank you very much. It worked right.

Browser other questions tagged

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