【发布时间】:2021-12-29 20:45:06
【问题描述】:
我正在尝试向本地打印机端点 - http://192.168.1.116/WebServices/PrinterService 发出 SOAP 请求。通常,要获取与您在 URL 末尾添加 ?wsdl 的端点相对应的 WSDL,但在这种情况下,它不起作用。
谢天谢地,可以从 https://docs.microsoft.com/en-us/windows-hardware/drivers/print/ws-print-v1-1 下载 WSDL。因此,我可以从本地文件系统中读取它:
$client = new SoapClient(dirname(__FILE__) . '/WebPackage/WSDPrinterService.wsdl', ['trace' => 1]);
$client->SendDocument();
问题是这段代码总是出现以下错误:
[29-Dec-2021 14:39:11 America/Chicago] PHP Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in /home/neubert/test.php:9
Stack trace:
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://localhos...', 'http://schemas....', 1, 0)
#1 /home/neubert/test.php(9): SoapClient->__call('SendDocument', Array)
#2 {main}
thrown in /home/neubert/test.php on line 9
__doRequest ($location) 的第二个参数是 'http://localhos...'。这很可能是 localhost 被截断了。
我的问题是...我如何才能使本地文件系统上的 WSDL 不总是发布到本地主机?
我在 WebPackage 目录中做了grep -r localhost . 并将所有这些实例替换为 192.168.1.116 并且仍然收到错误。
有什么想法吗?
【问题讨论】:
标签: php web-services soap wsdl