PHP:读取SOAP响应中的XML属性

PHP:读取SOAP响应中的XML属性,php,soap,soap-client,Php,Soap,Soap Client,我正在尝试使用PHP5内置Soap客户端,该客户端具有某种复杂的WSDL结构,如下所述: 我定义了所有类型类和类型映射,并且可以在uu doRequest函数中看到有效的SOAP XML请求和响应。但是,在_doRequest返回并且PHP将数据转换为对象和数组之后,我丢失了作为XML属性而不是元素返回的所有信息 下面是发送到服务器的SOAP请求: <?xml version="1.0" encoding="UTF-8"?> <env:Envelope xmlns:env="h

我正在尝试使用PHP5内置Soap客户端,该客户端具有某种复杂的WSDL结构,如下所述:

我定义了所有类型类和类型映射,并且可以在uu doRequest函数中看到有效的SOAP XML请求和响应。但是,在_doRequest返回并且PHP将数据转换为对象和数组之后,我丢失了作为XML属性而不是元素返回的所有信息

下面是发送到服务器的SOAP请求:

<?xml version="1.0" encoding="UTF-8"?>
<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">

<env:Header>
<ns3:Security env:mustUnderstand="true">
<Timestamp xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<Created>2012-08-02T17:16:11Z</Created>
<Expires>2012-08-02T18:16:11Z</Expires>
</Timestamp>
<ns3:UsernameToken><ns3:Username>***</ns3:Username>
<ns3:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">***</ns3:Password></ns3:UsernameToken>
</ns3:Security>
</env:Header>

<env:Body>
<ns1:getChildren xsi:type="ns2:getChildren">
<ns1:repositoryId>a8b08c6a-96e0-4783-a062-bc0ae106a2f2</ns1:repositoryId>
<ns1:folderId>workspace://SpacesStore/b461d5ac-5df9-48ec-84ed-03257c411227</ns1:folderId>
<ns1:filter>*</ns1:filter><ns1:orderBy/><ns1:includeAllowableActions/><ns1:includeRelationships/>
<ns1:renditionFilter/><ns1:includePathSegment/><ns1:maxItems/><ns1:skipCount/><ns1:extension/>
</ns1:getChildren>
</env:Body></env:Envelope>
显然,我无法更改WSDL文件。我读过一些评论,说PHP SOAP不支持SOAP消息中的属性数据。如果这是真的,那么PHPSOAP对于这个应用程序来说几乎是无用的


有人知道如何使用内置的SOAP扩展解析响应吗?还是我需要寻找一种完全绕过PHP SOAP功能的解决方案?

我终于自己找到了这个问题

问题是WSDL文件中属性的类型定义:

<xs:attribute name="propertyDefinitionId" type="xs:anySimpleType" />


PHP WSDL解析器不喜欢xs:anySimpleType类型。用xs:string替换它可以解决整个问题。也许这是PHP中的一个bug。

看起来是一个可能的解决方案。可能比使用普通的XML解析器更容易。是的,我以前看过这个响应,本质上它建议应用一个类映射。我已经这样做了,结果没有变化。
array(5) {
  [0]=>
  object(cmisObjectInFolderType)#137 (3) {
    ["object"]=>
    object(cmisObjectType)#136 (9) {
      ["properties"]=>
      array(8) {
        [0]=>
        object(cmisPropertyString)#132 (5) {
          ["value"]=>
          array(1) {
            [0]=>
            string(16) "/Data Dictionary"
          }
          ["propertyDefinitionId"]=>
          object(stdClass)#133 (0) {
          }
          ["localName"]=>
          NULL
          ["displayName"]=>
          NULL
          ["queryName"]=>
          NULL
        }
        [1]=>
        object(cmisPropertyString)#140 (5) {
          ["value"]=>
          array(1) {
            [0]=>
            string(15) "Data Dictionary"
          }
          ["propertyDefinitionId"]=>
          object(stdClass)#133 (0) {
          }
          ["localName"]=>
          NULL
          ["displayName"]=>
          NULL
          ["queryName"]=>
          NULL
        }
        [2]=>
        object(cmisPropertyString)#141 (5) {
          ["value"]=>
          array(1) {
            [0]=>
            string(6) "System"
          }
          ["propertyDefinitionId"]=>
          object(stdClass)#133 (0) {
          }
          ["localName"]=>
          NULL
          ["displayName"]=>
          NULL
          ["queryName"]=>
          NULL
        }
        [3]=>
        object(cmisPropertyString)#142 (5) {
          ["value"]=>
          array(1) {
            [0]=>
            string(6) "System"
          }
          ["propertyDefinitionId"]=>
          object(stdClass)#133 (0) {
          }
          ["localName"]=>
          NULL
          ["displayName"]=>
          NULL
          ["queryName"]=>
          NULL
        }
        [4]=>
        object(cmisPropertyId)#143 (5) {
          ["value"]=>
          array(1) {
            [0]=>
            string(11) "cmis:folder"
          }
          ["propertyDefinitionId"]=>
          object(stdClass)#133 (0) {
          }
          ["localName"]=>
          NULL
          ["displayName"]=>
          NULL
          ["queryName"]=>
          NULL
        }
        [5]=>
        object(cmisPropertyId)#144 (5) {
          ["value"]=>
          array(1) {
            [0]=>
            string(60) "workspace://SpacesStore/14f3706f-a999-4e56-a19a-49c34db0fbe8"
          }
          ["propertyDefinitionId"]=>
          object(stdClass)#133 (0) {
          }
          ["localName"]=>
          NULL
          ["displayName"]=>
          NULL
          ["queryName"]=>
          NULL
        }
        [6]=>
        object(cmisPropertyId)#145 (5) {
          ["value"]=>
          array(1) {
            [0]=>
            string(11) "cmis:folder"
          }
          ["propertyDefinitionId"]=>
          object(stdClass)#133 (0) {
          }
          ["localName"]=>
          NULL
          ["displayName"]=>
          NULL
          ["queryName"]=>
          NULL
        }
        [7]=>
        object(cmisPropertyId)#146 (5) {
          ["value"]=>
          array(1) {
            [0]=>
            string(60) "workspace://SpacesStore/b461d5ac-5df9-48ec-84ed-03257c411227"
          }
          ["propertyDefinitionId"]=>
          object(stdClass)#133 (0) {
          }
          ["localName"]=>
          NULL
          ["displayName"]=>
          NULL
          ["queryName"]=>
          NULL
        }
      }
      ["allowableActions"]=>
      NULL
      ["relationship"]=>
      NULL
      ["changeEventInfo"]=>
      NULL
      ["acl"]=>
      NULL
      ["exactACL"]=>
      NULL
      ["policyIds"]=>
      NULL
      ["rendition"]=>
      NULL
      ["any"]=>
      NULL
    }
    ["pathSegment"]=>
    NULL
    ["any"]=>
    NULL
  }
...
<xs:attribute name="propertyDefinitionId" type="xs:anySimpleType" />