我有一个基于symfony的产品,我必须在其中公开Soap API.我创建了wsdl文件,在输入用户名和密码后可以从浏览器访问以进行基本的http身份验证.
当我使用SoapClient调用该API并通过头提供用户名和密码时,它能够访问WSDL并调用SoapServer Endpoint.但是当SoapServer()调用该wsdl链接时,它显示错误.
SoapClient的():
$client = new \SoapClient('http://example.com/soaptest?wsdl', array(
"exceptions" => 0,
"trace" => 1,
'stream_context' => stream_context_create(array(
'http' => array(
'header' => "Authorization: Basic " . base64_encode("$username:$password")
),
)),
));
Run Code Online (Sandbox Code Playgroud)
SoapServer的():
ini_set("soap.wsdl_cache_enabled", "0");
$server = new SoapServer($wsdl); //Here SoapServer not able to access WSDl because of .htaccess
$server->setObject($this->get($class));
ob_start();
$server->handle();
$result = ob_get_clean();
return $result;
Run Code Online (Sandbox Code Playgroud)
我也有一个.htaccess:
DirectoryIndex app.php
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .
RewriteRule …Run Code Online (Sandbox Code Playgroud)