I am trying to deploy a non-wsdl php soapserver, the code as follows is minimal:
function notify($string) {
return null;
}
$server = new SoapServer(
null, array('uri' => "http://localhost/")
);
$server->addFunction("notify");
$server->handle();
The above seems to work fine, the only problem is that the SOAP client requires a 200 OK and empty notifyResponse XML element. As you can see from the above, I tried a "return null" on the notify function but that still builds a "notifyResponse" element.
Unfortunately I cannot modify the client to accept anything different. I also tried removing the soapServer for tests and generated a http response with just a 200 OK without any XML response and that was acceptable, unfortunately I cannot find a way to do this when soapServer is used.
The most simplified response I was able to generate is shown below, I achieved that by using:
return new SoapVar('', XSD_ANYXML);
But this is still not accepted by the client as a good response, I either need to remove the whole XML layer or at least remove the "notifyResponse".
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://localhost/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body><ns1:notifyResponse></ns1:notifyResponse></SOAP-ENV:Body>
</SOAP-ENV:Envelope>
As you have already found out, the moment you return from the notify() function, the SoapServer will create a SOAP response with the result.
Rule: Given the notify() function, when it is returning, then an XML response is created.
We can invalidate the rules' condition so that the notify() function never returns. This consequentially interrupts SoapServer from handling any return value, and instead is making PHP take over again sending its standard HTTP response.
Given the minimal example in your question, when no other output has been generated (which we can assume), then the HTTP response body send to the client will be empty (and with the default HTTP status code 200 OK together with all other standard HTTP response headers from PHP):
function notify()
: never
{
exit;
}
Example.1: A notify() function that never returns
If it helps to visualize: You can imagine placing an empty file named OK
on your webserver and then requesting it with a curl get request. Or an empty index.php
file even, to make this more of a PHP script.