From 71380e7d7fbed263e865a33489b02c707447af6e Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 12 Feb 2004 09:05:56 +0000 Subject: [PATCH] "Runtime Configuration" and "Exceptions" were added. --- ext/soap/readme.html | 67 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/ext/soap/readme.html b/ext/soap/readme.html index 26770dc9b0..1284391396 100644 --- a/ext/soap/readme.html +++ b/ext/soap/readme.html @@ -22,13 +22,38 @@ TD:{ This extension is EXPERIMENTAL. The behaviour of this extension -- including the names of its functions and anything else documented about this extension -- may change without notice in a future release of PHP. Use this extension at your own risk. -FIXME +

+SOAP extension can be used to write SOAP Servers and Clients. It supports +subsets of SOAP 1.1, +SOAP 1.2 and +WSDL 1.1 specifications. +


Requirements

This extension makes use of the GNOME XML library. Download and install this library. You will need at least libxml-2.5.4.

Installation

This extension is only available if PHP was configured with --enable-soap. +
+

Runtime Configuration

+

The behaviour of these functions is affected by settings in php.ini.

+ + + + + +
NameDefaultChangeable
soap.wsdl_cache_enabled"1"PHP_INI_ALL
soap.wsdl_cache_dir"/tmp"PHP_INI_ALL
soap.wsdl_cache_ttl86400PHP_INI_ALL
+

Here is a short explanation of the configuration directives.

+
+
soap.wsdl_cache_enabled (boolean)
+
enables or disables WSDL caching feature.
+
soap.wsdl_cache_dir (string)
+
sets the directory name where SOAP extension will put cache files
+
soap.wsdl_cache_ttl (integer)
+
(time to live) sets the number of second while cached file will be used instead of original one.
+
+ +

Predefined Constants

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. @@ -168,8 +193,9 @@ It is just a data holder and it has not any special method except constructor.

SoapFault class

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. +handling of SOAP request. It is derived form standard PHP Exception class, +so it can be used to throw exceptions in server side and to catch tham on +client side.

@@ -207,20 +233,33 @@ constructor.

Description

bool is_soap_fault(mixed obj)

-This function is useful when you like to check if the SOAP call was failed. -In this case SOAP method returns a special SoapFault object which encapsulate -the fault details (faultcode, faultstring, faultactor and faultdetails). -is_soap_fault() functions checks if the given parameter is a SoapFault object. +This function is useful when you like to check if the SOAP call was failed, +but don't like to use exceptions. To use it you must create SoapClient object +with exceptions option set to zero or false. In this case SOAP method +will return a special SoapFault object which encapsulate the fault details +(faultcode, faultstring, faultactor and faultdetails). If exceptions is +not set then SOAP call will throw an exception on error.
+is_soap_fault() functions checks if the given parameter is a SoapFault object.

Example

SoapFault -- SoapFault constructor
 <?php
-    $client = SoapClient("some.wsdl");
+    $client = SoapClient("some.wsdl",array("exceptions"=>0));
     $result = $client->SomeFunction(...);
     if (is_soap_fault($result)) {
         trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faulstring})", E_ERROR);
     }
 ?>
+

Standard method that used by SOAP extension for error reporting is excptions.

+
+<?php
+    try {
+        $client = SoapClient("some.wsdl");
+        $result = $client->SomeFunction(...);
+    } catch {SoapFault $fault) {
+        trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faulstring})", E_ERROR);
+    }
+?>

SoapClient::SoapClient

@@ -614,6 +653,18 @@ This class is useful when you like to send SOAP fault response from PHP handler. $server->handle(); ?> +

It is possible to use PHP exception mechanism to throw SOAP Fault.

+
+<?php
+    function test($x) {
+        throw new SoapFault("Server","Some error message");
+    }
+
+    $server = new SoapServer(null,array('uri'=>"http://test-uri/"));
+    $server->addFunction("test");
+    $server->handle();
+?>
+

See also: SoapServer::fault

\ No newline at end of file -- 2.50.1