Link to home
Create AccountLog in
Avatar of andieje
andieje

asked on

more about soap namespaces

Hi

My understanding of a namespace is a means to avoid naming conflicts. So you specify a prefix for an element and what namespace that prefixe belongs to. That makes sense to me but i don't understand the following use of xsi and xsd

<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/"
  SOAP:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <SOAP:Body>
    <m:getStateName xmlns:m="http://www.soapware.org/">
      <statenum xsi:type="xsd:int">41</statenum>
    </m:getStateName>
  </SOAP:Body>
</SOAP:Envelope>

To me, I can see that we are delcaring the SOAP prefix to belong to the relevant namespace with this code [xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/"] but what does  the following mean

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">

xsi and xsd are not used as element prefixes. They occur within an element and I am not familiar with the use of namespaces in this way:

    <statenum xsi:type="xsd:int">41</statenum>

It looks like
1) You are giving the attribute a namespace
2)YOu are giving the attribute value a namespace

Why would an attribute need a namespace? Isn't it implicity linked to the namespace of the element? It seems, then, that elements can have attributes from a namespace other than the namespace of the parent element. I can understand this even if i can't immediately appreciate a need for it

I'm not sure what's going on with the attribute value having a namespace or how that could work or why it's needed. Please could you explain

thanks
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of andieje
andieje

ASKER

i do appreciate that you don't like SOAP but if what I am looking at uses SOAP i dont really have much choice....
You might want to ask the provider of the web service if they can offer a REST interface.  Usually when they understand how easy it is, they do it immediately.  There are reasons why Yahoo, Google and Facebook abandoned SOAP!

Avatar of andieje

ASKER

thanks