Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 135
  • Last Modified:

I am trying to create a PHP soap client. Following is my soap request XML Schema

I am trying to create a PHP soap client. Following is my soap request 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>

Open in new window



following is my var_dump($client->__getFunctions()) output

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

Open in new window


can anyone help me to write PHP client for above soap request ? I am trying since 2 weeks.and I am failed. getting error

PHP code

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


    }

Open in new window

OUTPUT
Fault occurred in processing, detail provided
0
Dhanish pk
Asked:
Dhanish pk
  • 6
  • 2
  • 2
1 Solution
 
Julian HansenCommented:
Is this a PHP error or an error you get back from the remote service?
0
 
Dhanish pkAuthor Commented:
i think this is PHP error . not from remote service
0
 
Julian HansenCommented:
It does not look like a PHP error - the latter usually is accompanies by a line number and file name.
Is that the exact error as it appears on the screen?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Dhanish pkAuthor Commented:
full error

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
 
Dhanish pkAuthor Commented:
i tryed to connect SOAP  with curl . i gett blank result.here is the  code
0
 
Slick812Commented:
greetings Dhanish pk, , the SOAP connection for remote function-method operations, is not simple to get to work, , for several reasons. The SOAP depends entirely on method definition and structure definitions in the XML text that can be used in code (line by line, step wise programming) "Processing" on a remote computer, in a NON HTTP data exchanges (more than a single request and response). .  You seem to have written the WSDL XML as -
<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>

Open in new window


This does not look entirely "formatted" correctly in WSDL XML definitions, and structures? ? It has no definition for a specific "Method" and the result-return TYPE structure or the method parameters TYPES and TYPE stuctures.

In the WSDL programming processing exchanges I have attempted, for a "Client" to a remote server, PHP Got the XML document from the remote server address that will do the object creation that processes the methods defined in the WSDL XML text, that initiates the new SoapClient ( ) -
        $client = new SoapClient("https://b2b.bank.com/soap/wsdl/b2bpro.wsdl");

it looks like your error message is from this lines -
    } catch (SoapFault $E) {
        echo $E->getMessage(); // ERROR OUTPUT
    }

I do not beleive you can write the WSDL XML text yourself and get this to work as a SOAP exchange? ?

The PHP function   SoapClient( ) and get a successful connection, , but for successful use of the remote server programming SOAP API , you usually need to use their provided "CODE" samples in the SOAP object explanations and demo codes.
1
 
Dhanish pkAuthor Commented:
Dear Slick812 ,Thank you for your support
the service provider will not give us any sample or demo code to achieve this task .they only give us .wsdl and Keystore file . I did this integration in java successfully . I am struggling on only in PHP.

the XML I showed in question, not a WSDL file .its a soap requestion schema which I copied from soapUI tool

Thank you.
0
 
Slick812Commented:
I have looked briefly for PHP code using SOAP and the XML text for a "requestion schema", and did not find anything that I thought could be used here. I think in JAVA, you can use the "requestion schema" as the parameter's VALUES (and other things)  when calling a remote method. I have never seen or heard of the XML "requestion schema" used in PHP SOAP code? But it may be usable somehow? But I do not know that usage.  But In PHP using the SoapClient( ) , there is no reason or advantage I know of in using XML text instead of the array TYPE in PHP to store the VALUES of a method's parameters. In your code, you have the "requestion schema" VALUES as -
    ****
    ****
    234324
    200
    SAR

and then in your  $in Object VALUES, you Duplicate all of those
    '****'
    '***'
    '12344'
    '100'
    'SAR'

which indicates to me you are on the wrong path to success in coding.

In the PHP SOAP I have used, I neede to have a working remote server WSDL XML file address in the SoapClient( ) like -
    $client = new SoapClient("https://b2b.bank.com/soap/wsdl/b2bpro.wsdl");

and NOT a "requestion schema" XML file. The SoapClient( ) requires the full WSDL definitions to know what to do and how to do it on the client side exchange.

If you have done this in JAVA platform, and the -
     executeRB_OLP_INITIATE_PAYMENT( )
is a correct method name, then define the method parameters complex type as a PHP array with the VALUES -

$par = array('olpIdAlias'=>'****',
  'merchantId'=>'***';
  'merchantRefNum'=>12344, // probably NOT a string
  'paymentAmount'=>100,
  'paymentCurrency'=>'SAR',
  'dynamicMerchantLandingURL'=>'',
  'dynamicMerchantFailureURL'=>''    );

And you can try the method as -
    $response = $client->executeRB_OLP_INITIATE_PAYMENT($par);

I did NOT show the $options parameter in the SoapClient( ) , because I have no way to know what your source server SOAP connection needs for its requirements, but you may know this from the JAVA? ?
I think maybe the -
    'location'      => $endpoint,
may not be needed if the service WSDL file is in the address
1
 
Dhanish pkAuthor Commented:
Dear Slick812

Your last solution not worked .finaly i found solution my self .i posting here.it might help other developers
<?php
$tb='200';

$xml = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://olp.bank.com/sappay/service/olppaymentmanager/req">
   <soapenv:Header/>
   <soapenv:Body>
      <req:initiatePaymentDetailsReq>
         <olpIdAlias>*****</olpIdAlias>
         <merchantId>********</merchantId>
         <merchantRefNum>'.rand(1, 15).rand().'</merchantRefNum>
         <paymentAmount>'.$tb.'</paymentAmount>
         <paymentCurrency>SAR</paymentCurrency>
         <dynamicMerchantLandingURL></dynamicMerchantLandingURL>
         <dynamicMerchantFailureURL></dynamicMerchantFailureURL>
      </req:initiatePaymentDetailsReq>
   </soapenv:Body>
</soapenv:Envelope>';
try{
$url = "https://b2b.rb.com/soap?service=RB_OLP_INITIATE_PAYMENT";
 $certFile =  dirname(__FILE__)."/key1.pem";
  $certPass = "*****";
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

curl_setopt($ch, CURLOPT_SSLCERT, $certFile);
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $certPass);
$headers = array();
array_push($headers, "Content-Type: text/xml; charset=utf-8");
array_push($headers, "SOAPAction: sii:RB_OLP_INITIATE_PAYMENT");
array_push($headers, "Host:b22.rb.com");

if($xml != null) {
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
    array_push($headers, "Content-Length: " . strlen($xml));
}

curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
     print_r($response);
}  catch (Exception $e){
echo $e->getMessage();
   }


?>

Open in new window


I really appreciate your support . Thank you so much
0
 
Dhanish pkAuthor Commented:
i solved the problem and got output
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now