0

我已经阅读了这里的问题和答案。 处理 SOAP 响应

所以我有几乎相同的东西,但有些物品的情况不同

我得到错误

警告:main() [function.main]:节点不再存在于第 XX 行的 result.php 中,错误的行是 response = ...。

这是我的代码(result.php)

<?php 
$result = "<soap-env:envelope xmlns:soap-env='http://schemas.xmlsoap.org/soap/envelope/'><soap-env:header><soap-env:body><fdggwsapi:fdggwsapiorderresponse xmlns:fdggwsapi='http://secure.linkpt.net/fdggwsapi/schemas_us/fdggwsapi'><fdggwsapi:commercialserviceprovider><fdggwsapi:transactiontime>Fri Apr 19 16:35:45 2013</fdggwsapi:transactiontime><fdggwsapi:transactionid><fdggwsapi:processorreferencenumber><fdggwsapi:processorresponsemessage><fdggwsapi:errormessage>SGS-005003: The order already exists in the database.</fdggwsapi:errormessage><fdggwsapi:orderid>25</fdggwsapi:orderid><fdggwsapi:approvalcode><fdggwsapi:avsresponse><fdggwsapi:tdate><fdggwsapi:transactionresult>DUPLICATE</fdggwsapi:transactionresult><fdggwsapi:processorresponsecode><fdggwsapi:processorapprovalcode><fdggwsapi:calculatedtax><fdggwsapi:calculatedshipping><fdggwsapi:transactionscore><fdggwsapi:fraudaction><fdggwsapi:authenticationresponsecode></fdggwsapi:authenticationresponsecode></fdggwsapi:fraudaction></fdggwsapi:transactionscore></fdggwsapi:calculatedshipping></fdggwsapi:calculatedtax></fdggwsapi:processorapprovalcode></fdggwsapi:processorresponsecode></fdggwsapi:tdate></fdggwsapi:avsresponse></fdggwsapi:approvalcode></fdggwsapi:processorresponsemessage></fdggwsapi:processorreferencenumber></fdggwsapi:transactionid></fdggwsapi:commercialserviceprovider></fdggwsapi:fdggwsapiorderresponse></soap-env:body></soap-env:header></soap-env:envelope>"


    print "<br /><hr /><br />";

    $response = "";
    $obj2 = "";
    $obj2 = simplexml_load_string($result);
    $obj2->registerXPathNamespace('soap-env', 'http://schemas.xmlsoap.org/soap/envelope/');
    $obj2->registerXPathNamespace('fdggwsapi','http://secure.linkpt.net/fdggwsapi/schemas_us/fdggwsapi');

    $response = $obj2->children('http://schemas.xmlsoap.org/soap/envelope/')->body->children('http://secure.linkpt.net/fdggwsapi/schemas_us/fdggwsapi')->fdggwsapiorderresponse;


echo $response->transactiontime . "\n";
echo $response->errormessage;

结果产生的 vardump

string(1427) "<soap-env:envelope xmlns:soap-env='http://schemas.xmlsoap.org/soap/envelope/'><soap-env:header><soap-env:body><fdggwsapi:fdggwsapiorderresponse xmlns:fdggwsapi='http://secure.linkpt.net/fdggwsapi/schemas_us/fdggwsapi'><fdggwsapi:commercialserviceprovider><fdggwsapi:transactiontime>Fri Apr 19 16:35:45 2013</fdggwsapi:transactiontime><fdggwsapi:transactionid><fdggwsapi:processorreferencenumber><fdggwsapi:processorresponsemessage><fdggwsapi:errormessage>SGS-005003: The order already exists in the database.</fdggwsapi:errormessage><fdggwsapi:orderid>25</fdggwsapi:orderid><fdggwsapi:approvalcode><fdggwsapi:avsresponse><fdggwsapi:tdate><fdggwsapi:transactionresult>DUPLICATE</fdggwsapi:transactionresult><fdggwsapi:processorresponsecode><fdggwsapi:processorapprovalcode><fdggwsapi:calculatedtax><fdggwsapi:calculatedshipping><fdggwsapi:transactionscore><fdggwsapi:fraudaction><fdggwsapi:authenticationresponsecode></fdggwsapi:authenticationresponsecode></fdggwsapi:fraudaction></fdggwsapi:transactionscore></fdggwsapi:calculatedshipping></fdggwsapi:calculatedtax></fdggwsapi:processorapprovalcode></fdggwsapi:processorresponsecode></fdggwsapi:tdate></fdggwsapi:avsresponse></fdggwsapi:approvalcode></fdggwsapi:processorresponsemessage></fdggwsapi:processorreferencenumber></fdggwsapi:transactionid></fdggwsapi:commercialserviceprovider></fdggwsapi:fdggwsapiorderresponse></soap-env:body></soap-env:header></soap-env:envelope>"

这是以更漂亮的形式出现的 SOAP 响应,这就是您正在寻找的

<soap-env:envelope xmlns:soap-env='http://schemas.xmlsoap.org/soap/envelope/'>
<soap-env:header><soap-env:body>
<fdggwsapi:fdggwsapiorderresponse xmlns:fdggwsapi='http://secure.linkpt.net/fdggwsapi/schemas_us/fdggwsapi'>
    <fdggwsapi:commercialserviceprovider>
        <fdggwsapi:transactiontime>Fri Apr 19 16:35:45 2013</fdggwsapi:transactiontime>
        <fdggwsapi:transactionid>
            <fdggwsapi:processorreferencenumber>
                <fdggwsapi:processorresponsemessage>
                <fdggwsapi:errormessage>SGS-005003: The order already exists in the database.</fdggwsapi:errormessage>
                <fdggwsapi:orderid>25</fdggwsapi:orderid>
                    <fdggwsapi:approvalcode>
                    <fdggwsapi:avsresponse>
                        <fdggwsapi:tdate>
                        <fdggwsapi:transactionresult>DUPLICATE</fdggwsapi:transactionresult>
                            <fdggwsapi:processorresponsecode>
                                <fdggwsapi:processorapprovalcode>
                                    <fdggwsapi:calculatedtax>
                                        <fdggwsapi:calculatedshipping>
                                            <fdggwsapi:transactionscore>
                                                <fdggwsapi:fraudaction>
                                                    <fdggwsapi:authenticationresponsecode>
                                                    </fdggwsapi:authenticationresponsecode>
                                                </fdggwsapi:fraudaction>
                                            </fdggwsapi:transactionscore>
                                        </fdggwsapi:calculatedshipping>
                                    </fdggwsapi:calculatedtax>
                                </fdggwsapi:processorapprovalcode>
                            </fdggwsapi:processorresponsecode>
                        </fdggwsapi:tdate>
                    </fdggwsapi:avsresponse>
                </fdggwsapi:approvalcode>
                </fdggwsapi:processorresponsemessage>
            </fdggwsapi:processorreferencenumber>
        </fdggwsapi:transactionid>
    </fdggwsapi:commercialserviceprovider>
</fdggwsapi:fdggwsapiorderresponse>
</soap-env:body>
</soap-env:header>
</soap-env:envelope>"
4

0 回答 0