Php 如何在SOAP中发送数组?
我有一个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
$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
查看上一个问题的答案