SOAP
[ class tree: SOAP ] [ index: SOAP ] [ all elements ]

Source for file client.php

Documentation is available at client.php

  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license,      |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Shane Caraveo <Shane@Caraveo.com>                           |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: client.php,v 1.10 2005/03/10 23:16:39 yunosh Exp $
  20. //
  21. include("SOAP/Client.php");
  22.  
  23. /**
  24.  * this client runs against the example server in SOAP/example/server.php
  25.  * it does not use WSDL to run these requests, but that can be changed easily by simply
  26.  * adding '?wsdl' to the end of the url.
  27.  */
  28. $soapclient = new SOAP_Client("http://localhost/SOAP/example/server.php");
  29. // this namespace is the same as declared in server.php
  30. $options = array('namespace' => 'urn:SOAP_Example_Server',
  31.                  'trace' => 1);
  32.  
  33. $ret $soapclient->call("echoStringSimple",
  34.                          $params = array("inputStringSimple"=>"this is a test string"),
  35.                          $options);
  36. #print $soapclient->__get_wire();
  37. print_r($ret);echo "<br>\n";
  38.  
  39. $ret $soapclient->call("echoString",
  40.                          $params = array("inputString"=>"this is a test string"),
  41.                          $options);
  42. print_r($ret);echo "<br>\n";
  43.  
  44. $ret $soapclient->call("divide",
  45.                          $params = array("dividend"=>22,"divisor"=>7),
  46.                          $options);
  47. # print $soapclient->__get_wire();
  48. if (PEAR::isError($ret))
  49.     print("Error: " $ret->getMessage("<br>\n");
  50. else
  51.     print("Quotient is " $ret "<br>\n");
  52.  
  53. $ret $soapclient->call("divide",
  54.                          $params = array("dividend"=>22,"divisor"=>0),
  55.                          $options);
  56. if (PEAR::isError($ret))
  57.     print("Error: " $ret->getMessage("<br>\n");
  58. else
  59.     print("Quotient is " $ret "<br>\n");
  60.  
  61.  
  62. // SOAPStruct is defined in the following file
  63. require_once 'example_types.php';
  64.  
  65. $struct = new SOAPStruct('test string',123,123.123);
  66.  
  67. /* send an object, get an object back */
  68. /* tell client to translate to classes we provide if possible */
  69. $soapclient->_auto_translation = true;
  70. /* or you can explicitly set the translation for
  71.    a specific class.  auto_translation works for all cases,
  72.    but opens ANY class in the script to be used as a data type,
  73.    and may not be desireable.  both can be used on client or
  74.    server */
  75. $soapclient->__set_type_translation('{http://soapinterop.org/xsd}SOAPStruct','SOAPStruct');
  76. $ret $soapclient->call("echoStruct",
  77.                          $p = array('inputStruct' => $struct->__to_soap()),
  78.                          $options);
  79. #print $soapclient->__get_wire();
  80. print_r($ret);
  81.  
  82. /**
  83.  * PHP doesn't support multiple OUT parameters in function calls, so we
  84.  * must do a little work to make it happen here.  This requires knowledge on the
  85.  * developers part to figure out how they want to deal with it.
  86.  */
  87. $ret $soapclient->call("echoStructAsSimpleTypes",
  88.                          $p = array('inputStruct' => $struct->__to_soap()),
  89.                          $options);
  90. if (PEAR::isError($ret)) {
  91.     print("Error: " $ret->getMessage("<br>\n");
  92. else {
  93.     list($string$int$floatarray_values($ret);
  94. }
  95. echo "varString: $string<br>\nvarInt: $int<br>\nvarFloat: $float<br>\n";
  96.  
  97. ?>

Documentation generated on Mon, 11 Mar 2019 14:20:07 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.