这是我们在发送 SOAP 请求时在项目中面临的常见 Soap 错误。
请在下面找到 PHP 代码和 SOAP 请求示例......
$client = new SoapClient("url for wsdl",
array(
'soap_version' => SOAP_1_1, // Default Version
'trace' => true,
'exceptions' => true,
'style' => SOAP_RPC,
'use' => SOAP_ENCODED
)
);
$parimaryName = array(
"Company" => "xyz",
"FirstName" => "test",
"LastName" => "test",
"Mi"=>"test",
"NickName" => "t",
"Email" => "test@test.com"
);
$customer = array(
"CustClassificationID" => 12345,
"PrimaryName" => $parimaryName,
"EnrollerDistributorID" => 345545
);
$webser= array(
'APIKey' => 'xxx-xxx-xxxx',
'CompanyID' => xxx,
"Customer"=> $customer
);
$ccRequest= array(
"WebServiceCredentialsBase"=>$webser,
"CustomerCreateOnlyRequest"=>$req
);
$final= array( 'Request' => $ccRequest);
try {
$result = $client->myServiceCall($final);
echo "<pre>"; print_r($result); echo "</pre>";
echo "Success"."<br />";
echo("\n<p><pre>Dumping request:\n" . htmlspecialchars($client->__getLastRequest()) . '</pre></p>');
echo("\n<p><pre>Dumping response:\n" . htmlspecialchars($client->__getLastResponse()) . '</pre></p>');
} catch(Exception $e) {
echo "Failure"."<br />";
echo("\n<p><pre>Dumping request:\n" . htmlspecialchars($client->__getLastRequest()) . '</pre></p>');
echo("\n<p><pre>Dumping response:\n" . htmlspecialchars($client->__getLastResponse()) . '</pre></p>');
echo "Caught Exception"; echo "</br>";
var_dump($e->getMessage());
}
错误 :-
Caught Exception
string(56) "SOAP-ERROR: Encoding: object has no 'CompanyID' property"
我试图调试错误但没有解决方案!
请指导我在哪里做错了!
谢谢 !!