- Removed the E_STRICT deprecation notice from "var". (Ilia)
- Fixed debug_zval_dump() to support private and protected members. (Dmitry)
- Fixed bug #36809 (__FILE__ behavior changed). (Dmitry)
-- FIxed bug #36808 (syslog ident becomes garbage between requests). (Tony)
+- Fixed bug #36808 (syslog ident becomes garbage between requests). (Tony)
+- Fixed bug #36721 (The SoapServer is not able to send a header that it didn't
+ receive). (Dmitry)
- Fixed bug #36756 (DOMDocument::removeChild corrupts node). (Rob)
- Fixed bug #36749 (SOAP: 'Error Fetching http body' when using HTTP Proxy).
(Dmitry)
} map_class;
};
+struct _soapHeader;
+
struct _soapService {
sdlPtr sdl;
xmlCharEncodingHandlerPtr encoding;
HashTable *class_map;
int features;
+ struct _soapHeader **soap_headers_ptr;
};
#define SOAP_CLASS 1
PHP_METHOD(SoapServer, handle);
PHP_METHOD(SoapServer, setPersistence);
PHP_METHOD(SoapServer, fault);
+PHP_METHOD(SoapServer, addSoapHeader);
#ifdef HAVE_PHP_DOMXML
PHP_METHOD(PHP_SOAP_SERVER_CLASS, map);
#endif
PHP_ME(SoapServer, getFunctions, NULL, 0)
PHP_ME(SoapServer, handle, NULL, 0)
PHP_ME(SoapServer, fault, NULL, 0)
+ PHP_ME(SoapServer, addSoapHeader, NULL, 0)
#ifdef HAVE_PHP_DOMXML
PHP_ME(SoapServer, map, NULL, 0)
#endif
old_soap_version = SOAP_GLOBAL(soap_version);
function = deserialize_function_call(service->sdl, doc_request, service->actor, &function_name, &num_params, ¶ms, &soap_version, &soap_headers TSRMLS_CC);
xmlFreeDoc(doc_request);
+
+ service->soap_headers_ptr = &soap_headers;
soap_obj = NULL;
if (service->type == SOAP_CLASS) {
int i;
soap_headers = soap_headers->next;
- i = h->num_params;
- while (i > 0) {
- zval_ptr_dtor(&h->parameters[--i]);
+ if (h->parameters) {
+ i = h->num_params;
+ while (i > 0) {
+ zval_ptr_dtor(&h->parameters[--i]);
+ }
+ efree(h->parameters);
}
- efree(h->parameters);
zval_dtor(&h->function_name);
zval_dtor(&h->retval);
efree(h);
}
+ service->soap_headers_ptr = NULL;
/* Free Memory */
if (num_params > 0) {
}
/* }}} */
+PHP_METHOD(SoapServer, addSoapHeader)
+{
+ soapServicePtr service;
+ zval *fault;
+ soapHeader **p;
+
+ SOAP_SERVER_BEGIN_CODE();
+
+ FETCH_THIS_SERVICE(service);
+
+ if (!service || !service->soap_headers_ptr) {
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "The SoapServer::addSoapHeader function may be called only during SOAP request processing");
+ }
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &fault, soap_header_class_entry) == FAILURE) {
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters");
+ }
+
+ p = service->soap_headers_ptr;
+ while (*p != NULL) {
+ p = &(*p)->next;
+ }
+ *p = emalloc(sizeof(soapHeader));
+ memset(*p, 0, sizeof(soapHeader));
+ ZVAL_NULL(&(*p)->function_name);
+ (*p)->retval = *fault;
+ zval_copy_ctor(&(*p)->retval);
+
+ SOAP_SERVER_END_CODE();
+}
+
static void soap_server_fault_ex(sdlFunctionPtr function, zval* fault, soapHeader *hdr TSRMLS_DC)
{
int soap_version;
zend_hash_internal_pointer_reset(ht);
while (zend_hash_get_current_data(ht, (void**)&tmp) == SUCCESS) {
if (Z_TYPE_PP(tmp) != IS_OBJECT ||
- Z_OBJCE_PP(tmp) != soap_header_class_entry) {
+ !instanceof_function(Z_OBJCE_PP(tmp), soap_header_class_entry TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid SOAP header");
}
zend_hash_move_forward(ht);
verify_soap_headers_array(soap_headers TSRMLS_CC);
free_soap_headers = 0;
} else if (Z_TYPE_P(headers) == IS_OBJECT &&
- Z_OBJCE_P(headers) == soap_header_class_entry) {
+ instanceof_function(Z_OBJCE_P(headers), soap_header_class_entry TSRMLS_CC)) {
soap_headers = emalloc(sizeof(HashTable));
zend_hash_init(soap_headers, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_next_index_insert(soap_headers, &headers, sizeof(zval*), NULL);
add_property_zval(this_ptr, "__default_headers", headers);
}
} else if (Z_TYPE_P(headers) == IS_OBJECT &&
- Z_OBJCE_P(headers) == soap_header_class_entry) {
+ instanceof_function(Z_OBJCE_P(headers), soap_header_class_entry TSRMLS_CC)) {
zval *default_headers;
ALLOC_INIT_ZVAL(default_headers);
array_init(default_headers);
head = xmlNewChild(envelope, ns, "Header", NULL);
if (Z_TYPE_P(hdr_ret) == IS_OBJECT &&
- Z_OBJCE_P(hdr_ret) == soap_header_class_entry) {
+ instanceof_function(Z_OBJCE_P(hdr_ret), soap_header_class_entry)) {
HashTable* ht = Z_OBJPROP_P(hdr_ret);
zval **tmp;
sdlSoapBindingFunctionHeaderPtr *hdr;
if (Z_TYPE(h->retval) == IS_OBJECT &&
- Z_OBJCE(h->retval) == soap_header_class_entry) {
+ instanceof_function(Z_OBJCE(h->retval), soap_header_class_entry TSRMLS_CC)) {
HashTable* ht = Z_OBJPROP(h->retval);
zval **tmp;
sdlSoapBindingFunctionHeaderPtr *hdr;
--- /dev/null
+--TEST--
+SOAP Server 23: Send SOAP headers those were not received
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function test() {
+ global $server;
+ $server->addSoapHeader(new SoapHeader("http://testuri.org", "Test1", "Hello Header!"));
+ $server->addSoapHeader(new SoapHeader("http://testuri.org", "Test2", "Hello Header!"));
+ return "Hello Body!";
+}
+
+$server = new soapserver(null,array('uri'=>"http://testuri.org"));
+$server->addfunction("test");
+
+$HTTP_RAW_POST_DATA = <<<EOF
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<SOAP-ENV:Envelope
+ SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:si="http://soapinterop.org/xsd">
+ <SOAP-ENV:Body>
+ <ns1:test xmlns:ns1="http://testuri.org"/>
+ </SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
+EOF;
+
+$server->handle();
+echo "ok\n";
+?>
+--EXPECT--
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testuri.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Header><ns1:Test1>Hello Header!</ns1:Test1><ns1:Test2>Hello Header!</ns1:Test2></SOAP-ENV:Header><SOAP-ENV:Body><ns1:testResponse><return xsi:type="xsd:string">Hello Body!</return></ns1:testResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
+ok
--- /dev/null
+--TEST--
+SOAP Server 24: Send SOAP headers those were not received
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+class TestHeader1 extends SoapHeader {
+ function __construct($data) {
+ parent::__construct("http://testuri.org", "Test1", $data);
+ }
+}
+
+class TestHeader2 extends SoapHeader {
+ function __construct($data) {
+ parent::__construct("http://testuri.org", "Test2", $data);
+ }
+}
+
+function test() {
+ global $server;
+ $server->addSoapHeader(new TestHeader1("Hello Header!"));
+ $server->addSoapHeader(new TestHeader2("Hello Header!"));
+ return "Hello Body!";
+}
+
+$server = new soapserver(null,array('uri'=>"http://testuri.org"));
+$server->addfunction("test");
+
+$HTTP_RAW_POST_DATA = <<<EOF
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<SOAP-ENV:Envelope
+ SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:si="http://soapinterop.org/xsd">
+ <SOAP-ENV:Body>
+ <ns1:test xmlns:ns1="http://testuri.org"/>
+ </SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
+EOF;
+
+$server->handle();
+echo "ok\n";
+?>
+--EXPECT--
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testuri.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Header><ns1:Test1>Hello Header!</ns1:Test1><ns1:Test2>Hello Header!</ns1:Test2></SOAP-ENV:Header><SOAP-ENV:Body><ns1:testResponse><return xsi:type="xsd:string">Hello Body!</return></ns1:testResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
+ok
--- /dev/null
+--TEST--
+SOAP Server 25: One-way SOAP headers encoding using WSDL
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+class TestHeader1 extends SoapHeader {
+ function __construct($data) {
+ parent::__construct("http://testuri.org", "Test1", $data);
+ }
+}
+
+class TestHeader2 extends SoapHeader {
+ function __construct($data) {
+ parent::__construct("http://testuri.org", "Test2", $data);
+ }
+}
+
+function test() {
+ global $server;
+ $server->addSoapHeader(new TestHeader1("Hello Header!"));
+ $server->addSoapHeader(new TestHeader2("Hello Header!"));
+ return "Hello Body!";
+}
+
+$server = new soapserver(dirname(__FILE__)."/server025.wsdl");
+$server->addfunction("test");
+
+$HTTP_RAW_POST_DATA = <<<EOF
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<SOAP-ENV:Envelope
+ SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
+ <SOAP-ENV:Body>
+ <ns1:test xmlns:ns1="http://testuri.org"/>
+ </SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
+EOF;
+
+$server->handle();
+echo "ok\n";
+?>
+--EXPECT--
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://testuri.org"><SOAP-ENV:Header><ns1:Test1 xsi:type="xsd:string">Hello Header!</ns1:Test1><ns1:Test2 xsi:type="xsd:string">Hello Header!</ns1:Test2></SOAP-ENV:Header><SOAP-ENV:Body><ns1:testResponse><result>Hello Body!</result></ns1:testResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
+ok
--- /dev/null
+<?xml version="1.0" ?>
+<definitions
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
+ xmlns:si="http://soapinterop.org/xsd"
+ xmlns:tns="http://linuxsrv.home/~dmitry/soap/test.wsdl"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ targetNamespace="http://testuri.org">
+
+ <message name="TestHeader1">
+ <part name="Test1" type="xsd:string" />
+ </message>
+ <message name="TestHeader2">
+ <part name="Test2" type="xsd:string" />
+ </message>
+
+ <message name="TestRequest">
+ </message>
+ <message name="TestResponse">
+ <part name="result" type="xsd:string" />
+ </message>
+
+ <portType name="TestServicePortType">
+ <operation name="test">
+ <input message="tns:TestRequest" />
+ <output message="tns:TestResponse" />
+ </operation>
+ </portType>
+
+ <binding name="TestServiceBinding" type="tns:TestServicePortType">
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
+ <operation name="test">
+ <soap:operation soapAction="Test" style="rpc" />
+ <input>
+ <soap:body namespace="http://testuri.org" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
+ </input>
+ <output>
+ <soap:body namespace="http://testuri.org" use="literal" />
+ <soap:header namespace="http://testuri.org" message="tns:TestHeader1" part="Test1" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
+ <soap:header namespace="http://testuri.org" message="tns:TestHeader2" part="Test2" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
+ </output>
+ </operation>
+ </binding>
+
+ <service name="TestService">
+ <port name="TestServicePort" binding="tns:TestServiceBinding">
+ <soap:address location="http://linuxsrv.home/~dmitry/soap/soap_server.php" />
+ </port>
+ </service>
+
+</definitions>