我试图弄清楚如何使用 SoapClient 在 PHP 中处理 WSDL,但我感到很害怕:
SoapFault exception: [soap:Server] Server was unable to process request. ---> Object reference not set to an instance of an object.
这是我尝试使用的功能:
CheckInventoryResponse CheckInventory(CheckInventory $parameters)
结构:
string(47) "struct CheckInventory {
InventoryRequest ir;
}"
我想做什么:
class PhpCheckInventory {
public $ir;
}
$client = new SoapClient($wsdl);
$header = new SOAPHeader($wsdl, 'Authentication', array('Username' => $username, 'Password' => $password));
$client->__setSoapHeaders($header);
try {
$parameter1 = new PhpCheckInventory();
$parameter2 = new SoapParam($parameter1, 'CheckInventory');
$result = $client->CheckInventory($parameter2);
} catch (SoapFault $exception) {
echo $exception;
}