简体   繁体   中英

Fatal error: Uncaught SoapFault exception: [soap:Client]

hi I have a problem with my payment gateway , when the work finishes in gateway and it returns to this file by coding below

 <?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>';
  ?>

I'm facing this following error

Fatal error: Uncaught SoapFault exception: [soap:Client] Server was unable to read request. ---> There is an error in XML document (2, 235). ---> Input string was not in a correct format. in /home/travianx/public_html/ts1/parspal.php:53 Stack trace: #0 /home/travianx/public_html/ts1/parspal.php(53): SoapClient->__call('VerifyPayment', Array) #1 /home/travianx/public_html/ts1/parspal.php(53): SoapClient->VerifyPayment(Array) #2 {main} thrown in /home/travianx/public_html/ts1/parspal.php on line 53

I contact with my payment support and they said that I must give access to this : http://merchant.parspal.com/WebService.asmx?wsdl

And I didnt find out how and what they say about ! please help me! i have vps and cpanel is installed on it

You need to catch your Soap client errors, they will usually return much more formatted:

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
}

In my case the server was not accessible (ip restricted) and the standard error page from the web service had some DTD header:

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

Removing the ip access restriction (project was still in development) solved the problem ;)

I solve this problem, only have to avoid space at the end of your webservice php code

<?php

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM