Hello everybody,

I literally have been pulling out my hair over this. I'm trying to validate WSDL files against http://schemas.xmlsoap.org/wsdl/2003-02-11.xsd using PHP. So I have been toying around with different WSDL files to get schemaValidate to work. My PHP code is:

<?php
	extract($_POST);
?>
<html>
	<body>
		<form action="http://ce-gmbh.com/dswsr/validateWSDL.php" method="post">
			<input type="text" name="WSDLPath" id="WSDLPath" size="40" maxlength="256">
			<input type="submit" value="Validate">                                                                            
</form> <?php if (strcmp($WSDLPath,"")!=0) { function libxml_display_error($error) { $return = "<br/>\n"; switch ($error->level) { case LIBXML_ERR_WARNING: $return .= "<b>Warning $error->code</b>: "; break; case LIBXML_ERR_ERROR: $return .= "<b>Error $error->code</b>: "; break; case LIBXML_ERR_FATAL: $return .= "<b>Fatal Error $error->code</b>: "; break; } $return .= trim($error->message); if ($error->file) { $return .= " in <b>$error->file</b>"; } $return .= " on line <b>$error->line</b>\n"; return $return; } function libxml_display_errors() { $errors = libxml_get_errors(); foreach ($errors as $error) { print libxml_display_error($error); } libxml_clear_errors(); } // Enable user error handling libxml_use_internal_errors(true); $xml = new DOMDocument(); $xml->load($WSDLPath); if (!$xml->schemaValidate('wsdl-2004-08-24.xsd')) { print '<b>DOMDocument::schemaValidate() Generated Errors!</b>'; libxml_display_errors(); } else { echo "validated"; } } ?> </body> </html>

You can try this at http://ce-gmbh.com/dswsr/validateWSDL.php.

If I enter for example https://www.providerbox.de/providerbox.wsdl the validation returns tons of these two kinds of failure messages:

Error 1: Unimplemented block at xmlschemas.c:5588 on line 0
Error 1871: Element 'part', [lax WC]: The namespace of the element is not allowed. in https://www.providerbox.de/providerbox.wsdl on line 7

If I validate the same file using http://tools.decisionsoft.com/schemaValidate/ or XMLSpy it validates fine for "well formed" and "schema".

Even if I try to follow the example from http://www.xml-training-guide.com/validate-xml-against-schema-using-php.html I get similar faults and no validation as described.

What do above fault messages mean? I searched high and low and can't find an answer to that. And more importantly - how do I get rid of them? How can I validate WSDL files using PHP? Are their some libraries that do the job besides schemaValidate().

Thanks in advance for any feedback.

    8 days later

    After days (literally) of searching for an answer I finally figured out what the problem is. It seems to be the version of PHP5 respectively the version of the associated libxml2. I found some post that states that the problem I'm experiencing is typical for libxml2 V2.6.16. Now I'm not sure which version is installed on my ISPs server but I installed PHP 5.3.5 on my local machine and sure enough the code I posted works. Hopefully this will save somebody else some time in the future.

      The version of PHP on my ISPs server is 5.2.14 which comes with libXML V2.6.16. Lucky me 😉

        Write a Reply...