title: PHP: Read XML attribute in SOAP response
body: <p>I am trying to use the PHP5 built-in Soap Client with a somewhat complex WSDL structure, as defined here: <a href="http://cmis.alfresco.com/cmis/NavigationService?wsdl" rel="nofollow">http://cmis.alfresco.com/cmis/NavigationService?wsdl</a></p>
  
  <p>I defined all type classes and type mapping, and I can see a valid SOAP XML request and response within the __doRequest function. However, after __doRequest returns and PHP transforms the data into objects and arrays, I am missing all information that is returned as XML attributes and not as elements.</p>
  
  <p>Here is the SOAP Request going out to the server:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" 
  xmlns:ns1="http://docs.oasis-open.org/ns/cmis/messaging/200908/" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:ns2="http://docs.oasis-open.org/ns/cmis/ws/200908/" 
  xmlns:ns3="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&gt;
  
  &lt;env:Header&gt;
  &lt;ns3:Security env:mustUnderstand="true"&gt;
  &lt;Timestamp xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt;
  &lt;Created&gt;2012-08-02T17:16:11Z&lt;/Created&gt;
  &lt;Expires&gt;2012-08-02T18:16:11Z&lt;/Expires&gt;
  &lt;/Timestamp&gt;
  &lt;ns3:UsernameToken&gt;&lt;ns3:Username&gt;***&lt;/ns3:Username&gt;
  &lt;ns3:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"&gt;***&lt;/ns3:Password&gt;&lt;/ns3:UsernameToken&gt;
  &lt;/ns3:Security&gt;
  &lt;/env:Header&gt;
  
  &lt;env:Body&gt;
  &lt;ns1:getChildren xsi:type="ns2:getChildren"&gt;
  &lt;ns1:repositoryId&gt;a8b08c6a-96e0-4783-a062-bc0ae106a2f2&lt;/ns1:repositoryId&gt;
  &lt;ns1:folderId&gt;workspace://SpacesStore/b461d5ac-5df9-48ec-84ed-03257c411227&lt;/ns1:folderId&gt;
  &lt;ns1:filter&gt;*&lt;/ns1:filter&gt;&lt;ns1:orderBy/&gt;&lt;ns1:includeAllowableActions/&gt;&lt;ns1:includeRelationships/&gt;
  &lt;ns1:renditionFilter/&gt;&lt;ns1:includePathSegment/&gt;&lt;ns1:maxItems/&gt;&lt;ns1:skipCount/&gt;&lt;ns1:extension/&gt;
  &lt;/ns1:getChildren&gt;
  &lt;/env:Body&gt;&lt;/env:Envelope&gt;
  </code></pre>
  
  <p>Here is the SOAP Response coming back, shorted for repeating entries:</p>
  
  <pre><code>&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  &lt;soap:Header&gt;
  &lt;wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&gt;
  &lt;wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-1464665770"&gt;
  &lt;wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt;2012-08-01T15:16:19.407Z&lt;/wsu:Created&gt;
  &lt;wsu:Expires xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt;2012-08-01T15:21:19.407Z&lt;/wsu:Expires&gt;
  &lt;/wsu:Timestamp&gt;
  &lt;/wsse:Security&gt;
  &lt;/soap:Header&gt;
  
  &lt;soap:Body&gt;
    &lt;getChildrenResponse xmlns="http://docs.oasis-open.org/ns/cmis/messaging/200908/" 
    xmlns:ns2="http://docs.oasis-open.org/ns/cmis/core/200908/" 
    xmlns:ns3="http://www.alfresco.org"&gt;
    &lt;objects&gt;
      &lt;objects&gt;
        &lt;object&gt;
          &lt;ns2:properties&gt;
            &lt;ns2:propertyId propertyDefinitionId="cmis:objectTypeId"&gt;
              &lt;ns2:value&gt;cmis:folder&lt;/ns2:value&gt;
            &lt;/ns2:propertyId&gt;
            &lt;ns2:propertyString propertyDefinitionId="cmis:path"&gt;
              &lt;ns2:value&gt;/Data Dictionary&lt;/ns2:value&gt;
            &lt;/ns2:propertyString&gt;
            &lt;ns2:propertyString propertyDefinitionId="cmis:name"&gt;
              &lt;ns2:value&gt;Data Dictionary&lt;/ns2:value&gt;
            &lt;/ns2:propertyString&gt;
            &lt;ns2:propertyDateTime propertyDefinitionId="cmis:creationDate"&gt;
              &lt;ns2:value&gt;2012-06-24T11:08:45.282+02:00&lt;/ns2:value&gt;
            &lt;/ns2:propertyDateTime&gt;
            &lt;ns2:propertyString propertyDefinitionId="cmis:lastModifiedBy"&gt;
              &lt;ns2:value&gt;System&lt;/ns2:value&gt;
            &lt;/ns2:propertyString&gt;
            &lt;ns2:propertyString propertyDefinitionId="cmis:createdBy"&gt;
              &lt;ns2:value&gt;System&lt;/ns2:value&gt;
            &lt;/ns2:propertyString&gt;
            &lt;ns2:propertyId propertyDefinitionId="cmis:objectId"&gt;
              &lt;ns2:value&gt;workspace://SpacesStore/14f3706f-a999-4e56-a19a-49c34db0fbe8&lt;/ns2:value&gt;
            &lt;/ns2:propertyId&gt;
            &lt;ns2:propertyId propertyDefinitionId="cmis:baseTypeId"&gt;
              &lt;ns2:value&gt;cmis:folder&lt;/ns2:value&gt;
            &lt;/ns2:propertyId&gt;
            &lt;ns2:propertyDateTime propertyDefinitionId="cmis:lastModificationDate"&gt;
              &lt;ns2:value&gt;2012-06-24T11:08:53.940+02:00&lt;/ns2:value&gt;
            &lt;/ns2:propertyDateTime&gt;
            &lt;ns2:propertyId propertyDefinitionId="cmis:parentId"&gt;
              &lt;ns2:value&gt;workspace://SpacesStore/b461d5ac-5df9-48ec-84ed-03257c411227&lt;/ns2:value&gt;
            &lt;/ns2:propertyId&gt;
            &lt;ns3:aspects&gt;
              &lt;ns3:appliedAspects&gt;P:sys:localized&lt;/ns3:appliedAspects&gt;
              &lt;ns3:appliedAspects&gt;P:cm:titled&lt;/ns3:appliedAspects&gt;
              &lt;ns3:appliedAspects&gt;P:app:uifacets&lt;/ns3:appliedAspects&gt;
              &lt;ns3:properties&gt;
                &lt;ns2:propertyString propertyDefinitionId="cm:title"&gt;
                  &lt;ns2:value&gt;Data Dictionary&lt;/ns2:value&gt;
                &lt;/ns2:propertyString&gt;
                &lt;ns2:propertyString propertyDefinitionId="cm:description"&gt;
                  &lt;ns2:value&gt;User managed definitions&lt;/ns2:value&gt;
                &lt;/ns2:propertyString&gt;
                &lt;ns2:propertyString propertyDefinitionId="app:icon"&gt;
                  &lt;ns2:value&gt;space-icon-default&lt;/ns2:value&gt;
                &lt;/ns2:propertyString&gt;
              &lt;/ns3:properties&gt;
            &lt;/ns3:aspects&gt;
          &lt;/ns2:properties&gt;
        &lt;/object&gt;
      &lt;/objects&gt;
  
      ...
  
      &lt;hasMoreItems&gt;false&lt;/hasMoreItems&gt;
      &lt;numItems&gt;5&lt;/numItems&gt;
    &lt;/objects&gt;
    &lt;/getChildrenResponse&gt;
  &lt;/soap:Body&gt;
  
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>A var_dump of the resulting object gives the following output. All the attribute data for propertyDefinitionId is completely lost:</p>
  
  <pre><code>array(5) {
    [0]=&gt;
    object(cmisObjectInFolderType)#137 (3) {
      ["object"]=&gt;
      object(cmisObjectType)#136 (9) {
        ["properties"]=&gt;
        array(8) {
          [0]=&gt;
          object(cmisPropertyString)#132 (5) {
            ["value"]=&gt;
            array(1) {
              [0]=&gt;
              string(16) "/Data Dictionary"
            }
            ["propertyDefinitionId"]=&gt;
            object(stdClass)#133 (0) {
            }
            ["localName"]=&gt;
            NULL
            ["displayName"]=&gt;
            NULL
            ["queryName"]=&gt;
            NULL
          }
          [1]=&gt;
          object(cmisPropertyString)#140 (5) {
            ["value"]=&gt;
            array(1) {
              [0]=&gt;
              string(15) "Data Dictionary"
            }
            ["propertyDefinitionId"]=&gt;
            object(stdClass)#133 (0) {
            }
            ["localName"]=&gt;
            NULL
            ["displayName"]=&gt;
            NULL
            ["queryName"]=&gt;
            NULL
          }
          [2]=&gt;
          object(cmisPropertyString)#141 (5) {
            ["value"]=&gt;
            array(1) {
              [0]=&gt;
              string(6) "System"
            }
            ["propertyDefinitionId"]=&gt;
            object(stdClass)#133 (0) {
            }
            ["localName"]=&gt;
            NULL
            ["displayName"]=&gt;
            NULL
            ["queryName"]=&gt;
            NULL
          }
          [3]=&gt;
          object(cmisPropertyString)#142 (5) {
            ["value"]=&gt;
            array(1) {
              [0]=&gt;
              string(6) "System"
            }
            ["propertyDefinitionId"]=&gt;
            object(stdClass)#133 (0) {
            }
            ["localName"]=&gt;
            NULL
            ["displayName"]=&gt;
            NULL
            ["queryName"]=&gt;
            NULL
          }
          [4]=&gt;
          object(cmisPropertyId)#143 (5) {
            ["value"]=&gt;
            array(1) {
              [0]=&gt;
              string(11) "cmis:folder"
            }
            ["propertyDefinitionId"]=&gt;
            object(stdClass)#133 (0) {
            }
            ["localName"]=&gt;
            NULL
            ["displayName"]=&gt;
            NULL
            ["queryName"]=&gt;
            NULL
          }
          [5]=&gt;
          object(cmisPropertyId)#144 (5) {
            ["value"]=&gt;
            array(1) {
              [0]=&gt;
              string(60) "workspace://SpacesStore/14f3706f-a999-4e56-a19a-49c34db0fbe8"
            }
            ["propertyDefinitionId"]=&gt;
            object(stdClass)#133 (0) {
            }
            ["localName"]=&gt;
            NULL
            ["displayName"]=&gt;
            NULL
            ["queryName"]=&gt;
            NULL
          }
          [6]=&gt;
          object(cmisPropertyId)#145 (5) {
            ["value"]=&gt;
            array(1) {
              [0]=&gt;
              string(11) "cmis:folder"
            }
            ["propertyDefinitionId"]=&gt;
            object(stdClass)#133 (0) {
            }
            ["localName"]=&gt;
            NULL
            ["displayName"]=&gt;
            NULL
            ["queryName"]=&gt;
            NULL
          }
          [7]=&gt;
          object(cmisPropertyId)#146 (5) {
            ["value"]=&gt;
            array(1) {
              [0]=&gt;
              string(60) "workspace://SpacesStore/b461d5ac-5df9-48ec-84ed-03257c411227"
            }
            ["propertyDefinitionId"]=&gt;
            object(stdClass)#133 (0) {
            }
            ["localName"]=&gt;
            NULL
            ["displayName"]=&gt;
            NULL
            ["queryName"]=&gt;
            NULL
          }
        }
        ["allowableActions"]=&gt;
        NULL
        ["relationship"]=&gt;
        NULL
        ["changeEventInfo"]=&gt;
        NULL
        ["acl"]=&gt;
        NULL
        ["exactACL"]=&gt;
        NULL
        ["policyIds"]=&gt;
        NULL
        ["rendition"]=&gt;
        NULL
        ["any"]=&gt;
        NULL
      }
      ["pathSegment"]=&gt;
      NULL
      ["any"]=&gt;
      NULL
    }
  ...
  </code></pre>
  
  <p>Obviously, I cannot change the WSDL file. I have read a few comments that PHP SOAP does not support attribute data in SOAP messages. If this is true, PHP SOAP is pretty much useless for this application.</p>
  
  <p>Has anyone an idea how to parse the response with the built-in SOAP extension? Or do I need to go for a solution that bypasses the PHP SOAP functionality completely?</p>