如何在SOAP中向请求添加XML属性


How to add XML attributes to request in SOAP?

我需要创建这样的SOAP请求:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:stor="http://storage.xdoc.xx/">
   <soapenv:Header/>
   <soapenv:Body>
      <stor:createDocument>
         <parentEntryId>workspace://SpacesStore/15f33e3a-32ba-4a5d-976f-c9e2096e1112</parentEntryId>
         <name>test.txt</name>
         <properties module="" name="Content" type="Binary">
            <valueBinary>
               <bytes>cXdlcnR5</bytes>
            </valueBinary>
         </properties>
      </stor:createDocument>
   </soapenv:Body>
</soapenv:Envelope>

据我所知,我需要使用嵌套数组,但问题在于XML属性。SoapVar似乎并不是我所需要的。

现在我有这样一个电话:

$client->__callSoap("createDocument",
                                array(new SoapParam($name, "name"),
                                        new SoapParam(
                                                new SoapParam(
                                                        new SoapParam(
                                                                $contents,
                                                                "bytes"
                                                        ),
                                                        "valueBinary"
                                                ),
                                                "properties"
                                        )
                                )
                        );  

如何添加属性到"属性"?

提前感谢。

我已经尝试了一些变体来完成这项工作—使用嵌套数组、stdClass和SoapVar编码数组和组合等。但我发现唯一能正常工作的变体是:

 $parameters = new stdClass();
 $parameters->name = $name;
 $parameters->parentEntryId = $parentEntryId;
 $parameters->properties = new stdClass();
 $propsSimpleVar = new SoapVar("<properties module='"'" name='"Content'" type='"Binary'"><valueBinary><bytes>" . $cleanContents . "</bytes></valueBinary></properties>", XSD_ANYXML);
 $parameters->properties = $propsSimpleVar;
 $client->createDocument( $parameters );

我认为它应该工作与数组属性。希望对大家有所帮助。