Re: SoapServer::handlle

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Selon Richard Lynch <ceo@xxxxxxxxx>:

> Charles FENDT wrote:
> > <?php
> >    $server = new SoapServer(null, array('uri' => "http://test-uri/";));
> >    $server->handle("");
> >    echo "\nAlive!!!!\n";
> > ?>
> >
> > here is the result
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <SOAP-ENV:Envelope
> > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";>
> >    <SOAP-ENV:Body>
> >      <SOAP-ENV:Fault>
> >        <faultcode>SOAP-ENV:Server</faultcode>
> >        <faultstring>Bad Request</faultstring>
> >      </SOAP-ENV:Fault>
> >    </SOAP-ENV:Body>
> > </SOAP-ENV:Envelope>
> >
> > this didn't output "Alive!!!!" on stdout...
> > the script ends with the SoapServer::handle() call.
>
> What I know about SOAP could be carved on a bar of soap with room left
> over for all the angels in heaven...
>
> But it looks to me like you didn't set up your SOAP server to respond to a
> request for "", so your SOAP server generated a "Bad Request" error, and
> then it killed your PHP script.
>
> WILD GUESS:
> Change your 'null' when you create the thing to '' and maybe SOAP will
> respond to '' with the uri you provided.
>
> There may also be some kind of wild-card system you can use in place of
> null, or a SOAP function to tell it what to *DO* when an invalid request
> is made, rather than the default "Bad Request" and die() behaviour it
> seems to be doing...
>
> A quick check of the manual indicates that there is some way to do this:
> http://us3.php.net/manual/en/function.is-soap-fault.php
> I dunno how you create a SoapClient with exceptions set to FALSE, but
> that's what you're gonna have to do.
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
>


Hello,

In fact, I use a WSDL mode...
here is an other exemple:

<?php
class web_service {
  function sayHello($input) {
    return "Hello, ".$input."...";
  }
}

$soap_query =
   "<soapenv:Envelope
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>"
 . "  <soapenv:Body>"
 . "    <m:sayHello xmlns:m='http://localhost/test.php'>"
 . "      <m:login>toto</m:login>"
 . "    </m:sayHello>"
 . "  </soapenv:Body>"
 . "</soapenv:Envelope>";

$server = new SoapServer("./test.wsdl");
$server->setclass("web_service");
$server->handle($soap_query);
echo "\r\nAlive!!!!\r\n";
$server->handle("");
echo "\r\nAlive!!!!\r\n";
?>

<?xml version="1.0"?>
<wsdl:definitions
       xmlns:tns="urn:TEST"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema";
    xmlns:typens="urn:TEST"
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
   xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
           xmlns="http://schemas.xmlsoap.org/wsdl/";
 targetNamespace="urn:TEST"
            name="TEST">
	<message name="sayHelloInputMessage">
		<part name="login"       type="xsd:string"/>
	</message>
	<message name="sayHelloOutputMessage">
		<part name="hello"       type="xsd:string"/>
	</message>
	<portType name="TESTPorts">
		<operation name="sayHello">
			<input  message="typens:sayHelloInputMessage"/>
			<output message="typens:sayHelloOutputMessage"/>
		</operation>
	</portType>
	<binding name="TESTBinding" type="typens:TESTPorts">
		<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
		<operation name="sayHello">
			<soap:operation soapAction="http://localhost/test.php"/>
			<input ><soap:body use="literal"/></input >
			<output><soap:body use="literal"/></output>
		</operation>
	</binding>
	<service name="TESTWebService">
		<documentation>TEST WebService</documentation>
		<port name="TESTPorts" binding="typens:TESTBinding">
			<soap:address location="http://localhost/test.php"/>
		</port>
	</service>
</wsdl:definitions>

here is the result:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";>
  <SOAP-ENV:Body>
    <SOAP-ENV:sayHelloResponse>
      <hello>Hello, toto...</hello>
    </SOAP-ENV:sayHelloResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Alive!!!!
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";>
  <SOAP-ENV:Body>
    <SOAP-ENV:Fault>
      <faultcode>SOAP-ENV:Server</faultcode>
      <faultstring>Bad Request</faultstring>
    </SOAP-ENV:Fault>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


I 've to do a command line daemon which provide a soap interface...
I just catch the client request, I call handle(), I send the result, and I
contune with the next query...
But if there is a fault, my daemon is killed...
I don't understand why the handle methode kill the process when the answer is
"soapFault"...

I didn't find any reference to a "SoapServer" fault handler...
It was just for client... Your exemple (with client :-( ) could be translated
like this :
$server->handle(...);
if ($server->isSoapFault()) ...
But the test won't be done... the script is already killed!!!
:-(

regards,

FENDT Charles

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux