如何在php中创建Soap Client。

时间:2016-09-19 10:51:36

标签: php web-services soap

我正在尝试创建一个PHP soap客户端。 以下是我的soap请求XML Schema

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://olp.bank.com/payement/service/olppaymentmanager/req">
   <soapenv:Header/>
   <soapenv:Body>
      <req:initiatePaymentDetailsReq>
         <olpIdAlias>****</olpIdAlias>
         <merchantId>****</merchantId>
         <merchantRefNum>234324</merchantRefNum>
         <paymentAmount>200</paymentAmount>
         <paymentCurrency>SAR</paymentCurrency>
         <dynamicMerchantLandingURL></dynamicMerchantLandingURL>
         <dynamicMerchantFailureURL></dynamicMerchantFailureURL>
      </req:initiatePaymentDetailsReq>
   </soapenv:Body>
</soapenv:Envelope>

以下是我的 var_dump($ client-&gt; __ getFunctions())输出

array(1) { [0]=> string(95) "initiatePaymentDetailsRes executeRB_OLP_INITIATE_PAYMENT(initiatePaymentDetailsReq $parameters)" } 

任何人都可以帮助我为上述soap请求编写PHP客户端吗?我从2个星期开始尝试。我失败了。得到错误

PHP代码

include 'initiatePaymentDetailsReq.php';

$wsdl = dirname(__FILE__).'/librb/RB_OLP_INITIATE_PAYMENT.wsdl';

$endpoint       = 'https://b2b.bank.com/soap?service=RB_OLP_INITIATE_PAYMENT';
$local_cert = dirname(__FILE__)."/key1.pem";
$passphrase = "*****";
$options = array(
    'location'      => $endpoint,
    'keep_alive'    => true,
    'trace'         => true,
    'local_cert'    => $local_cert,
    'passphrase'    => $passphrase,
    'cache_wsdl'    => WSDL_CACHE_NONE,
    'exceptions' => 0

);

try{

        $client = new SoapClient($wsdl,$options); 

    } catch (SoapFault $E) { 
        echo $E->getMessage();
    }
    if ($client) {                                '
$in=new StdClass();


$in->olpIdAlias='****';
      $in->merchantId='***';
        $in->merchantRefNum='12344';
          $in->paymentAmount='100';
            $in->paymentCurrency='SAR';
                $in->dynamicMerchantLandingURL='';
                    $in->dynamicMerchantFailureURL='';


                    //$response = $client->__soapCall('executeRB_OLP_INITIATE_PAYMENT',array($req_params));
               $response = $client->executeRB_OLP_INITIATE_PAYMENT($req_params);
                      var_dump($response);


    }

输出

object(SoapFault)#4 (10) { ["message":protected]=> string(46) "Fault occurred in processing, detail provided." ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(38) "C:\xampp\htdocs\RbphpGateway\index.php" ["line":protected]=> int(86) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(38) "C:\xampp\htdocs\RbphpGateway\index.php" ["line"]=> int(86) ["function"]=> string(10) "__soapCall" ["class"]=> string(10) "SoapClient" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(30) "executeRB_OLP_INITIATE_PAYMENT" [1]=> array(1) { [0]=> object(stdClass)#2 (7) { ["olpIdAlias"]=> string(8) "****" ["merchantId"]=> string(4) "***" ["merchantRefNum"]=> string(5) "12344" ["paymentAmount"]=> string(3) "100" ["paymentCurrency"]=> string(3) "SAR" ["dynamicMerchantLandingURL"]=> string(0) "" ["dynamicMerchantFailureURL"]=> string(0) "" } } } } } ["previous":"Exception":private]=> NULL ["faultstring"]=> string(46) "Fault occurred in processing, detail provided." ["faultcode"]=> string(17) "SOAP-ENV:Receiver" ["detail"]=> object(stdClass)#3 (1) { ["faultDetail"]=> string(147) "id= 7712402 stepId=10 serviceName=SOARequestHandler_Instance message=Service Specific Exception (check status report) runTime=2016.09.18 12:00:00.0" } }

0 个答案:

没有答案