When trying to implement a web service with SoapClient it appears that the wsdl link isn't being resolved; when attempting to create a new SoapClient object, the request fails with the message:
Request failed. Reason: SOAP-ERROR: Parsing Schema: can't import schema from 'https://dev.example.com/StubService/RequestService.xsd'
The WSDL contains relative links to the .xsd files for the request and response, however when the client attempts to load them they do not exist. When navigating to the WSDL file in the browser, it redirects to the longform version of the .wsdl file. Substituting this into the WSDL file works for getting around this however the rest of the service falls apart. My main obstacle seems to be that SoapClient isn't resolving the link to the WSDL in a way that it may correctly link to the .xsd files.
Frustratingly, the XML being output by the client has been proven to be valid; I've copypasted the generated XML into SoapUI and fired it at the shortform WSDL and it has returned the expected result.
Below is the code for the SoapClient. Any ideas?
<?php
// The shorthand wsdl that should be used
// The long wsdl it should resolve to is https://dev.example.com/StubService/WebService/WEB-INF/wsdl/SearchByPropertyDescriptionV2_0Service.wsdl
$wsdl = 'https://dev.example.com/StubService/WebService?wsdl';
try
{
// Create a new soap client
$client = new SoapClient($wsdl,
array(
'local_cert' => MY_KEY,
'passphrase' => MY_PASSWORD,
'locale' => 'en',
'trace' => true,
'exceptions' => true,
));
//set the Headers of Soap Client.
$username = 'User001';
$password = 'Pass001';
$security = 'MY_SECURITY_HEADER';
$securityheader = new \SoapVar($security,XSD_ANYXML, null, null, null);
$international = 'MY_INTERNATIONAL_HEADER';
$internationalheader = new \SoapVar($international,XSD_ANYXML, null, null, null);
$headers = array(
new SoapHeader('null', 'wsse', $securityheader),
new SoapHeader('null', 'i18n', $internationalheader)
);
$client->__setSoapHeaders($headers);
// Create the XML body
$params = new SoapVar('MY_VALID_XML_BODY', XSD_ANYXML);
$result = $client->searchProperties($params));
var_dump($result);
}
catch (Exception $e)
{
echo "Request failed. Reason: ".$e->getMessage();
echo "<br />";
echo "Last request:\n";
var_dump($client->__getLastRequest());
};