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

Source for file wsdl_client.php

Documentation is available at wsdl_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: wsdl_client.php,v 1.3 2005/03/10 23:16:40 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. $wsdl = new SOAP_WSDL("http://localhost/SOAP/example/server.php?wsdl");
  29. $soapclient $wsdl->getProxy();
  30.  
  31. $ret $soapclient->echoStringSimple("this is a test string");
  32. #print $soapclient->__get_wire();
  33. print_r($ret);echo "<br>\n";
  34.  
  35. $ret $soapclient->echoString("this is a test string");
  36. print_r($ret);echo "<br>\n";
  37.  
  38. $ret $soapclient->divide(22,7);
  39. # print $soapclient->__get_wire();
  40. if (PEAR::isError($ret))
  41.     print("Error: " $ret->getMessage("<br>\n");
  42. else
  43.     print("Quotient is " $ret "<br>\n");
  44.  
  45. $ret $soapclient->divide(22,0);
  46. if (PEAR::isError($ret))
  47.     print("Error: " $ret->getMessage("<br>\n");
  48. else
  49.     print("Quotient is " $ret "<br>\n");
  50.  
  51.  
  52. // SOAPStruct is defined in the following file
  53. require_once 'example_types.php';
  54.  
  55. $struct = new SOAPStruct('test string',123,123.123);
  56.  
  57. /* send an object, get an object back */
  58. /* tell client to translate to classes we provide if possible */
  59. $soapclient->_auto_translation = true;
  60. /* or you can explicitly set the translation for
  61.    a specific class.  auto_translation works for all cases,
  62.    but opens ANY class in the script to be used as a data type,
  63.    and may not be desireable.  both can be used on client or
  64.    server */
  65. $soapclient->__set_type_translation('{http://soapinterop.org/xsd}SOAPStruct','SOAPStruct');
  66. $ret $soapclient->echoStruct($struct->__to_soap());
  67. #print $soapclient->__get_wire();
  68. print_r($ret);
  69.  
  70. /**
  71.  * PHP doesn't support multiple OUT parameters in function calls, so we
  72.  * must do a little work to make it happen here.  This requires knowledge on the
  73.  * developers part to figure out how they want to deal with it.
  74.  */
  75. $ret $soapclient->echoStructAsSimpleTypes($struct->__to_soap());
  76. if (PEAR::isError($ret)) {
  77.     print("Error: " $ret->getMessage("<br>\n");
  78. else {
  79.     list($string$int$floatarray_values($ret);
  80. }
  81. echo "varString: $string<br>\nvarInt: $int<br>\nvarFloat: $float<br>\n";
  82.  
  83. ?>

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