Reputation: 11
I'm having a hard time understanding this error, and also finding an answer online. I am trying to consume an API in Postman from "correios", and I'm getting this error:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Unmarshalling Error: elemento inesperado (uri:"http://service.objetopostado.cws.correios.com.br/", local:"codigoObjeto"). Os elementos esperados são <{}codigoObjeto> </faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
Translating:
Unmarshalling Error: unexpected element (uri:"http://service.objetopostado.cws.correios.com.br/", local:"codigoObjeto"). The expected elements are <{}codigoObjeto>
This is the body for the POST request:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<consultarObjetoPostado xmlns="http://service.objetopostado.cws.correios.com.br/">
<codigoObjeto>AB123456789BR</codigoObjeto>
</consultarObjetoPostado>
</soap:Body>
</soap:Envelope>
I don't understand if the error is simply that the <codigoObjeto>
is written wrong, and needs to be written as <{}codigoObjeto>
or something else, because if I write as <{}codigoObjeto>
it shows another error, like this:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Unmarshalling Error: Unexpected character '{' (code 123) in content after '<' (malformed start element?).
at [row,col {unknown-source}]: [5,10] </faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
So I really don't know how to solve this problem.
Upvotes: 0
Views: 6847
Reputation: 4482
The problem seems to be in the namespace:
<consultarObjetoPostado xmlns="http://service.objetopostado.cws.correios.com.br/">
<!-- Element codigoObjeto belongs to the default namespace "http://service.objetopostado.cws.correios.com.br/" -->
<codigoObjeto>AB123456789BR</codigoObjeto>
</consultarObjetoPostado>
To remove codigoObjeto
from the default namespace on the XML level it would be needed either to provide a namespace prefix:
<ns:consultarObjetoPostado xmlns:ns="http://service.objetopostado.cws.correios.com.br/">
<codigoObjeto>AB123456789BR</codigoObjeto>
</ns:consultarObjetoPostado>
Or provide an empty namespace on the element level:
<consultarObjetoPostado xmlns="http://service.objetopostado.cws.correios.com.br/">
<codigoObjeto xmlns="">AB123456789BR</codigoObjeto>
</consultarObjetoPostado>
The client implementation may differ depending on the languages and frameworks used to build and to send the request.
Upvotes: 4