dtuy84033 2018-01-23 09:06
浏览 58
已采纳

Live服务器上的SOAP-ERROR

Good day all,

I have a problem I have code a soap client that checks if a user have a valid TV license when they purchase a set of TV in my website,

The program works fine on local host with no errors and it returns the results, When moved to the live server, it gives the following error:

Error!"SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://secure4.tvlic.co.za/AccountEnquiryService_Test_1.0/AccountEnquiryService.svc?wsdl' : failed to load external entity \"https://secure4.tvlic.co.za/AccountEnquiryService_Test_1.0/AccountEnquiryService.svc?wsdl\" "

My code :

<?php
$wdsl    = "https://secure4.tvlic.co.za/AccountEnquiryService_Test_1.0/AccountEnquiryService.svc?wsdl";
$opts = array(
    'http' => array(
            'user_agent' => 'PHPSoapClient'
        )
);

$context = stream_context_create($opts);

$soapClientOptions = array(
        'stream_context' => $context,
        'cache_wsdl' => WSDL_CACHE_NONE
    );
//Generate GUID
function getGUID()
{
    if (function_exists('com_create_guid')) {
        return com_create_guid();
    } else {
        mt_srand((double) microtime() * 10000);
        $charid = strtoupper(md5(uniqid(rand(), true)));
        $hyphen = chr(45); // "-"
        $uuid   = chr(123) // "{"
            . substr($charid, 0, 8) . $hyphen . substr($charid, 8, 4) . $hyphen . substr($charid, 12, 4) . $hyphen . substr($charid, 16, 4) . $hyphen . substr($charid, 20, 12) . chr(125); // "}"
        return trim($uuid, '{}');
    }
}

$quid = getGUID();


$licencetype = isset($_POST['licencetype']) ? $_POST['licencetype'] : NULL;
switch ($licencetype) {

    case 'domestic':
        $holder_id = isset($_POST['holder_id']) ? $_POST['holder_id'] : NULL;
        try {
            $client = new SoapClient($wdsl, $soapClientOptions);
            $client->__setLocation('https://secure4.tvlic.co.za/AccountEnquiryService_1.0/AccountEnquiryService.svc');

            $arrParams = array(
                'request' => array(
                    'Header' => array(
                        'Rquid' => $quid,
                        'ApiKey' => '2c261e98-90ca-4f7d-90a0-1f5e91ebf416'
                    ),
                    'AccountIdentifier' => $holder_id,
                    'AccountIdentifierType' => 'SaidNumber'
                )
            );

            $account   = $client->GetAccount($arrParams);
            echo json_encode($account);
        }
        catch (\Exception $e) {
            echo "Error!";
            echo json_encode($e->getMessage());
            echo 'Last response: ' . $client->__getLastResponse();
        }
        break;

    case 'business':
        $tvlicencenumber = isset($_POST['tvlicence']) ? $_POST['tvlicence'] : NULL;
        try {
            $client = new SoapClient($wdsl, $soapClientOptions);
            $client->__setLocation('https://secure4.tvlic.co.za/AccountEnquiryService_1.0/AccountEnquiryService.svc');

            $arrParams = array(
                'request' => array(
                    'Header' => array(
                        'Rquid' => $quid,
                        'ApiKey' => '5957237e-101c-4ff2-8fdc-4bd6c9393a1d'
                    ),
                    'AccountIdentifier' => $tvlicencenumber,
                    'AccountIdentifierType' => 'AccountNumber'
                )
            );

            $account   = $client->GetAccount($arrParams);
            echo json_encode($account);
        }
        catch (\Exception $e) {
            echo "Error!";
            echo json_encode($e->getMessage());
            echo 'Last response: ' . $client->__getLastResponse();
        }
        break;

    case 'dealer':
        $tvlicencenumber = isset($_POST['tvlicence']) ? $_POST['tvlicence'] : NULL;
        try {
            $client = new SoapClient($wdsl, $soapClientOptions);
            $client->__setLocation('https://secure4.tvlic.co.za/AccountEnquiryService_1.0/AccountEnquiryService.svc');

            $arrParams = array(
                'request' => array(
                    'Header' => array(
                        'Rquid' => $quid,
                        'ApiKey' => '5957237e-101c-4ff2-8fdc-4bd6c9393a1d'
                    ),
                    'AccountIdentifier' => $tvlicencenumber,
                    'AccountIdentifierType' => 'AccountNumber'
                )
            );

            $account   = $client->GetAccount($arrParams);
            echo json_encode($account);
        }
        catch (\Exception $e) {
            echo "Error!";
            echo json_encode($e->getMessage());
            echo 'Last response: ' . $client->__getLastResponse();
        }
        break;

    default:

        echo json_encode('Please select licence type');
}
?>

Xampp uses :

php 5.6

Live server

PHP/5.6.33-0+deb8u1

Please help solve this error

  • 写回答

1条回答 默认 最新

  • douyanyan1123 2018-01-23 09:38
    关注

    Are you sure that https://secure4.tvlic.co.za/AccountEnquiryService_1.0/AccountEnquiryService.svc is the right location for SOAP client? When I open it in a browser, it shows an error - Metadata publishing for this service is currently disabled. Even if that's because I don't initialize the SOAP client to open it, you still seem to mix test and live APIs, judging from your WSDL (BTW you named the wsdl variable $wdsl, I guess typo, but you use it consistently so that shouldn't be an issue) and SOAP addresses.

    Compare:

    ↓ SOAP address (not working, even with ?wsdl appended) https://secure4.tvlic.co.za/AccountEnquiryService_1.0/AccountEnquiryService.svc https://secure4.tvlic.co.za/AccountEnquiryService_Test_1.0/AccountEnquiryService.svc?wsdl ↑ WSDL address (working)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥15 绘制多分类任务的roc曲线时只画出了一类的roc,其它的auc显示为nan
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?