dmitry Wed Apr 20 06:59:02 2005 EDT
Modified files:
/php-src/ext/soap php_packet_soap.c soap.c
/php-src/ext/soap/tests/bugs bug32776.phpt bug32776.wsdl
Log:
Fixed bug #32776 (SOAP doesn't support one-way operations)
http://cvs.php.net/diff.php/php-src/ext/soap/php_packet_soap.c?r1=1.40&r2=1.41&ty=u
Index: php-src/ext/soap/php_packet_soap.c
diff -u php-src/ext/soap/php_packet_soap.c:1.40
php-src/ext/soap/php_packet_soap.c:1.41
--- php-src/ext/soap/php_packet_soap.c:1.40 Tue Mar 22 05:19:07 2005
+++ php-src/ext/soap/php_packet_soap.c Wed Apr 20 06:59:01 2005
@@ -17,7 +17,7 @@
| Dmitry Stogov <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_packet_soap.c,v 1.40 2005/03/22 10:19:07 dmitry Exp $ */
+/* $Id: php_packet_soap.c,v 1.41 2005/04/20 10:59:01 dmitry Exp $ */
#include "php_soap.h"
@@ -34,6 +34,11 @@
ZVAL_NULL(return_value);
+ /* Response for one-way opearation */
+ if (buffer_size == 0) {
+ return TRUE;
+ }
+
/* Parse XML packet */
response = soap_xmlParseMemory(buffer, buffer_size);
http://cvs.php.net/diff.php/php-src/ext/soap/soap.c?r1=1.142&r2=1.143&ty=u
Index: php-src/ext/soap/soap.c
diff -u php-src/ext/soap/soap.c:1.142 php-src/ext/soap/soap.c:1.143
--- php-src/ext/soap/soap.c:1.142 Wed Apr 20 04:44:05 2005
+++ php-src/ext/soap/soap.c Wed Apr 20 06:59:01 2005
@@ -17,7 +17,7 @@
| Dmitry Stogov <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
-/* $Id: soap.c,v 1.142 2005/04/20 08:44:05 dmitry Exp $ */
+/* $Id: soap.c,v 1.143 2005/04/20 10:59:01 dmitry Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -1689,25 +1689,30 @@
/* Flush buffer */
php_end_ob_buffer(0, 0 TSRMLS_CC);
- /* xmlDocDumpMemoryEnc(doc_return, &buf, &size,
XML_CHAR_ENCODING_UTF8); */
- xmlDocDumpMemory(doc_return, &buf, &size);
-
- if (size == 0) {
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "Dump memory failed");
- }
+ if (doc_return) {
+ /* xmlDocDumpMemoryEnc(doc_return, &buf, &size,
XML_CHAR_ENCODING_UTF8); */
+ xmlDocDumpMemory(doc_return, &buf, &size);
+
+ if (size == 0) {
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Dump memory
failed");
+ }
+
+ sprintf(cont_len, "Content-Length: %d", size);
+ sapi_add_header(cont_len, strlen(cont_len), 1);
+ if (soap_version == SOAP_1_2) {
+ sapi_add_header("Content-Type: application/soap+xml;
charset=utf-8", sizeof("Content-Type: application/soap+xml; charset=utf-8")-1,
1);
+ } else {
+ sapi_add_header("Content-Type: text/xml;
charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1);
+ }
- sprintf(cont_len, "Content-Length: %d", size);
- sapi_add_header(cont_len, strlen(cont_len), 1);
- if (soap_version == SOAP_1_2) {
- sapi_add_header("Content-Type: application/soap+xml;
charset=utf-8", sizeof("Content-Type: application/soap+xml; charset=utf-8")-1,
1);
+ xmlFreeDoc(doc_return);
+ php_write(buf, size TSRMLS_CC);
+ xmlFree(buf);
} else {
- sapi_add_header("Content-Type: text/xml; charset=utf-8",
sizeof("Content-Type: text/xml; charset=utf-8")-1, 1);
+ sapi_add_header("HTTP/1.1 202 Accepted", sizeof("HTTP/1.1 202
Accepted")-1, 1);
+ sapi_add_header("Content-Length: 0", sizeof("Content-Length:
0")-1, 1);
}
- xmlFreeDoc(doc_return);
- php_write(buf, size TSRMLS_CC);
- xmlFree(buf);
-
fail:
SOAP_GLOBAL(soap_version) = old_soap_version;
SOAP_GLOBAL(encoding) = old_encoding;
@@ -3156,7 +3161,7 @@
ns = encode_add_ns(body, fnb->output.ns);
if (function->responseName) {
method = xmlNewChild(body, ns,
function->responseName, NULL);
- } else {
+ } else if (function->responseParameters) {
method = xmlNewChild(body, ns,
function->functionName, NULL);
}
}
@@ -3248,6 +3253,7 @@
xmlNodePtr envelope = NULL, body, param;
xmlNsPtr ns = NULL;
int use = SOAP_LITERAL;
+ xmlNodePtr head = NULL;
encode_reset_ns();
@@ -3459,7 +3465,6 @@
} else {
if (headers) {
- xmlNodePtr head;
soapHeader *h;
head = xmlNewChild(envelope, ns, "Header", NULL);
@@ -3552,6 +3557,11 @@
}
}
+ if (function && function->responseName == NULL &&
+ body->children == NULL && head == NULL) {
+ xmlFreeDoc(doc);
+ return NULL;
+ }
return doc;
}
http://cvs.php.net/diff.php/php-src/ext/soap/tests/bugs/bug32776.phpt?r1=1.1&r2=1.2&ty=u
Index: php-src/ext/soap/tests/bugs/bug32776.phpt
diff -u /dev/null php-src/ext/soap/tests/bugs/bug32776.phpt:1.2
--- /dev/null Wed Apr 20 06:59:02 2005
+++ php-src/ext/soap/tests/bugs/bug32776.phpt Wed Apr 20 06:59:02 2005
@@ -0,0 +1,47 @@
+--TEST--
+Bug #32776 SOAP doesn't support one-way operations
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$d = null;
+
+function test($x) {
+ global $d;
+ $d = $x;
+}
+
+class LocalSoapClient extends SoapClient {
+
+ function __construct($wsdl, $options) {
+ parent::__construct($wsdl, $options);
+ $this->server = new SoapServer($wsdl, $options);
+ $this->server->addFunction('test');
+ }
+
+ function __doRequest($request, $location, $action, $version) {
+ ob_start();
+ $this->server->handle($request);
+ $response = ob_get_contents();
+ ob_end_clean();
+ return $response;
+ }
+
+}
+
+$x = new
LocalSoapClient(dirname(__FILE__)."/bug32776.wsdl",array("trace"=>true,"exceptions"=>false));
+var_dump($x->test("Hello"));
+var_dump($d);
+var_dump($x->__getLastRequest());
+var_dump($x->__getLastResponse());
+echo "ok\n";
+?>
+--EXPECT--
+NULL
+string(5) "Hello"
+string(459) "<?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: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:Body><SOAP-ENV:test><x
xsi:type="xsd:string">Hello</x></SOAP-ENV:test></SOAP-ENV:Body></SOAP-ENV:Envelope>
+"
+string(0) ""
+ok
http://cvs.php.net/diff.php/php-src/ext/soap/tests/bugs/bug32776.wsdl?r1=1.1&r2=1.2&ty=u
Index: php-src/ext/soap/tests/bugs/bug32776.wsdl
diff -u /dev/null php-src/ext/soap/tests/bugs/bug32776.wsdl:1.2
--- /dev/null Wed Apr 20 06:59:02 2005
+++ php-src/ext/soap/tests/bugs/bug32776.wsdl Wed Apr 20 06:59:02 2005
@@ -0,0 +1,47 @@
+<?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://linuxsrv.home/~dmitry/soap/test.wsdl">
+
+ <types>
+ <xsd:schema targetNamespace="http://linuxsrv.home/~dmitry/soap/test.wsdl">
+ <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
+ <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
+ </xsd:schema>
+ </types>
+
+ <message name="TestRequest">
+ <part name="x" type="xsd:string" />
+ </message>
+
+ <portType name="TestServicePortType">
+ <operation name="test">
+ <input message="tns:TestRequest" />
+ </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="Add" style="rpc" />
+ <input>
+ <soap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
+ </input>
+ </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>
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php