Implement Vbscript Post Office Reverse Logic WebService

3

I'm trying to implement the webservice of reverse mail logistics in vbscript but I always get the error "Error reading XMLStreamReader."

Follow the code that is being used. I'm 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 manual for the post office

link

    
asked by anonymous 22.02.2017 / 22:14

1 answer

2

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

Your Tag Envelope 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 have helped.

    
10.04.2017 / 17:34