7

I'm trying to integrate our software with SecureNet gateway. They have a SOAP based API.

The problem I'm having is their WSDL file really doesn't work with PHP. Specifically their WSDL file is split across multiple files with a wsdl:import statement, and the import location is http. On their test server http and https ports are open, so PHP can read the WSDL file. On their production server only https is open, but their location block still references http, so PHP times out! If it was https it would work fine.

Their recommendation was to pull the WSDL file from their test server, but override the location. They tell me their test server should always be up, but I don't feel comfortable relying to two systems for our transactions to work.

The other alternative is to use their XML post API... But the issue with that is you have to specify every field (needed or not) in the correct order. The worst part is the error message for this API is simply Unknown Error., so it's nearly impossible to figure out what I'm missing.

I need a third option. Soap works well, if I can load the WSDL file (can on test, not production). I think they're using WCF, which is a .NET thing I believe. There's supposed to be a "?simpleWSDL" verses "?wsdl" option, but on their version of WCF doesn't have it.

Here is their WSDL file (test server): https://certify.securenet.com/API/Gateway.svc?wsdl

EDIT:

Here is the reproducible code:

$client = new SoapClient("https://gateway.securenet.com/API/Gateway.svc?wsdl");
// Hangs and throws exception in construct
Luke
  • 13,678
  • 7
  • 45
  • 79

2 Answers2

0

You can pull the WSDL from the production server and override the location programmatically using SoapClient::__setLocation

Zak
  • 311
  • 2
  • 5
  • 12
  • This sets the end-point. The problem is the WSDL file imports several other files, and import URL's begin with http://. They suggested pulling the WSDL from their development environment and using setLocation, but I don't want to rely on their dev environment being up. – Luke Mar 14 '13 at 16:08
0

It sounds more like a bug in the remote WSDL file, similar to how visiting websites over SSL that have non-SSL assets included causes a warning.

Luckily it looks like we can work around it. The SoapClient Manual Page has a similar workaround for port numbers, posted by the user jjlopez.

The workaround is to extend the base SoapClient class to rewrite the URLs that it will make requests to, like so:

class SecureSoapClient extends \SoapClient
{
    protected $_scheme;

    public function __construct($wsdl, $options)
    {
        $this->_scheme =  parse_url($wsdl, PHP_URL_SCHEME);
        return parent::__construct($wsdl, $options);
    }

    public function __doRequest($request, $location, $action, $version, $one_way = 0) {
        $currentScheme = parse_url($location, PHP_URL_SCHEME);
        $location = preg_replace('^' . $currentScheme, $this->_scheme, $location);
        return parent::__doRequest($request, $location, $action, $version, $one_way);
    }
}
jedifans
  • 2,287
  • 1
  • 13
  • 9