I'm trying to use certain filters out of a remote WSDL web service. I get no errors when trying to do so, but all I get is the full list of data with those parameters being ignored.
Calling $client->__getFunctions()
retrieves a blank page, so I'm not sure what to do.
This is the XML:
<s:element name="Entities">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Format" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="wherefilter" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="ordercondition" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
And this is how I'm trying to do it with PHP:
public static function fetch($name = 'Entities')
{
$base = 'http://tempuri.org/';
$client = new \SoapClient(null, [
'location' => '...',
'uri' => '...',
'trace' => 1,
'exceptions' => true
]);
$params = ['Format' => 'JSON'];
try {
// $params is being ignored
$data = $client->__soapCall($name, $params, ['soapaction' => $base . $name]);
return $data;
}
catch (\SoapFault $ex) {
abort(403, $ex);
}
catch (Exception $ex) {
die($ex);
}
}
Any hints on what I'm doing wrong would be appreciated.
After circling the internet for an answer I had to restructure the code in order to make this work. I'm not entirely sure why the old setup didn't work but this is how it does work now:
public static function fetch()
{
$options = [
'trace' => 1,
'exceptions' => true
];
$client = new \SoapClient('my_soap_url.asmx?WSDL', $options);
try {
$input = new \stdClass();
$input->Format = "JSON";
$data = $client->Entities($input);
return reset($data);
}
catch (Exception $ex) {
echo 'Caught exception: ', $e->getMessage(), PHP_EOL . PHP_EOL;
echo 'REQUEST:' . $client->__getLastRequestHeaders() . $client->__getLastRequest() . PHP_EOL . PHP_EOL;
echo 'RESPONSE:' . $client->__getLastResponseHeaders() . $client->__getLastResponse();
}
}