SOAP 错误:解析 WSDL:无法从<URL加载>

2022-08-30 22:40:04

在 PHP 中:我收到一个错误:

SOAP-ERROR:解析 WSDL:无法从“http://xxx.xxxx.asmx 加载?WSDL' : 无法加载外部实体“http://xxx.xxxx.asmx?断续器"

我的代码是:

<?php
header('Content-Type: text/plain');
if (!class_exists('SoapClient')) {
    die ("You haven't installed the PHP-Soap module.");
}

ini_set('max_execution_time', 1);
try {
    $options = array(
        'soap_version' => SOAP_1_2,
        'exceptions'   => true,
        'trace'        => 1,
        'cache_wsdl'   => WSDL_CACHE_NONE
    );
    $client = new SoapClient('http://xxx.xxxx.asmx?WSDL', $options);
    // Note where 'CreateIncident' and 'request' tags are in the XML
    $results = $client->CreateIncident(
        array(
            'FirstName'         => 'gyaan',
            'LastName'          => 'p',
            'Email'             => 'aa@gmail.com',
            'QueryProductClass' => 'QueryProductClass',
            'ChannelCode'       => 12,
            'CampaignCode'      => 234,
            'Lob'               => 'Lob',
            'PackageName'       => 'SEONI',
            'PackageCode'       => 'SMP',
            'TravelYear'        => 2012,
            'TravelMonth'       => 06,
            'TravelDay'         => 29,
            'CityOfResidence'   => 'Jabalpur',
            'ncidentNotes'      => 'testing ignor this',
            'MobilePhone'       => '1234567890',
            'DepartureCity'     => 'bangalore',
            'NoOfDaysTravel'    => '3 Days',
            'VendorName'        => 'TEST HIQ'
        )
    );
}
catch (Exception $e) {
    echo "<h2>Exception Error!</h2>";
    echo $e->getMessage();
}
?>

请告诉我我在哪里犯错,我是WSDL和肥皂的新手


答案 1

我通过启用扩展程序在WAMP设置中解决了这个问题,因为我从中加载的URL使用了。php_opensslhttps://


答案 2

我有完全相同的错误消息。在我的情况下,在我的文件(在托管服务的服务器上)为WSDL中引用的目标服务器创建一个条目修复了它。/etc/hosts

有点奇怪的错误消息。.


推荐