我正在使用Web服务,但无法连接,总是收到此错误消息:
SOAP错误:解析模式:无法从domain.com/WebService.svc?xsd=xsd0导入模式
我确实找到了我没有找到解决方案的所有SO问题。
Linux,php7.1
bz2, calendar, Core, ctype, curl, date, dom, exif, fileinfo, filter, ftp, gd,
gettext, hash, iconv, intl, json, ldap, libxml, mbstring, mysqli, mysqlnd,
openssl, pcntl, pcre, PDO, pdo_dblib, pdo_mysql, pdo_sqlite, Phar, posix,
readline, Reflection, session, shmop, SimpleXML, soap, sockets, SPL,
sqlite3, standard, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xml,
xmlreader, xmlwriter, xsl, zip, zlib
$wsdlFile = **fullpathtowsdlfile**;
$context = stream_context_create([
'ssl' => [
// set some SSL/TLS specific options
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
],
'http'=>array(
'user_agent'=>'SoapClient'
)
]);
$options = array(
'trace'=>1,
'location'=>self::$wsdl,
'exception'=>1,
'cache_wsdl'=>WSDL_CACHE_NONE,
//'stream_context'=>$context, // disable but leaved for reference.
'local_cert'=> **fullpath**,
'soap_version'=> SOAP_1_1
);
$client = new \SoapClient($wsdlFile, $options);
也尝试了Url而不是Wsdl文件,但出现了同样的错误。我可以通过telnet域80,telnet域413以及浏览器连接到url。
我缺少什么?任何帮助将不胜感激。
答案 0 :(得分:0)
问题是自签名证书,我将代码更新为此,现在错误消失了。
$context = stream_context_create([
'ssl' => [
// set some SSL/TLS specific options
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
]);
$options = array(
'trace'=>1,
'exception'=>0,
'stream_context'=>$context,
);
$client = new \SoapClient($wsdlFile, $options);