1

我正在尝试创建一个 PHP 脚本,该脚本将使用 SOAP 和 xml 将潜在客户发送给商家,但我遇到了这个错误:

致命错误:未捕获的 SoapFault 异常:[WSDL] SOAP-ERROR:解析 WSDL:无法从“ https://tst.webservices.outsurance.co.za/SecureHost/Lead/LeadPostService.svc?wsdl ”加载:未能加载外部实体“ https://tst.webservices.outsurance.co.za/SecureHost/Lead/LeadPostService.svc?wsdl

我似乎无法连接到安全网络服务。他们说我应该包含一个证书,所以我包含了它,但我仍然遇到同样的错误。我搜索了一些解决方案,其中大多数都建议启用、openssl、fopen 等,但所有这些都已在我的服务器上启用。这是我的代码:

function sendRequest($url, $params)
{
    $request = curl_init($url); // initiate curl object
    curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
    curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
    curl_setopt($request, CURLOPT_POSTFIELDS, $params); // use HTTP POST to send form data
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response.
    $response = curl_exec($request); // execute curl post and store results in $post_response
    curl_close ($request); // close curl object
    return $response;
}


// Get Variables sent from websites
$uname = $_GET['un'];
$usname = $_GET['ul'];
$uphone = $_GET['up'];
$uemail = $_GET['ue'];
$testlive = $_GET['test'];
$aff_id = $_GET['af'];
$unique_id = $_GET['uid'];
$script = $_GET['script'];

// Convert URL and Name split
$rurl = 'http://'.$_GET['rurl'];

// Split Name if no surname entered
if (strlen($usname) > 0) {
    $firstname = $uname;
    $lastname = $usname; // I have a first and lastname
} else {
    list($firstname, $lastname) = explode(" ",$uname,2); // I only entered my firstname
}
// Determine phone number format
$phoneformat = strpos($uphone,'-');
if($phoneformat === false) {
 // string - NOT found in haystack
 $phonesubmit = $uphone; 
} else {
    $phone1 = substr($uphone,0,3);
    $phone2 = substr($uphone,4,3);
    $phone3 = substr($uphone,8,4);
    $phonesubmit = $phone1.$phone2.$phone3;
}
// Determine Live or Test
$testlive = strtolower($testlive);
switch ($testlive) {
    case "test":
        $debug = true; //Set this to 'false' to redirect users
        $outurl = 'https://tst.webservices.outsurance.co.za/SecureHost/Lead/LeadPostService.svc?wsdl'; // Set to TEST environment
        break;
    case "live":
        $debug = false;
        $outurl = 'https://webservices.outsurance.co.za/SecureHost/Lead/LeadPostService.svc?wsdl'; // Set to LIVE environment
        break;
}

// Set Variables
if($debug) echo("<pre>\n");
if($debug) echo("Form data complete\n");
if($debug) echo("Creating XML document\n");

$cert = "certificate.cer";
$client = new SoapClient($outurl, array('local_cert'=>file_get_contents($cert)));

$xml = new stdClass();
$xml->mode = 'LIVE';
$xml->title = '';
$xml->firstname = $firstname;
$xml->lastname = $lastname;
$xml->id = $unique_id;
$xml->homecode = '';
$xml->hometel = '';
$xml->workcode = '';
$xml->worktel = '';
$xml->mobile = $phonesubmit;
$xml->homecode = '';
$xml->email = $uemail;
$xml->comment = $script;
$xml->source = 'UPSTART';
$xml->notes = '';
$xml->language = 'E';
$xml->product = 'P';

$result = $client->SubmitAffiliateLead($xml);
print_r($result);
4

0 回答 0