logo       

cvs: pear /SOAP/example client.php server.php: msg#00661

php.cvs.pear

Subject: cvs: pear /SOAP/example client.php server.php

shane Sun Sep 29 16:57:33 2002 EDT

Modified files:
/pear/SOAP/example client.php server.php
Log:
better example and documentation of using objects with soap.


Index: pear/SOAP/example/client.php
diff -u pear/SOAP/example/client.php:1.3 pear/SOAP/example/client.php:1.4
--- pear/SOAP/example/client.php:1.3 Sat Sep 28 21:06:09 2002
+++ pear/SOAP/example/client.php Sun Sep 29 16:57:33 2002
@@ -16,7 +16,7 @@
// | Authors: Shane Caraveo <Shane@xxxxxxxxxxx> |
// +----------------------------------------------------------------------+
//
-// $Id: client.php,v 1.3 2002/09/29 01:06:09 shane Exp $
+// $Id: client.php,v 1.4 2002/09/29 20:57:33 shane Exp $
//
include("SOAP/Client.php");
/**
@@ -28,22 +28,39 @@
'trace' => 1);

$ret = $soapclient->call("echoStringSimple",array("inputString"=>"this is a
test string"),$options);
-print $soapclient->__get_wire();
+#print $soapclient->__get_wire();
print_r($ret);echo "<br>\n";

$ret = $soapclient->call("echoString",array("inputString"=>"this is a test
string"),$options);
print_r($ret);echo "<br>\n";

class SOAPStruct {
- var $varString = 'This is a test';
- var $varInt = 1234;
- var $varFloat = 123.456;
+ var $varString;
+ var $varInt;
+ var $varFloat;
+ function SOAPStruct($s=NULL, $i=NULL, $f=NULL) {
+ $this->varString = $s;
+ $this->varInt = $i;
+ $this->varFloat = $f;
+ }
}

-$SOAPStruct = new SOAPStruct;
+$struct = new SOAPStruct('test string',123,123.123);

/* send an object, get an object back */
-$ret = $soapclient->call("echoStruct",array(new
SOAP_Value('inputStruct','',$SOAPStruct)),$options);
+/* tell client to translate to classes we provide if possible */
+$soapclient->_auto_translation = true;
+/* or you can explicitly set the translation for
+ a specific class. auto_translation works for all cases,
+ but opens ANY class in the script to be used as a data type,
+ and may not be desireable. both can be used on client or
+ server */
+$soapclient->__set_type_translation('{http://soapinterop.org/xsd}SOAPStruct','SOAPStruct');
+$ret = $soapclient->call("echoStruct",
+ array(new SOAP_Value('inputStruct',
+ '{http://soapinterop.org/xsd}SOAPStruct',
+ $struct)),$options);
+#print $soapclient->__get_wire();
print_r($ret);

/**
@@ -51,7 +68,7 @@
* must do a little work to make it happen here. This requires knowledge on
the
* developers part to figure out how they want to deal with it.
*/
-list($string, $int, $float) =
array_values($soapclient->call("echoStructAsSimpleTypes",$SOAPStruct,$options));
+list($string, $int, $float) =
array_values($soapclient->call("echoStructAsSimpleTypes",$struct,$options));
echo "varString: $string<br>\nvarInt: $int<br>\nvarFloat: $float<br>\n";

?>
Index: pear/SOAP/example/server.php
diff -u pear/SOAP/example/server.php:1.3 pear/SOAP/example/server.php:1.4
--- pear/SOAP/example/server.php:1.3 Sat Jul 13 16:43:10 2002
+++ pear/SOAP/example/server.php Sun Sep 29 16:57:33 2002
@@ -16,13 +16,26 @@
// | Authors: Shane Caraveo <Shane@xxxxxxxxxxx> |
// +----------------------------------------------------------------------+
//
-// $Id: server.php,v 1.3 2002/07/13 20:43:10 shane Exp $
+// $Id: server.php,v 1.4 2002/09/29 20:57:33 shane Exp $
//

// first, include the SOAP/Server class
require_once 'SOAP/Server.php';

$server = new SOAP_Server;
+/* tell server to translate to classes we provide if possible */
+$server->_auto_translation = true;
+
+class SOAPStruct {
+ var $varString;
+ var $varInt;
+ var $varFloat;
+ function SOAPStruct($s=NULL, $i=NULL, $f=NULL) {
+ $this->varString = $s;
+ $this->varInt = $i;
+ $this->varFloat = $f;
+ }
+}

// create a class for your soap functions
class SOAP_Example_Server {
@@ -66,7 +79,7 @@

function echoStruct($inputStruct)
{
- return new SOAP_Value('outputStruct','',$inputStruct);
+ return new
SOAP_Value('outputStruct','{http://soapinterop.org/xsd}SOAPStruct',$inputStruct);
}

/**



--
PEAR CVS Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise