Hello all,
I am having a problem with the DOMDocument class to validate a local XML file with an XSD file in a remote location.
I know that the remote XSD file requires HTTP authentication so I have adjusted the URL to send the username and password like so.
$xsd_path = "https://username:password@****.****.com:****/cdes/services/cdes2_ws?xsd=CDEX2.xsd";
The problem is that I am still getting HTTP authentication errors. From the error message I have been getting I can see that inside this XSD file is also another include to an XSD file that requires authentication.
I have thought about trying to open a persistent HTTP connection but I'm not even sure if I'm heading in the right direction with this. How would I go about solving this? Below is the error and my current PHP code.
Current PHP Code:
$xml_path = "./test-v1.xml";
$xsd_path = "https://username:password@****.****.com:****/cdes/services/cdes2_ws?xsd=CDEX2.xsd";
$x_validate = new DOMDocument();
$x_validate->load($xml_path);
$x_validate->schemaValidate($xsd_path);
HTTP Auth Error:
Warning: DOMDocument::schemaValidate(https://****.****.com:****/cdes/services/cdes2_ws?xsd=CDEX_ISO_languages.xsd) [domdocument.schemavalidate]: failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required in C:\Xampp\htdocs\****\xml-validation\run-validation.php on line 16
Any help with this would be greatly appreciated!