PHP soapserver with URL parameters

507 Views Asked by At

I have URL-parameters on my soapserver call. Calling 'mysoapserver.php?version=1' works well, except in this case

mysoapserver.php?wsdl&version=1

Soapserver does not output the wsdl.

The code looks like this

$version = isset($_GET['version']) ? $_GET['version'] : 1;
switch($version) {
    case 1: 
    $wsdl = 'myservices.v1.wsdl';
    break;
case 2:
    $wsdl = 'myservices.v2.wsdl';
    break;
default:
    throw new SoapFault('Server',utf8_encode('error'));
    break;
}
$mysoapserver = new SoapServer($wsdl);
$mysoapserver->setClass('SOAPServices');
$mysoapserver->handle();

Any ideas how to get this working?

1

There are 1 best solutions below

0
On

I had the same problem, GET was empty. The problem was that I was reading it inside my service. The problem is that we can't print inside a server cause it is an xml file, it we try it, it would return us error, then an good trick is this.

$write = fopen("result.txt","w") or die("it doesnt exist");
//result.txt is in the root of the server
fwrite($write,  $_GET['version']);
fclose($write);

Saving the result in other file.