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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14174584/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 06:48:13  来源:igfitidea点击:

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

phpsoappayment-gateway

提问by user1925409

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

致命错误:未捕获的 SoapFault 异常:[soap:Client] 服务器无法读取请求。---> XML 文档中有错误 (2, 235)。---> 输入字符串的格式不正确。在 /home/travianx/public_html/ts1/parspal.php:53 堆栈跟踪:#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} 在第 53 行的 /home/travianx/public_html/ts1/parspal.php 中抛出

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

我联系了我的付款支持,他们说我必须提供访问权限: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

我没有发现他们怎么说以及他们说什么!请帮我!我有 vps 并且安装了 cpanel

回答by Samuel Cook

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

您需要捕获 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
}

回答by Harald Ernst

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

在我的情况下,服务器无法访问(IP 受限)并且来自 Web 服务的标准错误页面有一些 DTD 标头:

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

<!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 ;)

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

回答by karla

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

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

<?php

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

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