我有这个 WSDL:https ://secure.softwarekey.com/solo/webservices/XmlCustomerService.asmx?WSDL
我正在尝试使用 SoapClient 向CustomerSearch方法发送请求。
我正在使用的代码如下:
$url = 'https://secure.softwarekey.com/solo/webservices/XmlCustomerService.asmx?WSDL';
$client = new SoapClient($url);
$CustomerSearch = array(
'AuthorID' => $authorID,
'UserID' => $userID,
'UserPassword' => $userPassword,
'Email' => $customerEmail
);
$xml = array('CustomerSearch' => $CustomerSearch);
$result = $client->CustomerSearch(array('xml' => $xml));
当我运行代码时,我得到以下 PHP 异常:
Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object has no 'any' property
我也为 XML 尝试过这个:
$xml = "
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<CustomerSearch>
<AuthorID>$authorID</AuthorID>
<UserID>$userID</UserID>
<UserPassword>$userPassword</UserPassword>
<Email>$customerEmail</Email>
</CustomerSearch>
";
这给了我以下结果(来自 print_r):
object(stdClass)#4 (1) { ["CustomerSearchResult"]=> object(stdClass)#5 (1) { ["any"]=> string(108) "-2Invalid Xml Document" } }
文档说输入 XML 应该是这样的:
<CustomerSearch>
<AuthorID></AuthorID>
<UserID></UserID>
<UserPassword></UserPassword>
<SearchField></SearchField>
<SearchField></SearchField>
<!-- ...additional SearchField elements -->
</CustomerSearch>
我对 Soap 还很陌生,我尝试过搞乱(传入原始的、输入的 XML),但似乎无法让它工作。任何关于我可能做错了什么的见解将不胜感激。