dmitry Mon Feb 9 04:31:21 2004 EDT Added files: /php-src/ext/soap/tests server016.phpt server017.phpt
Modified files: /php-src/ext/soap config.w32 readme.html soap.c Log: Allowing to report SOAP Fault with "return new SoapFault(...)"
http://cvs.php.net/diff.php/php-src/ext/soap/config.w32?r1=1.4&r2=1.5&ty=u Index: php-src/ext/soap/config.w32 diff -u php-src/ext/soap/config.w32:1.4 php-src/ext/soap/config.w32:1.5 --- php-src/ext/soap/config.w32:1.4 Fri Feb 6 04:18:51 2004 +++ php-src/ext/soap/config.w32 Mon Feb 9 04:31:12 2004 @@ -1,7 +1,7 @@ -// $Id: config.w32,v 1.4 2004/02/06 09:18:51 wez Exp $ +// $Id: config.w32,v 1.5 2004/02/09 09:31:12 dmitry Exp $ // vim:ft=javascript -ARG_WITH("soap", "SOAP support", "no"); +ARG_ENABLE("soap", "SOAP support", "no"); if (PHP_SOAP != "no" && PHP_LIBXML == "yes") { EXTENSION('soap', 'soap.c php_encoding.c php_http.c php_packet_soap.c php_schema.c php_sdl.c php_xml.c'); http://cvs.php.net/diff.php/php-src/ext/soap/readme.html?r1=1.3&r2=1.4&ty=u Index: php-src/ext/soap/readme.html diff -u php-src/ext/soap/readme.html:1.3 php-src/ext/soap/readme.html:1.4 --- php-src/ext/soap/readme.html:1.3 Mon Feb 9 02:51:07 2004 +++ php-src/ext/soap/readme.html Mon Feb 9 04:31:12 2004 @@ -28,7 +28,7 @@ This extension makes use of the <A HREF="http://www.xmlsoft.org" TARGET="_top">GNOME XML library</A>. Download and install this library. You will need at least libxml-2.5.4. <HR> <H2>Installation</H2> -This extension is only available if PHP was configured with --with-soap. +This extension is only available if PHP was configured with --enable-soap. <HR> <H2>Predefined Constants</H2> The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime. @@ -107,6 +107,7 @@ <tr><td><a href="#ref.soap.soapparam">SoapParam</a></td></tr> <tr><td><a href="#ref.soap.soapvar">SoapVar</a></td></tr> <tr><td><a href="#ref.soap.soapheader">SoapHeader</a></td></tr> +<tr><td><a href="#ref.soap.soapfault">SoapFault</a></td></tr> </table> <a name="ref.soap.soapclient"> <h4>SoapClient class</h4> @@ -163,6 +164,16 @@ <table border="0"> <tr><td><a href="#ref.soap.soapheader.soapheader">SoapHeader</a> -- SoapHeader constructor</td></tr> </table> +<a name="ref.soap.soapfault"> +<h4>SoapFault class</h4> +<p> +SoapFault is a special class that can be used for error reporting during +handling of SOAP request (on server). It has not any special methods except +constructor. +</p> +<table border="0"> +<tr><td><a href="#ref.soap.soapfault.soapfault">SoapFault</a> -- SoapFault constructor</td></tr> +</table> <HR> <!-- <H2>Examples</H2> @@ -186,6 +197,7 @@ <tr><td><a href="#ref.soap.soapparam.soapparam">SoapParam::SoapParam</a> -- SoapParam constructor</td></tr> <tr><td><a href="#ref.soap.soapvar.soapvar">SoapVar::SoapVar</a> -- SoapVar constructor</td></tr> <tr><td><a href="#ref.soap.soapheader.soapheader">SoapHeader::SoapHeader</a> -- SoapHeader constructor</td></tr> +<tr><td><a href="#ref.soap.soapfault.soapfault">SoapFault::SoapFault</a> -- SoapFault constructor</td></tr> </table> <a name="ref.soap.is_soap_fault"></a> @@ -216,7 +228,6 @@ <p>SoapClient constructor</p> <h3>Description</h3> <p><b>SoapClient</b>(mixed wsdl [, array options])</p> -<h4>Examples</h4> <p> The constructor allows creating SoapClient objects in WSDL or nonWSDL mode. The first case requires URI of WSDL file as first parameter and optional @@ -230,6 +241,7 @@ and <b>password</b>) and HTTP connection through proxy server (<b>proxy_host</b>, <b>proxy_port</b>, <b>proxy_login</b> and <b>proxy_password</b>). </p> +<h4>Examples</h4> <TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php"> $client = new SoapClient("some.wsdl"); @@ -494,6 +506,7 @@ $server->handle(); ?> </PRE></TD></TR></TABLE> +<p>See also: <a href="#ref.soap.soapfault.soapfault">SoapFault::SoapFault</a></p> <a name="ref.soap.soapparam.soapparam"></a> <h2>SoapParam::SoapParam</h2> @@ -580,5 +593,27 @@ 'hello world')); ?> </PRE></TD></TR></TABLE> + +<a name="ref.soap.soapfault.soapfault"></a> +<h2>SoapFault::SoapFault</h2> +<p>(PHP 5)</p> +<p>SoapFault constructor</p> +<h3>Description</h3> +<p><b>SoapFault</b>(string faultcode, string faultstring [, string faultactor [, mixed details]])</p> +This class is useful when you like to send SOAP fault response from PHP handler. +<h4>Example</h4> +<h4>Example</h4> +<TABLE BORDER="0" BGCOLOR="#E0E0E0"><TR><TD><PRE CLASS="php"> +<?php + function test($x) { + return new SoapFault("Server","Some error message"); + } + + $server = new SoapServer(null,array('uri'=>"http://test-uri/")); + $server->addFunction("test"); + $server->handle(); +?> +</PRE></TD></TR></TABLE> +<p>See also: <a href="#ref.soap.soapserver.fault">SoapServer::fault</a></p> </BODY> </HTML> \ No newline at end of file http://cvs.php.net/diff.php/php-src/ext/soap/soap.c?r1=1.75&r2=1.76&ty=u Index: php-src/ext/soap/soap.c diff -u php-src/ext/soap/soap.c:1.75 php-src/ext/soap/soap.c:1.76 --- php-src/ext/soap/soap.c:1.75 Mon Feb 9 02:51:07 2004 +++ php-src/ext/soap/soap.c Mon Feb 9 04:31:12 2004 @@ -17,7 +17,7 @@ | Dmitry Stogov <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: soap.c,v 1.75 2004/02/09 07:51:07 dmitry Exp $ */ +/* $Id: soap.c,v 1.76 2004/02/09 09:31:12 dmitry Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -47,6 +47,7 @@ static void clear_soap_fault(zval *obj TSRMLS_DC); static void set_soap_fault(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail TSRMLS_DC); static void soap_server_fault(char* code, char* string, char *actor, zval* details TSRMLS_DC); +static void soap_server_fault_ex(zval* fault TSRMLS_DC); static sdlParamPtr get_param(sdlFunctionPtr function, char *param_name, int index, int); static sdlFunctionPtr get_function(sdlPtr sdl, const char *function_name); @@ -1274,6 +1275,11 @@ if (call_status == SUCCESS) { char *response_name; + if (Z_TYPE(retval) == IS_OBJECT && + Z_OBJCE(retval) == soap_fault_class_entry) { + soap_server_fault_ex(&retval TSRMLS_CC); + } + if (function && function->responseName) { response_name = estrdup(function->responseName); } else { @@ -1361,21 +1367,16 @@ SOAP_SERVER_END_CODE(); } -static void soap_server_fault(char* code, char* string, char *actor, zval* details TSRMLS_DC) +static void soap_server_fault_ex(zval* fault TSRMLS_DC) { int soap_version; xmlChar *buf, cont_len[30]; int size; - zval ret; xmlDocPtr doc_return; soap_version = SOAP_GLOBAL(soap_version); - INIT_ZVAL(ret); - - set_soap_fault(&ret, code, string, actor, details TSRMLS_CC); - - doc_return = seralize_response_call(NULL, NULL, NULL, &ret, NULL, soap_version TSRMLS_CC); + doc_return = seralize_response_call(NULL, NULL, NULL, fault, NULL, soap_version TSRMLS_CC); xmlDocDumpMemory(doc_return, &buf, &size); @@ -1398,6 +1399,16 @@ zend_bailout(); } +static void soap_server_fault(char* code, char* string, char *actor, zval* details TSRMLS_DC) +{ + zval ret; + + INIT_ZVAL(ret); + + set_soap_fault(&ret, code, string, actor, details TSRMLS_CC); + soap_server_fault_ex(&ret TSRMLS_CC); +} + static void soap_error_handler(int error_num, const char *error_filename, const uint error_lineno, const char *format, va_list args) { TSRMLS_FETCH(); http://cvs.php.net/co.php/php-src/ext/soap/tests/server016.phpt?r=1.1&p=1 Index: php-src/ext/soap/tests/server016.phpt +++ php-src/ext/soap/tests/server016.phpt --TEST-- SOAP Server 16: user fault --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php function test() { global $server; $server->fault("MyFault","My fault string"); } $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/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>MyFault</faultcode><faultstring>My fault string</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope> http://cvs.php.net/co.php/php-src/ext/soap/tests/server017.phpt?r=1.1&p=1 Index: php-src/ext/soap/tests/server017.phpt +++ php-src/ext/soap/tests/server017.phpt --TEST-- SOAP Server 17: user fault (through return) --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- <?php function test() { return new SoapFault("MyFault","My fault string"); } $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/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>MyFault</faultcode><faultstring>My fault string</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php