Php 如何在SOAP中向请求添加XML属性?
我需要像这样创建SOAP请求:Php 如何在SOAP中向请求添加XML属性?,php,xml,soap,Php,Xml,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>
<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>
如何为“属性”添加属性
提前感谢。我已经尝试了一些变体来实现这一点——使用嵌套数组、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 );
$parameters=newstdclass();
$parameters->name=$name;
$parameters->ParentryId=$ParentryId;
$parameters->properties=new stdClass();
$propsSimpleVar=newsoapvar(“$cleanContents.”,XSD_ANYXML);
$parameters->properties=$propsSimpleVar;
$client->createDocument($parameters);
我认为它也应该适用于属性数组。
希望这对其他人有用
$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 );