在PHP中,如何从具有多个同名项的数组中正确生成SOAP WSDL请求?
我需要在PHP中生成以下XML Soap请求:在PHP中,如何从具有多个同名项的数组中正确生成SOAP WSDL请求?,php,xml,soap,wsdl,soap-client,Php,Xml,Soap,Wsdl,Soap Client,我需要在PHP中生成以下XML Soap请求: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header/> <soapenv:Body> <ns1:SomeRequest enddate="01-01-2018 00:00:00" authCode="exampleexample">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<ns1:SomeRequest enddate="01-01-2018 00:00:00" authCode="exampleexample">
<ns1:status>STATUS1</ns1:status>
<ns1:status>STATUS2</ns1:status>
</ns1:SomeRequest>
</soapenv:Body>
</soapenv:Envelope>
和接收数组到字符串的转换错误。
当我尝试将状态作为字符串传递时,如下所示:
$this->client = new SoapClient($this->wsdlUrl, [
'trace' => true,
'exception' => true,
'cache_wsdl' => WSDL_CACHE_NONE,
]);
$parameters = [
'authCode' => 'exampleexample',
'enddate' => '01-01-2018 00:00:00',
'status' => ['STATUS1', 'STATUS2']
];
$response = $this->client->SomeSimpleMethod($parameters);
$parameters = [
'authCode' => 'exampleexample',
'enddate' => '01-01-2018 00:00:00',
'status' => 'STATUS1'
];
然后一切正常。最好的方法是使用WSDL-to-PHP生成器,因为您不会想知道如何正确构造请求。由于使用生成的类构造请求并发送请求并不总是很简单,因此您可以使用OOP方法轻松地发送请求并处理响应 尝试最适合从任何soapwsdl生成phpsdk的项目