Forum Moderators: coopster
Without them, absolutely everything else can be right but you receive an error about mismatched elements.
Since I know practically nothing about SOAP or wsdl's or any of it, what I finally did is modify the serializeEnvelope function in nusoap.php:
// serialize envelope
$body = preg_replace('/<([^\/])/','<q0:$1',$body);
$body = preg_replace('/<\//','</q0:',$body);
It certainly seems to me that the wsdl file should specify explicit namespaces, but I messed with it all day and did searches for everything I could think of to no avail. I also couldn't find an 'official' way of telling nusoap to do it.
Is this a nusoap shortcoming? What is the right way to do this?
A couple of hints for anyone else who tries this - some things need to be changed in the FedEx example script to make it work with nusoap. For one thing, it wasn't immediately apparent to me that you're supposed to download their wsdl file and put it on your server. Once you've done that, the soapclient constructor looks like this:
$client = new soapclient($path_to_wsdl_file,true);
They pass the parameters to the soap call with:
("getRate",array('params' => $request)
but that absolutely will not work - you get an envelope and no body. Instead, the array index has to be the name of the service:
$response = $client->call("getRate",array('RateRequest' => $request),$fedex_rate_path);
$fedex_rate_path is the target namespace in the wsdl file - I'd list it explicitly here but then they'd change it tomorrow. If you leave it blank, nusoap uses its default which doesn't work, and if you set it to '' it still doesn't work - it has to be the target namespace.
So if someone could enlighten me I'd sure appreciate knowing how to really do this - I don't like the modified nusoap.php file. I suppose I could extend the class but I'm sure there's a better more 'conformant' way to do it.
The hacked nusoap.php file won't cause any problems since it's not used anywhere else in the project, but I don't like using a hack when it seems likely that there's a better way to do it.