2

次の PHP コードを使用して SOAP 接続を確立しようとしていますが、SoapClient コンストラクトの時点で失敗しています。

// Need to declare these settings here because our php.ini has alternate
// settings due to global purposes for other PHP scripts
ini_set("soap.wsdl_cache_enabled", "0");
ini_set("soap.wsdl_cache", "0");
ini_set("display_errors","On");
ini_set("track_errors","On");

// FedEx web services URL, note the HTTPS
$path_to_wsdl = 'https://wsbeta.fedex.com/web-services';

$soap_args = array(
    'exceptions'=>true,
    'cache_wsdl'=>WSDL_CACHE_NONE,
    'trace'=>1)
;

try {
    $client = new SoapClient($path_to_wsdl,$soap_args);
} catch (SoapFault $e) {
    var_dump(libxml_get_last_error());
    echo "<BR><BR>";
    var_dump($e);
}

これは以下を出力します:

object(LibXMLError)#1 (6) {
    ["level"]=> int(1)
    ["code"]=> int(1549)
    ["column"]=> int(0)
    ["message"]=> string(71) "failed to load external entity "https://wsbeta.fedex.com/web-services" "
    ["file"]=> string(0) ""
    ["line"]=> int(0)
}

object(SoapFault)#2 (9) {
    ["message":protected]=> string(158) "SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://wsbeta.fedex.com/web-services' : failed to load external entity "https://wsbeta.fedex.com/web-services" "
    ["string":"Exception":private]=> string(0) ""
    ["code":protected]=> int(0)
    ["file":protected]=> string(53) "/mnt/array/bell-enterprise/bell/fedex_shipservice.php"
    ["line":protected]=> int(34)
    ["trace":"Exception":private]=> array(1) {
        [0]=> array(6) {
            ["file"]=> string(53) "/mnt/array/bell-enterprise/bell/fedex_shipservice.php"
            ["line"]=> int(34)
            ["function"]=> string(10) "SoapClient"
            ["class"]=> string(10) "SoapClient"
            ["type"]=> string(2) "->"
            ["args"]=> array(2) {
                [0]=> string(37) "https://wsbeta.fedex.com/web-services"
                [1]=> array(4) {
                    ["exceptions"]=> bool(true)
                    ["soap_version"]=> int(1)
                    ["cache_wsdl"]=> int(0)
                    ["trace"]=> int(1)
                }
            }
        }
    }
    ["previous":"Exception":private]=> NULL
    ["faultstring"]=> string(158) "SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://wsbeta.fedex.com/web-services' : failed to load external entity "https://wsbeta.fedex.com/web-services" "
    ["faultcode"]=> string(4) "WSDL"
}
4

3 に答える 3

8

6 時間の頭痛の後、唯一の解決策は WSDL ファイルをダウンロードすることです。

https://wsbeta.fedex.com/web-services および https://ws.fedex.com/web-services

これは wsdl ではないため、常にエラー 500 がスローされます。

Technical Resources -> FedEx WebServices For Shipping -> GetStarted から wsdls をダウンロードしたら([Rate Services] をクリックし、[Download WSDL or XML] をクリックします)、スクリプトでローカルに保存された WSDL をロードする必要があり、すべてが機能します。魔法のように。

$this->_soapClient = new SoapClient("RateService_v13.wsdl", array('exceptions'=>true, 'trace' => true));

楽しむ!

于 2013-08-06T21:59:20.713 に答える
2

その URL は WSDL へのパスではなく、SOAP リクエストが送信される URL です。みんなと一緒に仕事をしたことはありませんが、wsdlファイルをどこかで取得してローカルに保存し、そのwsdlのエンドポイントをwsbetaのものに変更できると思います。wsdl が見つからず、fedex サイトではサインアップせずに開発技術リソースにアクセスすることはできません。そのため、そのままにしておきます。wsdlは別の場所にあり、あなたが持っている URL は次の場所です。特定のサービス。

于 2013-04-24T18:14:29.910 に答える
0

HTTPSでWSDLにアクセスするには、ローカル証明書ファイルが必要です。

$client = new SoapClient($wsdl, array('local_cert' => $pathToLocalCert));

このオプションを現在のコードに追加する$soap_argsと、このコードは期待どおりに機能するはずです。証明書に必要なpassphrase場合は、オプションも利用できます。

于 2012-04-25T15:16:51.680 に答える