duanlie3187 2018-12-04 10:11
浏览 100

PHP soap客户端调用停止脚本

the following Problem drives me crazy:

I am connected to a SOAP WS with WSDL and p12 certificate. I can call something and get the exception if the method is not correct, or if a Parameter is missing:

"Function ("Test1") is not a valid method for this service"
"SOAP-ERROR: Encoding: object has no 'message' property"

But if everything (I think) is correct, the script stops

try{
$client = new SoapClient(
        $soapUrl,
        array(
                'ssl' => array(
                        'cert' => $cert_file,
                        'certpasswd' => $cert_password),
                        'trace' => 1,
                        'exceptions' => 0
                        )
                )
);

$uuid = gen_uuid();

$SendValue = array('transaction' => Array('uuid'=>$uuid),
                   'message' => '-test message-',
                   'delay' => 0,
                   throwException => 1,
                   forceRollback => 0);
echo "<br>";                 

//           var_dump($SendValue);
        echo "Test Start - ";    // this is printed 
        $result = $client -> Test($SendValue);
            echo " - Test Ende";  // this is not printed anymore and all the below
                echo "<br>OK - Request:
" . $client->__getLastRequest(). "!
";


        echo "<pre>";
        print_r($result);
        echo "</pre>";
//-----------------------------------------------------------

echo "<h1>EOF</h1>";
}catch(\Exception $exception)
{
    echo "Did not work...";

 var_dump($exception);
 echo "Request:
" . $client->__getLastRequest() . "
";
 echo "Response:
" . $client->__getLastResponse() . "
";
}

echo "this is not printed";

Any suggestions please? Thanks a lot in Advance.

  • 写回答

1条回答 默认 最新

  • du16178 2018-12-04 10:34
    关注

    Looks like you placed the trace option in the wrong place in the configuration array. Rather than

        array(
                'ssl' => array(
                        'cert' => $cert_file,
                        'certpasswd' => $cert_password,
                        'trace' => 1,
                        'exceptions' => 0
                        )
                )
    

    it should be

        array(
                'ssl' => array(
                        'cert' => $cert_file,
                        'certpasswd' => $cert_password,
                        ) 
                'trace' => 1,
                'exceptions' => 0
                )
    

    An effectively unset trace option (when it's in the wrong place, the fallback default 0 is used) causes __getLastRequest() to be unavailable`, so you're probably getting "call to an undefined method error".

    The most possible reason you're not seeing this is your runtime php configuration that prevents you from seeing error messages. Refer to PHP's white screen of death to see how you can see the errors.

    It can also be that SoapClient throws a different type of exception instead of \SoapFault. Change that type to \Exception and see if you get anything.

    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号