Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在SOAP中发送数组?_Php_Xml_Soap_Soapui_Soap Client - Fatal编程技术网

Php 如何在SOAP中发送数组?

Php 如何在SOAP中发送数组?,php,xml,soap,soapui,soap-client,Php,Xml,Soap,Soapui,Soap Client,我有一个PHP文件,它发送SOAP请求 $client = new SoapClient('http://xyz'); $client->call('example', array('param1'=>'value2') 我想使用SoapUI执行相同的请求: <soapenv:Envelope [..]> <soapenv:Header/> <soapenv:Body> <urn:call soapenv:encod

我有一个PHP文件,它发送SOAP请求

$client = new SoapClient('http://xyz');
$client->call('example', array('param1'=>'value2')
我想使用SoapUI执行相同的请求:

<soapenv:Envelope [..]>
   <soapenv:Header/>
   <soapenv:Body>
      <urn:call soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <param1 xsi:type="xsd:string">example</param1>
         <param2 xsi:type="xsd:anyType">
            ??
         </param2>
      </urn:call>
   </soapenv:Body>
</soapenv:Envelope>

例子
??

如何用XML对上述示例进行编码?

使用
json\u encode()
,然后将数组作为字符串表示发送。

它应该是这样的:

<soapenv:Envelope [..]>
   <soapenv:Header/>
   <soapenv:Body>
      <urn:call soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <param1 xsi:type="xsd:string">example</param1>
         <param2 xsi:type="xsd:anyType">
            <param1 xsi:type="xsd:string">value2</param1>
         </param2>
      </urn:call>
   </soapenv:Body>
</soapenv:Envelope>

例子
价值2

在本例中,有一个很好的PHP SOAP客户端函数:
$client->\uu getLastRequest()

它表明,请求是这样构建的:

<param2 xsi:type="ns2:Map">
    <item xsi:type="ns2:Map">
        <key xsi:type="xsd:string">param1</key>
        <value xsi:type="xsd:string">param2</value>
    </item>
</param2>

参数1
参数2

查看上一个问题的答案