0

Hi All,

I'm trying to implement an experian bank account checking facility on the systems at work. I'm trying to do this using php and Soap. This is my first time using Soap so I'm not entirely sure if I'm doing it correct.

Here is my code:

<?php
    $options = array(
        'local_cert'=>'certificate.p12', 
        'passphrase'=>'mypass', 
        'location'=>"https://secure.authenticator.uat.uk.experian.com/WASPAuthenticator/Service.asmx",
        'uri'=>'http://www.uk.experian.com/WASP/',
    );

    $authenticationBlock = "<WASPAuthenticationRequest>";
    $authenticationBlock .= "<ApplicationName>YFR Admin</ApplicationName>";
    $authenticationBlock .= "<AuthenticationLevel>CertificateAuthentication</AuthenticationLevel>";
    $authenticationBlock .= "<AuthenticationParameters/>";
    $authenticationBlock .= "</WASPAuthenticationRequest>";

    try {
        $client = new SoapClient(null, $options);

        $result = $client->STS($authenticationBlock);  // experian function - possibly the problem line

    } catch (soapFault $fault) {
        trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
    } 

    var_dump($result);

?>

The error I'm getting is:

Fatal error: SOAP Fault: (faultcode: HTTP, faultstring: Could not connect to host) in /myfile/ on line 21

I feel I'm using the right details in the right places but figured I must be missing something obvious or just doing the whole thing wrong :)

Thanks for any help offered.

Edited by Tinnin

4
Contributors
10
Replies
42
Views
3 Years
Discussion Span
Last Post by Nicolás
0

Some modifications but still no success.

<?php
    $certificate = array();
    $pkcs12 = file_get_contents('certificate.p12');

    if (openssl_pkcs12_read($pkcs12, $certificate, 'myPass')) {

        $options = array(
            'local_cert'=>$certificate,
            'location'=>"https://secure.authenticator.uat.uk.experian.com/WASPAuthenticator/TokenService.asmx",
            'uri'=>'http://www.uk.experian.com/WASP/',
        );

        $authenticationBlock = "<WASPAuthenticationRequest>";
        $authenticationBlock .= "<ApplicationName>AppName</ApplicationName>";
        $authenticationBlock .= "<AuthenticationLevel>CertificateAuthentication</AuthenticationLevel>";
        $authenticationBlock .= "<AuthenticationParameters/>";
        $authenticationBlock .= "</WASPAuthenticationRequest>";

        try {
            $client = new SoapClient(null, $options);

            $result = $client->STS($authenticationBlock);

        } catch (soapFault $fault) {
            trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
        } 

        var_dump($result);

    } else {
        echo 'Could not parse PKCS12';  
    }

?>
0

If I change it to be indicate a wsdl I get a different error after some time:

$options = array(
            'local_cert'=>$cert,
            'passphrase'=>$certificate['pkey'],
            //'location'=>"https://secure.authenticator.uat.uk.experian.com/WASPAuthenticator/TokenService.asmx",
            //'uri'=>'http://www.uk.experian.com/WASP/',
        );

$client = new SoapClient("https://secure.authenticator.uat.uk.experian.com/WASPAuthenticator/TokenService.asmx", $options);

Fatal error: SOAP Fault: (faultcode: WSDL, faultstring: SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://secure.authenticator.uat.uk.experian.com/WASPAuthenticator/TokenService.asmx' : failed to load external entity "https://secure.authenticator.uat.uk.experian.com/WASPAuthenticator/TokenService.asmx" )

0

Attempt No:#GodKnowsWhat

$pkcs12 = file_get_contents('certificate.p12');

$options = array(
            'local_cert'=>$pkcs12,
            'passphrase'=>'myPass',
            'location'=>"https://secure.authenticator.uat.uk.experian.com/WASPAuthenticator/TokenService.asmx",
            'uri'=>'http://www.uk.experian.com/WASP/',
        );

        $authenticationBlock = "<WASPAuthenticationRequest>";
        $authenticationBlock .= "<ApplicationName>AppName</ApplicationName>";
        $authenticationBlock .= "<AuthenticationLevel>CertificateAuthentication</AuthenticationLevel>";
        $authenticationBlock .= "<AuthenticationParameters/>";
        $authenticationBlock .= "</WASPAuthenticationRequest>";

        try {
            $client = new SoapClient(null, $options);
            $result = $client->__soapCall("STS", array($authenticationBlock));

        } catch (soapFault $fault) {
            trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
        } 

        var_dump($result);

Nada!

Edited by Tinnin

0

Another thing that may be worth mentioning; when I var_dump($client), it does not show the key/value pair for 'local_cert' or 'passphrase'.

Anyone know why that may be?

0

var_dump($pkcs12) , what do you get? Is it the right structure expected by the webservice?

e.g.

Array ( [this_array] =>( [something] => something_value)[another_array]=>[index_b] =>[value_b]))

0

Yeah, that's the basic structure. The certificate was provided by them. When I run it all through SoapUI it works fine and returns the result. I just don't know how to make it work via php.

0

So, I've sort of solved the issue.

Needed the certificate to be in pem format.
Needed to enable SSL module on the server.

Works...on localhost :)

0

Hi Tinnin,

I am facing same issue.
I am having .p12 certificate. And am testing at local system with wamp server.
Please help me, How did you solved this issues on localhost?
Please provide needfull steps.

Thank you.

0

Hi, just in case this could help to someone else: In my case after an exhaustive debug during weeks, have found a property I was using in the soapClient constructor:

'ssl_method' => SOAP_SSL_METHOD_SSLv3

Do not know why i was using this, maybe copy/paste.
The documentations says:

The ssl_method option is one of SOAP_SSL_METHOD_TLS,
SOAP_SSL_METHOD_SSLv2, SOAP_SSL_METHOD_SSLv3 or
SOAP_SSL_METHOD_SSLv23.

Don't have any encryption neither ,so I just removed it from the array of parameters and there you go, up and running;

private function _getSoapClientOptions (){
        $options = array('trace'=>true,'encoding' => 'UTF-8', 'cache_wsdl' => WSDL_CACHE_NONE, 'login'=>$this->_login, 'password'=>$this->_password,
                        'soap_version'=>SOAP_1_2,'compression'=>(SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP),
                        'location'=>$this->_location,'ignore_errors' => true,"exceptions"=>0);
        return $options;        
    }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.