处理Firstdata Global Gateway API的SOAP响应

时间:2013-04-20 18:08:17

标签: php soap

我在这里已经阅读了问题和答案。 Processing SOAP response

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

我收到错误

  

警告:main()[function.main]:result.php中不再存在节点   在第XX行,坏线是响应= ....

这是我的代码(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>"

0 个答案:

没有答案