PHP SOAP将元素发送为xsi:type =“xsd:boolean”

时间:2014-09-11 14:24:08

标签: php soap-client

我在互联网上搜索没有成功,想要一种添加xsi的方式:type =" xsd:boolean"对于一个特定的元素..我正在使用PHP用于PHP,你能帮助我吗?

$paramsBody = array("Parametros" => array('Parametro' => array("Name" => 'Todos', 'Value' => new SOAPVar('false', XSD_ANYTYPE, null, null, null, 'http://microsoft.com/webservices/'))));

$this->client->$function($paramsBody);

XML输出:

   <env:Body>
      <ns1:Export>
         <ns1:Parametros>
            <ns1:Parametro>
               <ns1:Name>Todos</ns1:Name>
               <ns1:Value>false</ns1:Value>
            </ns1:Parametro>
         </ns1:Parametros>
      </ns1:Export>
   </env:Body>

应该如何......

   <env:Body>
      <ns1:Export>
         <ns1:Parametros>
            <ns1:Parametro>
               <ns1:Name>Todos</ns1:Name>
               <ns1:Value xsi:type="xsd:boolean">false</ns1:Value>
            </ns1:Parametro>
         </ns1:Parametros>
      </ns1:Export>
   </env:Body>

1 个答案:

答案 0 :(得分:4)

我找到了一个使用SoapVar对象的解决方案!

array("Parametros" => array('Parametro' => array("Name" => 'Todos', "Value" => new SoapVar('true', XSD_STRING, 'xsd:boolean'))))