Hi,
I'm newly here boring you with my PHP5 problem ;-).....
I've a problem with a remote invocation (via PEAR::SOAP) of the method schemaValidateSource of DOMDocument Object.
I Have the following SW configuration:
Windows XP Home SP2
Apache 2
PHP 5.1.1
libxml/libxml2 2.6.11
libxslt 1.1.7
libexslt 0.8.5
DOM/XML API 20031129
And
C:\PHP>pear list
INSTALLED PACKAGES, CHANNEL PEAR.PHP.NET:
=========================================
PACKAGE VERSION STATE
Archive_Tar 1.3.1 stable
Console_Getopt 1.2 stable
DB 1.7.6 stable
HTTP_Request 1.3.0 stable
Mail 1.1.9 stable
Mail_Mime 1.3.1 stable
Net_DIME 0.3 beta
Net_SMTP 1.2.8 stable
Net_Socket 1.0.6 stable
Net_URL 1.0.14 stable
PEAR 1.4.6 stable
PHPUnit 1.3.2 stable
SOAP 0.9.3 beta
UDDI 0.2.0alpha4 alpha
XML_Parser 1.2.7 stable
XML_RPC 1.4.5 stable
I have the SOAP server:
__________________________________________________________________________
<?php
require_once('SOAP/Server.php');
require_once('SOAP/Disco.php');
class pearsoaptest
{
public $__dispatch_map = array();
public function __construct()
{
$this->__dispatch_map['validate_pmif_from_xml_schema'] = array('in' => array('model' => 'String'), 'out' =>
array('validated' => 'Boolean'), );
}
public function validate_pmif_from_xml_schema($model)
{
$_lres = FALSE;
$schema = file_get_contents("http://www.perfeng.com/pmif/pmifschema.xsd");
// The following line will load a local backup copy of pmifschema.xsd if the previous instruction return FALSE
// it was tested by me and works fine
$schema = $schema ? $schema : file_get_contents("http://www.scienze.univaq.it/Zallocco.Samuel/pmifschema.xsd");
if ($schema)
{
$dom_model = DOMDocument::loadXML($model);
if ($dom_model)
{
// the instruction that fail is the following one:
$_lres = $dom_model->schemaValidateSource($schema);
// if you disable the previous instruction the code will work fine
//$_lres = TRUE; // For example
// So I deduced that the call to schemaValidateSource will rise some kind
// of fatal error that return an invalid HTTP response to SOAP client
} else {
// something
}
} else {
// something
}
return $_lres;
}
}
// Thanks to Harlan Iverson <hjiverson@plauditdesign.com> of php.soap newsgroup
// on news://news.php.net for this "sessions" slice of code!
// Whitout the session use the client have no way to access class variable from method invocation!!
session_start();
$server =& $_SESSION['server'];
if( !isset( $server ) )
{
$server = new SOAP_Server();
$webservice = new pearsoaptest();
$server->addObjectMap( $webservice, 'http://schemas.xmlsoap.org/soap/envelope/' );
}
// Thanks a lot Harlan! You save me!
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD']=='POST') {
$server->service($HTTP_RAW_POST_DATA);
} else {
$disco = new SOAP_DISCO_Server($server,'pearsoaptest');
header("Content-type: text/xml");
if (isset($_SERVER['QUERY_STRING']) && (strcasecmp($_SERVER['QUERY_STRING'],'wsdl') == 0) ) {
echo $disco->getWSDL();
} else {
header("Content-type: text/xml");
echo $disco->getDISCO();
}
}
exit;
?>
__________________________________________________________________________
And the client:
__________________________________________________________________________
#!/usr/local/bin/php
<?php
/*
NOTICE: In my php.ini file I have set to report all error to a a file
*/
require_once 'SOAP/Client.php';
class pearsoaptest
{
public $__dispatch_map = array();
public function __construct()
{
$this->__dispatch_map['validate_pmif_from_xml_schema'] = array('in' => array('model' => 'String'), 'out' =>
array('validated' => 'Boolean'), );
}
public function validate_pmif_from_xml_schema($model)
{
$_lres = FALSE;
$schema = file_get_contents("http://www.perfeng.com/pmif/pmifschema.xsd");
// The following line will load a local backup copy of pmifschema.xsd if the previous instruction return FALSE
// it was tested by me and works fine
$schema = $schema ? $schema : file_get_contents("http://www.scienze.univaq.it/Zallocco.Samuel/pmifschema.xsd");
if ($schema)
{
$dom_model = DOMDocument::loadXML($model);
if ($dom_model)
{
// the instruction that fail is the following one:
$_lres = $dom_model->schemaValidateSource($schema);
// if you disable the previous instruction the code will work fine
//$_lres = TRUE; // For example
// So I deduced that the call to schemaValidateSource will rise some kind
// of fatal error that return an invalid HTTP response to SOAP client
} else {
// something
}
} else {
// something
}
return $_lres;
}
}
try {
// A local invocation of pearsoaptest CLASS will produce the correct output
$obj = new pearsoaptest();
$ret =
$obj->validate_pmif_from_xml_schema(file_get_contents("http://www.scienze.univaq.it/Zallocco.Samuel/pmifexample.xml"));
echo "\nValidated: " , ($ret?"TRUE":"FALSE") , " -> " , $ret;
// Remote SOAP Invocation of pearsoaptest CLASS will produce an incorrect HTTP response
$_web_service_url = 'http://localhost/pearsoaptestserver.php?wsdl';
$wsdl = new SOAP_WSDL($_web_service_url);
$pearsoaptest = $wsdl->getProxy();
$ret =
$pearsoaptest->validate_pmif_from_xml_schema(file_get_contents("http://www.scienze.univaq.it/Zallocco.Samuel/pmifexample.xml"));
if (PEAR::isError($ret))
{
echo "\n\nError: " , $ret->getMessage() , "\n";
} else {
echo "\n\nValidated: " , ($ret?"TRUE":"FALSE") , " -> " , $ret;
};
} catch (Exception $e) {
echo '\n\nCaught exception: ', $e->getMessage(), "\n";
}
echo "\n\n";
?>
__________________________________________________________________________
As you can see running the code, the local invocation of the method validate_pmif_from_xml_schema produce the correct
response but when called via the PEAR:SOAP protocol it will fail with an invalid HTTP Response.
I have no idea about the source of the problem!!
Can you help me in some way??
Thank you.
PS1: You can download the full code, pmif example and schema from:
http://www.scienze.univaq.it/Zallocco.Samuel/pear-soap-test.zip
PS2: PMIF aka Permormance Model Interchange Format
--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php