Doubt about past information on SOAP

Asked

Viewed 103 times

1

I am researching the operation and use of the SOAP protocol, but I came across some doubts in the structural part of the protocol. I’ve been working on low-level language programming for microcontrollers for years. I never needed to use tools in the higher layers, especially in the communication part, so I have some difficulty understanding very abstract things.

I’ve been analyzing some requests using SOAP and noticed that in the SOAP elements will http links, as in the "envelope" element. Below follows an excerpt from a SOAP code (the code is incomplete, but for my doubt the rest is not necessary):

<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <ns2:RecepcionarLoteRpsRequest
            xmlns:ns2="http://ws.bhiss.pbh.gov.br">
            <nfseCabecMsg>
                <?xml version='1.0' encoding='UTF-8'?>
                <cabecalho xmlns="http://www.abrasf.org.br/nfse.xsd"versao="1.00">
                    <versaoDados>1.00</versaoDados>
                </cabecalho>
            </nfseCabecMsg>
            <nfseDadosMsg>
            </nfseDadosMsg>
        </ns2:RecepcionarLoteRpsRequest>
    </S:Body>
</S:Envelope>

In the envelope goes the following link: "http://schemas.xmlsoap.org/soap/envelope/". I wonder why these links go. Will they be accessed at some point? Or is it just for information?

1 answer

3


These links, in this case are the name Spaces, indeed there is xmlns, that is to say, XML Name Space. The resource of Namespace is required in XML because it is a free and extensible language, in which you can create your own tags, and the Namespace provides a context for the tag signed with a namespace, thus offering a way to avoid possible name conflicts between different tags, see more about this here.

In addition, by signing a tag with an xmlns, you can assign an expected tag/property structure, set an XML pattern to be sent, xmlns can receive any valid URI, but in such cases it is common for this URI to point to your Schema, see more information about schemas here.

So, this link serves to: define a context and structure to be followed by your XML, and it can yes be accessed by the receiver, to validate your XML, because as said, this link points to the schema that your XML should follow, i.e., its expected structure.

I hope I’ve helped.

PS: If possible, I recommend using Rest, which is much simpler than SOAP.

  • Clarified the doubt. Thank you.

Browser other questions tagged

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