致命错误:未捕获的SoapFault异常:[soap:Client]

时间:2013-01-05 17:49:12

标签: php soap payment-gateway

嗨我的支付网关有问题,当工作在网关完成时,它通过下面的编码返回到此文件

 <?php
 include("app/config.php"); 
 $db_connect = mysql_connect($AppConfig['db']['host'],$AppConfig['db']['user'],$AppConfig['db']['password']);
 mysql_select_db($AppConfig['db']['database'], $db_connect);
 $rest=mysql_query("SELECT * FROM p_players WHERE player_type=2" );   
 $rowa = mysql_fetch_assoc($rest); 
 $nameadmin=$rowa['name'];
 $idadmin=$rowa['id'];


 // Form Content
 echo '<html dir="rtl">
  <head>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <style>
    .title
    {
        height:30px;
    }     
    input
    {
        font-family:tahoma;
    }
  </style>
  </head>
  <body style="font-family:tahoma;line-height:30px">';
  //echo $this->package['cost'].'--'.$AppConfig['plus']['packages'][0]['cost'];

 // echo $st[1];
 // echo $AppConfig['plus']['payments']['paypal']['merchant_id'];
    if(isset($_POST['status']) && $_POST['status'] == 100){


    $Resnumber = $_POST['resnumber'];
    $Refnumber = $_POST['refnumber'];

    $info = split("_",$Resnumber,2);

    $UID = $info[0];
    $PgID = $info[1];

    $MerchantID = $AppConfig['plus']['payments']['paypal']['merchant_id'];
    $Password = $AppConfig['plus']['payments']['paypal']['key'];

    $Price = $AppConfig['plus']['packages'][$PgID]['cost'];

    $client = new SoapClient('http://merchant.parspal.com/WebService.asmx?wsdl');

    $res = $client->VerifyPayment(array("MerchantID" => $MerchantID , "Password" =>$Password , "Price" =>$Price,"RefNum" =>$Refnumber ));

    $Status = $res->verifyPaymentResult->ResultStatus;
    $PayPrice = $res->verifyPaymentResult->PayementedPrice;



    if($Status == 'success')// Your Peyment Code Only This Event
    {
    $result = mysql_query("SELECT * FROM p_players WHERE id='$UID'");
        while($row = mysql_fetch_array($result)){
            $idplayer=$row['id'];
            $nameplayer=$row['name'];
            $goldb=$AppConfig['plus']['packages'][$PgID]['gold'];

            $subject="خريد با موفقيت";
            $sendsms="خريد شما با موفقيت انجام شد و تعداد $goldb طلا به حسابتان واريز گرديد .  با تشکر از خريدتان -  شماره رسيد پرداخت $Refnumber";
            $Codemaker=rand(10000,200000000);
            $goldenb=0;


            mysql_query("UPDATE p_players SET gold_num = gold_num + '$goldb',new_mail_count=new_mail_count+1,codemaker='$Codemaker',goldb='$goldenb' where id='$idplayer' ") or die(mysql_error());  
            mysql_query("INSERT INTO `p_msgs` (`from_player_id`, `to_player_id`, `from_player_name`, `to_player_name`, `msg_title`, `msg_body`, `creation_date`, `is_readed`, `delete_status`) VALUES( '$idadmin', '$idplayer', '$nameadmin', '$nameplayer', '$subject', '$sendsms', now(), 0, 0)");
        }   


    echo '<div style="color:green">
      بازگشت از عمليات پرداخت، با موفقيت انجام شد.
      <br />
        شماره رسيد : '.$_POST['refnumber'].'
    <br/>
      <a href="http://'.$_SERVER['SERVER_NAME'].'">مشاهده سايت</a></div>';
      exit();
}
else {
    echo '<div style="color:red">
      شماره رسيد صحيح نمي باشد . '.$Status.'
      <br />
        شماره رسيد : '.$_POST['refnumber'].'
    <br/>
      <a href="http://'.$_SERVER['SERVER_NAME'].'">مشاهده سايت</a></div>';
      exit();
}

    }
    if(isset($_POST['status'])){
    echo '<div style="color:red">
  بازگشت از عمليات پرداخت، خطا در انجام عمليات پرداخت ( پرداخت ناموق ) !
  <br />
  <a href="http://'.$_SERVER['SERVER_NAME'].'">مشاهده سايت </a></div>';
  exit();
    }

   echo '</body>
    </html>';
  ?>

我正面临以下错误

  

致命错误:未捕获的SoapFault异常:[soap:Client]服务器无法读取请求。 ---&GT; XML文档中存在错误(2,235)。 ---&GT;输入字符串的格式不正确。在/home/travianx/public_html/ts1/parspal.php:53堆栈跟踪:#0 /home/travianx/public_html/ts1/parspal.php(53):SoapClient-&gt; __ call('VerifyPayment',Array)#1 /home/travianx/public_html/ts1/parspal.php(53):在第53行的/home/travianx/public_html/ts1/parspal.php中抛出的SoapClient-&gt; VerifyPayment(数组)#2 {main}

我与我的付款支持联系,他们说我必须提供访问权限:http://merchant.parspal.com/WebService.asmx?wsdl

我并没有发现他们如何以及如何说些什么!请帮我! 我有vps和cpanel安装在它上面

3 个答案:

答案 0 :(得分:8)

您需要捕获Soap客户端错误,它们通常会返回更多格式:

try{
    $client = new SoapClient('http://merchant.parspal.com/WebService.asmx?wsdl');
    $res = $client->VerifyPayment(array("MerchantID" => $MerchantID , "Password" =>$Password , "Price" =>$Price,"RefNum" =>$Refnumber ));
}catch (SoapFault $e){
    print_r($client);
    // or other error handling
}

答案 1 :(得分:0)

在我的情况下,服务器不可访问(受IP限制),并且Web服务中的标准错误页面具有一些DTD标头:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

取消ip访问限制(项目仍在开发中)解决了问题;)

答案 2 :(得分:-2)

我解决了这个问题,只需要在你的webservice php代码的末尾避免空间

<?php

.. (my php webservice)
.. (some code)
..

$server->service($POST_DATA);
exit();
?>**(here have an space or enter who cause this problem)**