Newsgroup: it.comp.www.php
Titolo: Problema con WSDL e SOAP

Ciao a tutti,
sto cercando di capire il funzionamento di WSDL, per quanto riguarda il
soap ho capito + o meno come funziona...
Il mio problema è questo: ho implementato un semplice client-server in
php che sfurutta soap+php, ma quando richiamo la pagina del client (che
si trova sullo stesso pc del server) ottengo questo simpatico errore:
Fatal error: Uncaught SoapFault exception: [Client] looks like we got
no XML document in /var/www/intesa/test/soap_cl.php:11 Stack trace: #0
/var/www/intesa/test/soap_cl.php(11):
SoapClient->__soapCall('sayHello', Array) #1 {main} thrown in
/var/www/intesa/test/soap_cl.php on line 11
ecco il codice del client:
<?php
// creo il soap server
// $client = new SoapClient(null, array( 'uri' =>
"
http://192.168.100.12/intesa/test/
"));
// creo il soap client utilizzando il wsdl
$client = new SoapClient("soap_xml/visure.wsdl");
$params = array("name" => "gabriele", "surname" => "brosulo");
$response = $client->__soapCall("sayHello", $params);
echo $response;
?>
ecco il server:
<?php
class hello
	{
		function	hello()
		{
		}
		function	sayHello($name,$surname)
		{
			return "Hello " . $name ." " .$surname;
		}
		function	sayGoodbye($name)
		{
			return "Good Bye " . $name;
		}
	}
// creo il soap server
// $server = new SoapServer(null, array( 'uri' =>
"
http://192.168.100.12/intesa/test/
"));
// creo il soap server utilizzando il wsdl
$server = new SoapServer("soap_xml/visure.wsdl");
// esporto tutti i metodi della classe
$server->setClass(hello);
//$server->addFunction(SOAP_FUNCTIONS_ALL);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
	$server->handle();
} else {
	echo "This SOAP server can handle following functions: ";
	$functions = $server->getFunctions();
	foreach($functions as $func) {
		echo $func . " - ";
	}
}
?>
ed infine ecco il file wsdl, che si trova nella directory soap_xml:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
    name="visure"
    targetNamespace="
http://localhost/intesa/test/soap_xml/visure.wsdl
"
    xmlns:soap="
http://schemas.xmlsoap.org/wsdl/soap/
"
    xmlns:tns="
http://localhost/intesa/test/soap_xml/visure.wsdl
"
    xmlns:wsdl="
http://schemas.xmlsoap.org/wsdl/
"
    xmlns:xsd="
http://www.w3.org/2001/XMLSchema
">
    <wsdl:documentation
xmlns:wsdl="
http://schemas.xmlsoap.org/wsdl/
">Created using Cape Clear
Studio SOA Editor - 
http://www.capeclear.com
</wsdl:documentation>
    <wsdl:message name="sayHelloResponse">
        <wsdl:documentation
xmlns:wsdl="
http://schemas.xmlsoap.org/wsdl/
">bbb</wsdl:documentation>
        <wsdl:part name="returnValue" type="xsd:string"/>
    </wsdl:message>
    <wsdl:message name="sayHelloRequest">
        <wsdl:documentation
xmlns:wsdl="
http://schemas.xmlsoap.org/wsdl/
">aaa</wsdl:documentation>
        <wsdl:part name="name" type="xsd:string"/>
        <wsdl:part name="surname" type="xsd:string"/>
    </wsdl:message>
    <wsdl:message name="sayGoodbyeResponse">
        <wsdl:part name="returnValue" type="xsd:string"/>
    </wsdl:message>
    <wsdl:message name="sayGoodbyeRequest">
        <wsdl:part name="name" type="xsd:string"/>
    </wsdl:message>
    <wsdl:portType name="visurePortType">
        <wsdl:operation name="sayHello">
            <wsdl:documentation
xmlns:wsdl="
http://schemas.xmlsoap.org/wsdl/
">funzione sayHello vera e
propria</wsdl:documentation>
            <wsdl:input message="tns:sayHelloRequest"/>
            <wsdl:output message="tns:sayHelloResponse"/>
        </wsdl:operation>
        <wsdl:operation name="sayGoodbye">
            <wsdl:documentation
xmlns:wsdl="
http://schemas.xmlsoap.org/wsdl/
">funzione sayGoodbye vera
e propria</wsdl:documentation>
            <wsdl:input message="tns:sayGoodbyeRequest"/>
            <wsdl:output message="tns:sayGoodbyeResponse"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="visureBinding" type="tns:visurePortType">
        <soap:binding style="rpc"
transport="
http://schemas.xmlsoap.org/soap/http
"/>
        <wsdl:operation name="sayHello">
            <soap:operation
soapAction="capeconnect:visure:visurePortType#sayHello"/>
            <wsdl:input>
                <soap:body parts="name surname" use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body parts="" use="literal"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="sayGoodbye">
            <soap:operation
soapAction="capeconnect:visure:visurePortType#sayGoodbye"/>
            <wsdl:input>
                <soap:body parts="name" use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="visure">
        <wsdl:port binding="tns:visureBinding" name="visurePort">
            <soap:address
location="
http://localhost:80/intesa/test/soap_srv.php
"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>
Aggiungo infine che se creo client e server senza usare il wsdl (con le
funzioni commentate, per intenderci), tutto funziona e il client riceve
la sua bella risposta...
grazie a tutti per la pazienza,
g4b0

scusate, ma sto facendo delle prove, e sono giunto qua:
senza wsdl tutto funziona, mentre invece con wsdl funziona solo in
parte...
client code:
<?php
// creo il soap client utilizzando il wsdl
$client = new
SoapClient("
http://localhost/intesa/test/soap_xml/visure.wsdl
");
echo "Hello:<br>";
$params = array("name" => "gabriele", "surname" => "brosulo");
$response = $client->__soapCall("sayHello", $params);
echo $response;
echo "<br><br>Bye:<br>";
$params = array("name" => "gabriele", "surname" => "brosulo");
$response = $client->__soapCall("sayGoodbye", $params);
echo $response;
?>
server code:
<?php
class hello
	{
		function	sayHello($name)
		{
			return "Hello " . $name;
		}
		function	sayGoodbye($name,$surname)
		{
			return "Good Bye " . $name." " .$surname;
		}
	}
// creo il soap server
// $server = new SoapServer(null, array( 'location' =>
"
http://localhost/intesa/test/soap_srv.php
",
// 													'uri' => "
http://localhost/intesa/test/
"));
// creo il soap server utilizzando il wsdl
$server = new
SoapServer("
http://localhost/intesa/test/soap_xml/visure.wsdl
");
// esporto tutti i metodi della classe
$server->setClass(hello);
//$server->addFunction(SOAP_FUNCTIONS_ALL);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
	$server->handle();
} else {
	echo "This SOAP server can handle following functions: ";
	$functions = $server->getFunctions();
	foreach($functions as $func) {
		echo $func . " - ";
	}
}
?>
new wsdl:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
    name="visure"
    targetNamespace="
http://www.your-company.com/visure.wsdl
"
    xmlns:soap="
http://schemas.xmlsoap.org/wsdl/soap/
"
    xmlns:tns="
http://www.your-company.com/visure.wsdl
"
    xmlns:wsdl="
http://schemas.xmlsoap.org/wsdl/
"
    xmlns:xsd="
http://www.w3.org/2001/XMLSchema
"
    xmlns:xsd1="
http://www.your-company.com/visure.xsd1
">
    <wsdl:documentation
xmlns:wsdl="
http://schemas.xmlsoap.org/wsdl/
">Created using Cape Clear
Studio SOA Editor - 
http://www.capeclear.com
</wsdl:documentation>
    <wsdl:types>
        <xsd:schema
            targetNamespace="
http://192.168.100.12/visure.xsd1
"
            xmlns:SOAP-ENC="
http://schemas.xmlsoap.org/soap/encoding/
"
            xmlns:xsd="
http://www.w3.org/2001/XMLSchema
"
            xmlns:xsd1="
http://192.168.100.12/visure.xsd1
">
</xsd:schema>
    </wsdl:types>
    <wsdl:message name="sayHelloRequest">
        <wsdl:part name="name" type="xsd:string"/>
    </wsdl:message>
    <wsdl:message name="sayHelloResponse">
        <wsdl:part name="returnValue" type="xsd:string"/>
    </wsdl:message>
    <wsdl:message name="sayGoodbyeResponse">
        <wsdl:part name="returnValue" type="xsd:string"/>
    </wsdl:message>
    <wsdl:message name="sayGoodbyeRequest">
        <wsdl:part name="name" type="xsd:string"/>
        <wsdl:part name="surname" type="xsd:string"/>
    </wsdl:message>
    <wsdl:portType name="visurePortType">
        <wsdl:operation name="sayHello">
            <wsdl:input message="tns:sayHelloRequest"/>
            <wsdl:output message="tns:sayHelloResponse"/>
        </wsdl:operation>
        <wsdl:operation name="sayGoodbye">
            <wsdl:input message="tns:sayGoodbyeRequest"/>
            <wsdl:output message="tns:sayGoodbyeResponse"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="visureBinding" type="tns:visurePortType">
        <soap:binding style="rpc"
transport="
http://schemas.xmlsoap.org/soap/http
"/>
        <wsdl:operation name="sayHello">
            <soap:operation/>
            <wsdl:input>
                <soap:body parts="name" use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body parts="returnValue" use="literal"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="sayGoodbye">
            <soap:operation/>
            <wsdl:input>
                <soap:body parts="surname name" use="literal"/>
                <soap:body parts="surname" use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body parts="returnValue" use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="visure">
        <wsdl:port binding="tns:visureBinding" name="visurePort">
            <soap:address
location="
http://localhost/intesa/test/soap_srv.php
"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>
output, richiamando la pagina del client:
----------start-------------
Hello:
Bye:
Good Bye gabriele
----------stop-------------
scusate la mole dei post, ma ho un po' di urgenza...
g4b0