Monday, December 26, 2011

SOAP/WSDL based Banking API

Secured banking systems use SOAP/WSDL to communicate third party systems. It's completely platform independent and secured. This communication uses XML data transfers with secured gateway. cURL library (libcURL) allows PHP developers to develop SOAP transactions features between servers/systems. PHP has a built-in library for SOAP communication. But, nuSOAP is a perfect choice to develop SOAP client/server in PHP.

Download nuSOAP Library: Sourceforge

SOAP Client Development:


1. Include nuSOAP library first
It's like including a php script to other. If the nuSOAP library is stored in a directory "lib" with the filename "nusoap.php", then it could be include as follows:



2. Set Parameters
It is needed to set required parameters to call a wsdl server to communicate. Developer should give parameters based on the subjected WSDL server's specific function's requirement.

Suppose, developer has intended to communicate with a wsdl "https://webservicetest.webserviceurl.com:5555/.wsdl" and calls a function "testConnection". "testConnection" function of this wsdl requires parameters "id", "username" and "password".

Save parameters in a variable


3. Certificate Issue
It also requires specific SSL certificate of .pfx or .p12 format. PHP doesn't process .pfx formatted, so it is needed to convert it into set of files like "key.pem" and "cert.pem" with a pass phrase "pass" and save them in the same directory of the scripts (saving to same directory is not mandatory). (See how to covert .pfx or .p12 SSL into .pem certificate).

Better to store certificate and wsdl information into variables.
$wsdl="https://webservicetest.webserviceurl.com:5555/.wsdl";
$sslkey = getcwd()."/key.pem";
$sslcert = getcwd()."/cert.pem";
$passphrase= "pass";


3. Call soap functions
Now, it is time to initialize a soap call.

$client = new nusoap_client($wsdlurl, 'wsdl', $proxyhost, $proxyport, $proxyusername, $proxypassword);

$client->authtype = 'certificate';
$client->decode_utf8 = 0;
$client->soap_defencoding = 'UTF-8';

$client->setCredentials("","","certificate",
array(
"sslcertfile" => $sslcert,
"sslkeyfile" => $sslkey,
"passphrase" => "pass",
"verifypeer" => 0, //OPTIONAL
"verifyhost" => 0 //OPTIONAL
)
);

After initializing, it's time to call specific function of the wsdl. We are going to call "testConnection" function.



4. Recieve and use response
Now the response from the WSDL is stored in $result variable. It's an array, it's possible to use information from that array as developer need.

1 comment:

  1. open banking api
    Therefore, services today, including banks need to make a choice; solving functional needs by utilizing vertical expertise, or transforming to adopt a more platform-based approach which makes them customer owners, able to solve broader lifecycle needs.

    ReplyDelete