@@ -63,7 +63,7 @@ |
||
| 63 | 63 | * |
| 64 | 64 | * @param string $name optional name |
| 65 | 65 | * @param mixed $type optional type name |
| 66 | - * @param mixed $value optional value |
|
| 66 | + * @param integer $value optional value |
|
| 67 | 67 | * @param mixed $element_ns optional namespace of value |
| 68 | 68 | * @param mixed $type_ns optional namespace of type |
| 69 | 69 | * @param mixed $attributes associative array of attributes to add to element serialization |
@@ -15,90 +15,90 @@ |
||
| 15 | 15 | * @access public |
| 16 | 16 | */ |
| 17 | 17 | class soapval extends nusoap_base {
|
| 18 | - /** |
|
| 19 | - * The XML element name |
|
| 20 | - * |
|
| 21 | - * @var string |
|
| 22 | - * @access private |
|
| 23 | - */ |
|
| 24 | - var $name; |
|
| 25 | - /** |
|
| 26 | - * The XML type name (string or false) |
|
| 27 | - * |
|
| 28 | - * @var mixed |
|
| 29 | - * @access private |
|
| 30 | - */ |
|
| 31 | - var $type; |
|
| 32 | - /** |
|
| 33 | - * The PHP value |
|
| 34 | - * |
|
| 35 | - * @var mixed |
|
| 36 | - * @access private |
|
| 37 | - */ |
|
| 38 | - var $value; |
|
| 39 | - /** |
|
| 40 | - * The XML element namespace (string or false) |
|
| 41 | - * |
|
| 42 | - * @var mixed |
|
| 43 | - * @access private |
|
| 44 | - */ |
|
| 45 | - var $element_ns; |
|
| 46 | - /** |
|
| 47 | - * The XML type namespace (string or false) |
|
| 48 | - * |
|
| 49 | - * @var mixed |
|
| 50 | - * @access private |
|
| 51 | - */ |
|
| 52 | - var $type_ns; |
|
| 53 | - /** |
|
| 54 | - * The XML element attributes (array or false) |
|
| 55 | - * |
|
| 56 | - * @var mixed |
|
| 57 | - * @access private |
|
| 58 | - */ |
|
| 59 | - var $attributes; |
|
| 18 | + /** |
|
| 19 | + * The XML element name |
|
| 20 | + * |
|
| 21 | + * @var string |
|
| 22 | + * @access private |
|
| 23 | + */ |
|
| 24 | + var $name; |
|
| 25 | + /** |
|
| 26 | + * The XML type name (string or false) |
|
| 27 | + * |
|
| 28 | + * @var mixed |
|
| 29 | + * @access private |
|
| 30 | + */ |
|
| 31 | + var $type; |
|
| 32 | + /** |
|
| 33 | + * The PHP value |
|
| 34 | + * |
|
| 35 | + * @var mixed |
|
| 36 | + * @access private |
|
| 37 | + */ |
|
| 38 | + var $value; |
|
| 39 | + /** |
|
| 40 | + * The XML element namespace (string or false) |
|
| 41 | + * |
|
| 42 | + * @var mixed |
|
| 43 | + * @access private |
|
| 44 | + */ |
|
| 45 | + var $element_ns; |
|
| 46 | + /** |
|
| 47 | + * The XML type namespace (string or false) |
|
| 48 | + * |
|
| 49 | + * @var mixed |
|
| 50 | + * @access private |
|
| 51 | + */ |
|
| 52 | + var $type_ns; |
|
| 53 | + /** |
|
| 54 | + * The XML element attributes (array or false) |
|
| 55 | + * |
|
| 56 | + * @var mixed |
|
| 57 | + * @access private |
|
| 58 | + */ |
|
| 59 | + var $attributes; |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * constructor |
|
| 63 | - * |
|
| 64 | - * @param string $name optional name |
|
| 65 | - * @param mixed $type optional type name |
|
| 66 | - * @param mixed $value optional value |
|
| 67 | - * @param mixed $element_ns optional namespace of value |
|
| 68 | - * @param mixed $type_ns optional namespace of type |
|
| 69 | - * @param mixed $attributes associative array of attributes to add to element serialization |
|
| 70 | - * @access public |
|
| 71 | - */ |
|
| 72 | - function soapval($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) {
|
|
| 73 | - parent::nusoap_base(); |
|
| 74 | - $this->name = $name; |
|
| 75 | - $this->type = $type; |
|
| 76 | - $this->value = $value; |
|
| 77 | - $this->element_ns = $element_ns; |
|
| 78 | - $this->type_ns = $type_ns; |
|
| 79 | - $this->attributes = $attributes; |
|
| 61 | + /** |
|
| 62 | + * constructor |
|
| 63 | + * |
|
| 64 | + * @param string $name optional name |
|
| 65 | + * @param mixed $type optional type name |
|
| 66 | + * @param mixed $value optional value |
|
| 67 | + * @param mixed $element_ns optional namespace of value |
|
| 68 | + * @param mixed $type_ns optional namespace of type |
|
| 69 | + * @param mixed $attributes associative array of attributes to add to element serialization |
|
| 70 | + * @access public |
|
| 71 | + */ |
|
| 72 | + function soapval($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) {
|
|
| 73 | + parent::nusoap_base(); |
|
| 74 | + $this->name = $name; |
|
| 75 | + $this->type = $type; |
|
| 76 | + $this->value = $value; |
|
| 77 | + $this->element_ns = $element_ns; |
|
| 78 | + $this->type_ns = $type_ns; |
|
| 79 | + $this->attributes = $attributes; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * return serialized value |
|
| 84 | - * |
|
| 85 | - * @param string $use The WSDL use value (encoded|literal) |
|
| 86 | - * @return string XML data |
|
| 87 | - * @access public |
|
| 88 | - */ |
|
| 89 | - function serialize($use='encoded') {
|
|
| 90 | - return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true); |
|
| 82 | + /** |
|
| 83 | + * return serialized value |
|
| 84 | + * |
|
| 85 | + * @param string $use The WSDL use value (encoded|literal) |
|
| 86 | + * @return string XML data |
|
| 87 | + * @access public |
|
| 88 | + */ |
|
| 89 | + function serialize($use='encoded') {
|
|
| 90 | + return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * decodes a soapval object into a PHP native type |
|
| 95 | - * |
|
| 96 | - * @return mixed |
|
| 97 | - * @access public |
|
| 98 | - */ |
|
| 99 | - function decode(){
|
|
| 100 | - return $this->value; |
|
| 101 | - } |
|
| 93 | + /** |
|
| 94 | + * decodes a soapval object into a PHP native type |
|
| 95 | + * |
|
| 96 | + * @return mixed |
|
| 97 | + * @access public |
|
| 98 | + */ |
|
| 99 | + function decode(){
|
|
| 100 | + return $this->value; |
|
| 101 | + } |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @param mixed $attributes associative array of attributes to add to element serialization |
| 70 | 70 | * @access public |
| 71 | 71 | */ |
| 72 | - function soapval($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) {
|
|
| 72 | + function soapval($name = 'soapval', $type = false, $value = -1, $element_ns = false, $type_ns = false, $attributes = false) {
|
|
| 73 | 73 | parent::nusoap_base(); |
| 74 | 74 | $this->name = $name; |
| 75 | 75 | $this->type = $type; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @return string XML data |
| 87 | 87 | * @access public |
| 88 | 88 | */ |
| 89 | - function serialize($use='encoded') {
|
|
| 89 | + function serialize($use = 'encoded') {
|
|
| 90 | 90 | return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @return mixed |
| 97 | 97 | * @access public |
| 98 | 98 | */ |
| 99 | - function decode(){
|
|
| 99 | + function decode() {
|
|
| 100 | 100 | return $this->value; |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -743,6 +743,7 @@ |
||
| 743 | 743 | /** |
| 744 | 744 | * dynamically creates proxy class code |
| 745 | 745 | * |
| 746 | + * @param integer $r |
|
| 746 | 747 | * @return string PHP/NuSOAP code for the proxy class |
| 747 | 748 | * @access private |
| 748 | 749 | */ |
@@ -25,967 +25,967 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | class nusoap_client extends nusoap_base {
|
| 27 | 27 | |
| 28 | - var $username = ''; // Username for HTTP authentication |
|
| 29 | - var $password = ''; // Password for HTTP authentication |
|
| 30 | - var $authtype = ''; // Type of HTTP authentication |
|
| 31 | - var $certRequest = array(); // Certificate for HTTP SSL authentication |
|
| 32 | - var $requestHeaders = false; // SOAP headers in request (text) |
|
| 33 | - var $responseHeaders = ''; // SOAP headers from response (incomplete namespace resolution) (text) |
|
| 34 | - var $responseHeader = NULL; // SOAP Header from response (parsed) |
|
| 35 | - var $document = ''; // SOAP body response portion (incomplete namespace resolution) (text) |
|
| 36 | - var $endpoint; |
|
| 37 | - var $forceEndpoint = ''; // overrides WSDL endpoint |
|
| 28 | + var $username = ''; // Username for HTTP authentication |
|
| 29 | + var $password = ''; // Password for HTTP authentication |
|
| 30 | + var $authtype = ''; // Type of HTTP authentication |
|
| 31 | + var $certRequest = array(); // Certificate for HTTP SSL authentication |
|
| 32 | + var $requestHeaders = false; // SOAP headers in request (text) |
|
| 33 | + var $responseHeaders = ''; // SOAP headers from response (incomplete namespace resolution) (text) |
|
| 34 | + var $responseHeader = NULL; // SOAP Header from response (parsed) |
|
| 35 | + var $document = ''; // SOAP body response portion (incomplete namespace resolution) (text) |
|
| 36 | + var $endpoint; |
|
| 37 | + var $forceEndpoint = ''; // overrides WSDL endpoint |
|
| 38 | 38 | var $proxyhost = ''; |
| 39 | 39 | var $proxyport = ''; |
| 40 | - var $proxyusername = ''; |
|
| 41 | - var $proxypassword = ''; |
|
| 42 | - var $portName = ''; // port name to use in WSDL |
|
| 40 | + var $proxyusername = ''; |
|
| 41 | + var $proxypassword = ''; |
|
| 42 | + var $portName = ''; // port name to use in WSDL |
|
| 43 | 43 | var $xml_encoding = ''; // character set encoding of incoming (response) messages |
| 44 | - var $http_encoding = false; |
|
| 45 | - var $timeout = 0; // HTTP connection timeout |
|
| 46 | - var $response_timeout = 30; // HTTP response timeout |
|
| 47 | - var $endpointType = ''; // soap|wsdl, empty for WSDL initialization error |
|
| 48 | - var $persistentConnection = false; |
|
| 49 | - var $defaultRpcParams = false; // This is no longer used |
|
| 50 | - var $request = ''; // HTTP request |
|
| 51 | - var $response = ''; // HTTP response |
|
| 52 | - var $responseData = ''; // SOAP payload of response |
|
| 53 | - var $cookies = array(); // Cookies from response or for request |
|
| 44 | + var $http_encoding = false; |
|
| 45 | + var $timeout = 0; // HTTP connection timeout |
|
| 46 | + var $response_timeout = 30; // HTTP response timeout |
|
| 47 | + var $endpointType = ''; // soap|wsdl, empty for WSDL initialization error |
|
| 48 | + var $persistentConnection = false; |
|
| 49 | + var $defaultRpcParams = false; // This is no longer used |
|
| 50 | + var $request = ''; // HTTP request |
|
| 51 | + var $response = ''; // HTTP response |
|
| 52 | + var $responseData = ''; // SOAP payload of response |
|
| 53 | + var $cookies = array(); // Cookies from response or for request |
|
| 54 | 54 | var $decode_utf8 = true; // toggles whether the parser decodes element content w/ utf8_decode() |
| 55 | - var $operations = array(); // WSDL operations, empty for WSDL initialization error |
|
| 56 | - var $curl_options = array(); // User-specified cURL options |
|
| 57 | - var $bindingType = ''; // WSDL operation binding type |
|
| 58 | - var $use_curl = false; // whether to always try to use cURL |
|
| 55 | + var $operations = array(); // WSDL operations, empty for WSDL initialization error |
|
| 56 | + var $curl_options = array(); // User-specified cURL options |
|
| 57 | + var $bindingType = ''; // WSDL operation binding type |
|
| 58 | + var $use_curl = false; // whether to always try to use cURL |
|
| 59 | 59 | |
| 60 | - /* |
|
| 60 | + /* |
|
| 61 | 61 | * fault related variables |
| 62 | 62 | */ |
| 63 | - /** |
|
| 64 | - * @var fault |
|
| 65 | - * @access public |
|
| 66 | - */ |
|
| 67 | - var $fault; |
|
| 68 | - /** |
|
| 69 | - * @var faultcode |
|
| 70 | - * @access public |
|
| 71 | - */ |
|
| 72 | - var $faultcode; |
|
| 73 | - /** |
|
| 74 | - * @var faultstring |
|
| 75 | - * @access public |
|
| 76 | - */ |
|
| 77 | - var $faultstring; |
|
| 78 | - /** |
|
| 79 | - * @var faultdetail |
|
| 80 | - * @access public |
|
| 81 | - */ |
|
| 82 | - var $faultdetail; |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * constructor |
|
| 86 | - * |
|
| 87 | - * @param mixed $endpoint SOAP server or WSDL URL (string), or wsdl instance (object) |
|
| 88 | - * @param mixed $wsdl optional, set to 'wsdl' or true if using WSDL |
|
| 89 | - * @param string $proxyhost optional |
|
| 90 | - * @param string $proxyport optional |
|
| 91 | - * @param string $proxyusername optional |
|
| 92 | - * @param string $proxypassword optional |
|
| 93 | - * @param integer $timeout set the connection timeout |
|
| 94 | - * @param integer $response_timeout set the response timeout |
|
| 95 | - * @param string $portName optional portName in WSDL document |
|
| 96 | - * @access public |
|
| 97 | - */ |
|
| 98 | - function nusoap_client($endpoint,$wsdl = false,$proxyhost = false,$proxyport = false,$proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = ''){
|
|
| 99 | - parent::nusoap_base(); |
|
| 100 | - $this->endpoint = $endpoint; |
|
| 101 | - $this->proxyhost = $proxyhost; |
|
| 102 | - $this->proxyport = $proxyport; |
|
| 103 | - $this->proxyusername = $proxyusername; |
|
| 104 | - $this->proxypassword = $proxypassword; |
|
| 105 | - $this->timeout = $timeout; |
|
| 106 | - $this->response_timeout = $response_timeout; |
|
| 107 | - $this->portName = $portName; |
|
| 108 | - |
|
| 109 | - $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
|
|
| 110 | - $this->appendDebug('endpoint=' . $this->varDump($endpoint));
|
|
| 111 | - |
|
| 112 | - // make values |
|
| 113 | - if($wsdl){
|
|
| 114 | - if (is_object($endpoint) && (get_class($endpoint) == 'wsdl')) {
|
|
| 115 | - $this->wsdl = $endpoint; |
|
| 116 | - $this->endpoint = $this->wsdl->wsdl; |
|
| 117 | - $this->wsdlFile = $this->endpoint; |
|
| 118 | - $this->debug('existing wsdl instance created from ' . $this->endpoint);
|
|
| 119 | - $this->checkWSDL(); |
|
| 120 | - } else {
|
|
| 121 | - $this->wsdlFile = $this->endpoint; |
|
| 122 | - $this->wsdl = null; |
|
| 123 | - $this->debug('will use lazy evaluation of wsdl from ' . $this->endpoint);
|
|
| 124 | - } |
|
| 125 | - $this->endpointType = 'wsdl'; |
|
| 126 | - } else {
|
|
| 127 | - $this->debug("instantiate SOAP with endpoint at $endpoint");
|
|
| 128 | - $this->endpointType = 'soap'; |
|
| 129 | - } |
|
| 130 | - } |
|
| 63 | + /** |
|
| 64 | + * @var fault |
|
| 65 | + * @access public |
|
| 66 | + */ |
|
| 67 | + var $fault; |
|
| 68 | + /** |
|
| 69 | + * @var faultcode |
|
| 70 | + * @access public |
|
| 71 | + */ |
|
| 72 | + var $faultcode; |
|
| 73 | + /** |
|
| 74 | + * @var faultstring |
|
| 75 | + * @access public |
|
| 76 | + */ |
|
| 77 | + var $faultstring; |
|
| 78 | + /** |
|
| 79 | + * @var faultdetail |
|
| 80 | + * @access public |
|
| 81 | + */ |
|
| 82 | + var $faultdetail; |
|
| 131 | 83 | |
| 132 | - /** |
|
| 133 | - * calls method, returns PHP native type |
|
| 134 | - * |
|
| 135 | - * @param string $operation SOAP server URL or path |
|
| 136 | - * @param mixed $params An array, associative or simple, of the parameters |
|
| 137 | - * for the method call, or a string that is the XML |
|
| 138 | - * for the call. For rpc style, this call will |
|
| 139 | - * wrap the XML in a tag named after the method, as |
|
| 140 | - * well as the SOAP Envelope and Body. For document |
|
| 141 | - * style, this will only wrap with the Envelope and Body. |
|
| 142 | - * IMPORTANT: when using an array with document style, |
|
| 143 | - * in which case there |
|
| 144 | - * is really one parameter, the root of the fragment |
|
| 145 | - * used in the call, which encloses what programmers |
|
| 146 | - * normally think of parameters. A parameter array |
|
| 147 | - * *must* include the wrapper. |
|
| 148 | - * @param string $namespace optional method namespace (WSDL can override) |
|
| 149 | - * @param string $soapAction optional SOAPAction value (WSDL can override) |
|
| 150 | - * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array |
|
| 151 | - * @param boolean $rpcParams optional (no longer used) |
|
| 152 | - * @param string $style optional (rpc|document) the style to use when serializing parameters (WSDL can override) |
|
| 153 | - * @param string $use optional (encoded|literal) the use when serializing parameters (WSDL can override) |
|
| 154 | - * @return mixed response from SOAP call, normally an associative array mirroring the structure of the XML response, false for certain fatal errors |
|
| 155 | - * @access public |
|
| 156 | - */ |
|
| 157 | - function call($operation,$params=array(),$namespace='http://tempuri.org',$soapAction='',$headers=false,$rpcParams=null,$style='rpc',$use='encoded'){
|
|
| 158 | - $this->operation = $operation; |
|
| 159 | - $this->fault = false; |
|
| 160 | - $this->setError('');
|
|
| 161 | - $this->request = ''; |
|
| 162 | - $this->response = ''; |
|
| 163 | - $this->responseData = ''; |
|
| 164 | - $this->faultstring = ''; |
|
| 165 | - $this->faultcode = ''; |
|
| 166 | - $this->opData = array(); |
|
| 84 | + /** |
|
| 85 | + * constructor |
|
| 86 | + * |
|
| 87 | + * @param mixed $endpoint SOAP server or WSDL URL (string), or wsdl instance (object) |
|
| 88 | + * @param mixed $wsdl optional, set to 'wsdl' or true if using WSDL |
|
| 89 | + * @param string $proxyhost optional |
|
| 90 | + * @param string $proxyport optional |
|
| 91 | + * @param string $proxyusername optional |
|
| 92 | + * @param string $proxypassword optional |
|
| 93 | + * @param integer $timeout set the connection timeout |
|
| 94 | + * @param integer $response_timeout set the response timeout |
|
| 95 | + * @param string $portName optional portName in WSDL document |
|
| 96 | + * @access public |
|
| 97 | + */ |
|
| 98 | + function nusoap_client($endpoint,$wsdl = false,$proxyhost = false,$proxyport = false,$proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = ''){
|
|
| 99 | + parent::nusoap_base(); |
|
| 100 | + $this->endpoint = $endpoint; |
|
| 101 | + $this->proxyhost = $proxyhost; |
|
| 102 | + $this->proxyport = $proxyport; |
|
| 103 | + $this->proxyusername = $proxyusername; |
|
| 104 | + $this->proxypassword = $proxypassword; |
|
| 105 | + $this->timeout = $timeout; |
|
| 106 | + $this->response_timeout = $response_timeout; |
|
| 107 | + $this->portName = $portName; |
|
| 108 | + |
|
| 109 | + $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
|
|
| 110 | + $this->appendDebug('endpoint=' . $this->varDump($endpoint));
|
|
| 111 | + |
|
| 112 | + // make values |
|
| 113 | + if($wsdl){
|
|
| 114 | + if (is_object($endpoint) && (get_class($endpoint) == 'wsdl')) {
|
|
| 115 | + $this->wsdl = $endpoint; |
|
| 116 | + $this->endpoint = $this->wsdl->wsdl; |
|
| 117 | + $this->wsdlFile = $this->endpoint; |
|
| 118 | + $this->debug('existing wsdl instance created from ' . $this->endpoint);
|
|
| 119 | + $this->checkWSDL(); |
|
| 120 | + } else {
|
|
| 121 | + $this->wsdlFile = $this->endpoint; |
|
| 122 | + $this->wsdl = null; |
|
| 123 | + $this->debug('will use lazy evaluation of wsdl from ' . $this->endpoint);
|
|
| 124 | + } |
|
| 125 | + $this->endpointType = 'wsdl'; |
|
| 126 | + } else {
|
|
| 127 | + $this->debug("instantiate SOAP with endpoint at $endpoint");
|
|
| 128 | + $this->endpointType = 'soap'; |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * calls method, returns PHP native type |
|
| 134 | + * |
|
| 135 | + * @param string $operation SOAP server URL or path |
|
| 136 | + * @param mixed $params An array, associative or simple, of the parameters |
|
| 137 | + * for the method call, or a string that is the XML |
|
| 138 | + * for the call. For rpc style, this call will |
|
| 139 | + * wrap the XML in a tag named after the method, as |
|
| 140 | + * well as the SOAP Envelope and Body. For document |
|
| 141 | + * style, this will only wrap with the Envelope and Body. |
|
| 142 | + * IMPORTANT: when using an array with document style, |
|
| 143 | + * in which case there |
|
| 144 | + * is really one parameter, the root of the fragment |
|
| 145 | + * used in the call, which encloses what programmers |
|
| 146 | + * normally think of parameters. A parameter array |
|
| 147 | + * *must* include the wrapper. |
|
| 148 | + * @param string $namespace optional method namespace (WSDL can override) |
|
| 149 | + * @param string $soapAction optional SOAPAction value (WSDL can override) |
|
| 150 | + * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array |
|
| 151 | + * @param boolean $rpcParams optional (no longer used) |
|
| 152 | + * @param string $style optional (rpc|document) the style to use when serializing parameters (WSDL can override) |
|
| 153 | + * @param string $use optional (encoded|literal) the use when serializing parameters (WSDL can override) |
|
| 154 | + * @return mixed response from SOAP call, normally an associative array mirroring the structure of the XML response, false for certain fatal errors |
|
| 155 | + * @access public |
|
| 156 | + */ |
|
| 157 | + function call($operation,$params=array(),$namespace='http://tempuri.org',$soapAction='',$headers=false,$rpcParams=null,$style='rpc',$use='encoded'){
|
|
| 158 | + $this->operation = $operation; |
|
| 159 | + $this->fault = false; |
|
| 160 | + $this->setError('');
|
|
| 161 | + $this->request = ''; |
|
| 162 | + $this->response = ''; |
|
| 163 | + $this->responseData = ''; |
|
| 164 | + $this->faultstring = ''; |
|
| 165 | + $this->faultcode = ''; |
|
| 166 | + $this->opData = array(); |
|
| 167 | 167 | |
| 168 | - $this->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType");
|
|
| 169 | - $this->appendDebug('params=' . $this->varDump($params));
|
|
| 170 | - $this->appendDebug('headers=' . $this->varDump($headers));
|
|
| 171 | - if ($headers) {
|
|
| 172 | - $this->requestHeaders = $headers; |
|
| 173 | - } |
|
| 174 | - if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
|
|
| 175 | - $this->loadWSDL(); |
|
| 176 | - if ($this->getError()) |
|
| 177 | - return false; |
|
| 178 | - } |
|
| 179 | - // serialize parameters |
|
| 180 | - if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){
|
|
| 181 | - // use WSDL for operation |
|
| 182 | - $this->opData = $opData; |
|
| 183 | - $this->debug("found operation");
|
|
| 184 | - $this->appendDebug('opData=' . $this->varDump($opData));
|
|
| 185 | - if (isset($opData['soapAction'])) {
|
|
| 186 | - $soapAction = $opData['soapAction']; |
|
| 187 | - } |
|
| 188 | - if (! $this->forceEndpoint) {
|
|
| 189 | - $this->endpoint = $opData['endpoint']; |
|
| 190 | - } else {
|
|
| 191 | - $this->endpoint = $this->forceEndpoint; |
|
| 192 | - } |
|
| 193 | - $namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] : $namespace; |
|
| 194 | - $style = $opData['style']; |
|
| 195 | - $use = $opData['input']['use']; |
|
| 196 | - // add ns to ns array |
|
| 197 | - if($namespace != '' && !isset($this->wsdl->namespaces[$namespace])){
|
|
| 198 | - $nsPrefix = 'ns' . rand(1000, 9999); |
|
| 199 | - $this->wsdl->namespaces[$nsPrefix] = $namespace; |
|
| 200 | - } |
|
| 168 | + $this->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType");
|
|
| 169 | + $this->appendDebug('params=' . $this->varDump($params));
|
|
| 170 | + $this->appendDebug('headers=' . $this->varDump($headers));
|
|
| 171 | + if ($headers) {
|
|
| 172 | + $this->requestHeaders = $headers; |
|
| 173 | + } |
|
| 174 | + if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
|
|
| 175 | + $this->loadWSDL(); |
|
| 176 | + if ($this->getError()) |
|
| 177 | + return false; |
|
| 178 | + } |
|
| 179 | + // serialize parameters |
|
| 180 | + if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){
|
|
| 181 | + // use WSDL for operation |
|
| 182 | + $this->opData = $opData; |
|
| 183 | + $this->debug("found operation");
|
|
| 184 | + $this->appendDebug('opData=' . $this->varDump($opData));
|
|
| 185 | + if (isset($opData['soapAction'])) {
|
|
| 186 | + $soapAction = $opData['soapAction']; |
|
| 187 | + } |
|
| 188 | + if (! $this->forceEndpoint) {
|
|
| 189 | + $this->endpoint = $opData['endpoint']; |
|
| 190 | + } else {
|
|
| 191 | + $this->endpoint = $this->forceEndpoint; |
|
| 192 | + } |
|
| 193 | + $namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] : $namespace; |
|
| 194 | + $style = $opData['style']; |
|
| 195 | + $use = $opData['input']['use']; |
|
| 196 | + // add ns to ns array |
|
| 197 | + if($namespace != '' && !isset($this->wsdl->namespaces[$namespace])){
|
|
| 198 | + $nsPrefix = 'ns' . rand(1000, 9999); |
|
| 199 | + $this->wsdl->namespaces[$nsPrefix] = $namespace; |
|
| 200 | + } |
|
| 201 | 201 | $nsPrefix = $this->wsdl->getPrefixFromNamespace($namespace); |
| 202 | - // serialize payload |
|
| 203 | - if (is_string($params)) {
|
|
| 204 | - $this->debug("serializing param string for WSDL operation $operation");
|
|
| 205 | - $payload = $params; |
|
| 206 | - } elseif (is_array($params)) {
|
|
| 207 | - $this->debug("serializing param array for WSDL operation $operation");
|
|
| 208 | - $payload = $this->wsdl->serializeRPCParameters($operation,'input',$params,$this->bindingType); |
|
| 209 | - } else {
|
|
| 210 | - $this->debug('params must be array or string');
|
|
| 211 | - $this->setError('params must be array or string');
|
|
| 212 | - return false; |
|
| 213 | - } |
|
| 202 | + // serialize payload |
|
| 203 | + if (is_string($params)) {
|
|
| 204 | + $this->debug("serializing param string for WSDL operation $operation");
|
|
| 205 | + $payload = $params; |
|
| 206 | + } elseif (is_array($params)) {
|
|
| 207 | + $this->debug("serializing param array for WSDL operation $operation");
|
|
| 208 | + $payload = $this->wsdl->serializeRPCParameters($operation,'input',$params,$this->bindingType); |
|
| 209 | + } else {
|
|
| 210 | + $this->debug('params must be array or string');
|
|
| 211 | + $this->setError('params must be array or string');
|
|
| 212 | + return false; |
|
| 213 | + } |
|
| 214 | 214 | $usedNamespaces = $this->wsdl->usedNamespaces; |
| 215 | - if (isset($opData['input']['encodingStyle'])) {
|
|
| 216 | - $encodingStyle = $opData['input']['encodingStyle']; |
|
| 217 | - } else {
|
|
| 218 | - $encodingStyle = ''; |
|
| 219 | - } |
|
| 220 | - $this->appendDebug($this->wsdl->getDebug()); |
|
| 221 | - $this->wsdl->clearDebug(); |
|
| 222 | - if ($errstr = $this->wsdl->getError()) {
|
|
| 223 | - $this->debug('got wsdl error: '.$errstr);
|
|
| 224 | - $this->setError('wsdl error: '.$errstr);
|
|
| 225 | - return false; |
|
| 226 | - } |
|
| 227 | - } elseif($this->endpointType == 'wsdl') {
|
|
| 228 | - // operation not in WSDL |
|
| 229 | - $this->appendDebug($this->wsdl->getDebug()); |
|
| 230 | - $this->wsdl->clearDebug(); |
|
| 231 | - $this->setError('operation '.$operation.' not present in WSDL.');
|
|
| 232 | - $this->debug("operation '$operation' not present in WSDL.");
|
|
| 233 | - return false; |
|
| 234 | - } else {
|
|
| 235 | - // no WSDL |
|
| 236 | - //$this->namespaces['ns1'] = $namespace; |
|
| 237 | - $nsPrefix = 'ns' . rand(1000, 9999); |
|
| 238 | - // serialize |
|
| 239 | - $payload = ''; |
|
| 240 | - if (is_string($params)) {
|
|
| 241 | - $this->debug("serializing param string for operation $operation");
|
|
| 242 | - $payload = $params; |
|
| 243 | - } elseif (is_array($params)) {
|
|
| 244 | - $this->debug("serializing param array for operation $operation");
|
|
| 245 | - foreach($params as $k => $v){
|
|
| 246 | - $payload .= $this->serialize_val($v,$k,false,false,false,false,$use); |
|
| 247 | - } |
|
| 248 | - } else {
|
|
| 249 | - $this->debug('params must be array or string');
|
|
| 250 | - $this->setError('params must be array or string');
|
|
| 251 | - return false; |
|
| 252 | - } |
|
| 253 | - $usedNamespaces = array(); |
|
| 254 | - if ($use == 'encoded') {
|
|
| 255 | - $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; |
|
| 256 | - } else {
|
|
| 257 | - $encodingStyle = ''; |
|
| 258 | - } |
|
| 259 | - } |
|
| 260 | - // wrap RPC calls with method element |
|
| 261 | - if ($style == 'rpc') {
|
|
| 262 | - if ($use == 'literal') {
|
|
| 263 | - $this->debug("wrapping RPC request with literal method element");
|
|
| 264 | - if ($namespace) {
|
|
| 265 | - // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace |
|
| 266 | - $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . |
|
| 267 | - $payload . |
|
| 268 | - "</$nsPrefix:$operation>"; |
|
| 269 | - } else {
|
|
| 270 | - $payload = "<$operation>" . $payload . "</$operation>"; |
|
| 271 | - } |
|
| 272 | - } else {
|
|
| 273 | - $this->debug("wrapping RPC request with encoded method element");
|
|
| 274 | - if ($namespace) {
|
|
| 275 | - $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . |
|
| 276 | - $payload . |
|
| 277 | - "</$nsPrefix:$operation>"; |
|
| 278 | - } else {
|
|
| 279 | - $payload = "<$operation>" . |
|
| 280 | - $payload . |
|
| 281 | - "</$operation>"; |
|
| 282 | - } |
|
| 283 | - } |
|
| 284 | - } |
|
| 285 | - // serialize envelope |
|
| 286 | - $soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders,$usedNamespaces,$style,$use,$encodingStyle); |
|
| 287 | - $this->debug("endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style, use=$use, encodingStyle=$encodingStyle");
|
|
| 288 | - $this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000));
|
|
| 289 | - // send |
|
| 290 | - $return = $this->send($this->getHTTPBody($soapmsg),$soapAction,$this->timeout,$this->response_timeout); |
|
| 291 | - if($errstr = $this->getError()){
|
|
| 292 | - $this->debug('Error: '.$errstr);
|
|
| 293 | - return false; |
|
| 294 | - } else {
|
|
| 295 | - $this->return = $return; |
|
| 296 | - $this->debug('sent message successfully and got a(n) '.gettype($return));
|
|
| 297 | - $this->appendDebug('return=' . $this->varDump($return));
|
|
| 215 | + if (isset($opData['input']['encodingStyle'])) {
|
|
| 216 | + $encodingStyle = $opData['input']['encodingStyle']; |
|
| 217 | + } else {
|
|
| 218 | + $encodingStyle = ''; |
|
| 219 | + } |
|
| 220 | + $this->appendDebug($this->wsdl->getDebug()); |
|
| 221 | + $this->wsdl->clearDebug(); |
|
| 222 | + if ($errstr = $this->wsdl->getError()) {
|
|
| 223 | + $this->debug('got wsdl error: '.$errstr);
|
|
| 224 | + $this->setError('wsdl error: '.$errstr);
|
|
| 225 | + return false; |
|
| 226 | + } |
|
| 227 | + } elseif($this->endpointType == 'wsdl') {
|
|
| 228 | + // operation not in WSDL |
|
| 229 | + $this->appendDebug($this->wsdl->getDebug()); |
|
| 230 | + $this->wsdl->clearDebug(); |
|
| 231 | + $this->setError('operation '.$operation.' not present in WSDL.');
|
|
| 232 | + $this->debug("operation '$operation' not present in WSDL.");
|
|
| 233 | + return false; |
|
| 234 | + } else {
|
|
| 235 | + // no WSDL |
|
| 236 | + //$this->namespaces['ns1'] = $namespace; |
|
| 237 | + $nsPrefix = 'ns' . rand(1000, 9999); |
|
| 238 | + // serialize |
|
| 239 | + $payload = ''; |
|
| 240 | + if (is_string($params)) {
|
|
| 241 | + $this->debug("serializing param string for operation $operation");
|
|
| 242 | + $payload = $params; |
|
| 243 | + } elseif (is_array($params)) {
|
|
| 244 | + $this->debug("serializing param array for operation $operation");
|
|
| 245 | + foreach($params as $k => $v){
|
|
| 246 | + $payload .= $this->serialize_val($v,$k,false,false,false,false,$use); |
|
| 247 | + } |
|
| 248 | + } else {
|
|
| 249 | + $this->debug('params must be array or string');
|
|
| 250 | + $this->setError('params must be array or string');
|
|
| 251 | + return false; |
|
| 252 | + } |
|
| 253 | + $usedNamespaces = array(); |
|
| 254 | + if ($use == 'encoded') {
|
|
| 255 | + $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; |
|
| 256 | + } else {
|
|
| 257 | + $encodingStyle = ''; |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | + // wrap RPC calls with method element |
|
| 261 | + if ($style == 'rpc') {
|
|
| 262 | + if ($use == 'literal') {
|
|
| 263 | + $this->debug("wrapping RPC request with literal method element");
|
|
| 264 | + if ($namespace) {
|
|
| 265 | + // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace |
|
| 266 | + $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . |
|
| 267 | + $payload . |
|
| 268 | + "</$nsPrefix:$operation>"; |
|
| 269 | + } else {
|
|
| 270 | + $payload = "<$operation>" . $payload . "</$operation>"; |
|
| 271 | + } |
|
| 272 | + } else {
|
|
| 273 | + $this->debug("wrapping RPC request with encoded method element");
|
|
| 274 | + if ($namespace) {
|
|
| 275 | + $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . |
|
| 276 | + $payload . |
|
| 277 | + "</$nsPrefix:$operation>"; |
|
| 278 | + } else {
|
|
| 279 | + $payload = "<$operation>" . |
|
| 280 | + $payload . |
|
| 281 | + "</$operation>"; |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | + // serialize envelope |
|
| 286 | + $soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders,$usedNamespaces,$style,$use,$encodingStyle); |
|
| 287 | + $this->debug("endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style, use=$use, encodingStyle=$encodingStyle");
|
|
| 288 | + $this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000));
|
|
| 289 | + // send |
|
| 290 | + $return = $this->send($this->getHTTPBody($soapmsg),$soapAction,$this->timeout,$this->response_timeout); |
|
| 291 | + if($errstr = $this->getError()){
|
|
| 292 | + $this->debug('Error: '.$errstr);
|
|
| 293 | + return false; |
|
| 294 | + } else {
|
|
| 295 | + $this->return = $return; |
|
| 296 | + $this->debug('sent message successfully and got a(n) '.gettype($return));
|
|
| 297 | + $this->appendDebug('return=' . $this->varDump($return));
|
|
| 298 | 298 | |
| 299 | - // fault? |
|
| 300 | - if(is_array($return) && isset($return['faultcode'])){
|
|
| 301 | - $this->debug('got fault');
|
|
| 302 | - $this->setError($return['faultcode'].': '.$return['faultstring']); |
|
| 303 | - $this->fault = true; |
|
| 304 | - foreach($return as $k => $v){
|
|
| 305 | - $this->$k = $v; |
|
| 306 | - $this->debug("$k = $v<br>");
|
|
| 307 | - } |
|
| 308 | - return $return; |
|
| 309 | - } elseif ($style == 'document') {
|
|
| 310 | - // NOTE: if the response is defined to have multiple parts (i.e. unwrapped), |
|
| 311 | - // we are only going to return the first part here...sorry about that |
|
| 312 | - return $return; |
|
| 313 | - } else {
|
|
| 314 | - // array of return values |
|
| 315 | - if(is_array($return)){
|
|
| 316 | - // multiple 'out' parameters, which we return wrapped up |
|
| 317 | - // in the array |
|
| 318 | - if(sizeof($return) > 1){
|
|
| 319 | - return $return; |
|
| 320 | - } |
|
| 321 | - // single 'out' parameter (normally the return value) |
|
| 322 | - $return = array_shift($return); |
|
| 323 | - $this->debug('return shifted value: ');
|
|
| 324 | - $this->appendDebug($this->varDump($return)); |
|
| 325 | - return $return; |
|
| 326 | - // nothing returned (ie, echoVoid) |
|
| 327 | - } else {
|
|
| 328 | - return ""; |
|
| 329 | - } |
|
| 330 | - } |
|
| 331 | - } |
|
| 332 | - } |
|
| 299 | + // fault? |
|
| 300 | + if(is_array($return) && isset($return['faultcode'])){
|
|
| 301 | + $this->debug('got fault');
|
|
| 302 | + $this->setError($return['faultcode'].': '.$return['faultstring']); |
|
| 303 | + $this->fault = true; |
|
| 304 | + foreach($return as $k => $v){
|
|
| 305 | + $this->$k = $v; |
|
| 306 | + $this->debug("$k = $v<br>");
|
|
| 307 | + } |
|
| 308 | + return $return; |
|
| 309 | + } elseif ($style == 'document') {
|
|
| 310 | + // NOTE: if the response is defined to have multiple parts (i.e. unwrapped), |
|
| 311 | + // we are only going to return the first part here...sorry about that |
|
| 312 | + return $return; |
|
| 313 | + } else {
|
|
| 314 | + // array of return values |
|
| 315 | + if(is_array($return)){
|
|
| 316 | + // multiple 'out' parameters, which we return wrapped up |
|
| 317 | + // in the array |
|
| 318 | + if(sizeof($return) > 1){
|
|
| 319 | + return $return; |
|
| 320 | + } |
|
| 321 | + // single 'out' parameter (normally the return value) |
|
| 322 | + $return = array_shift($return); |
|
| 323 | + $this->debug('return shifted value: ');
|
|
| 324 | + $this->appendDebug($this->varDump($return)); |
|
| 325 | + return $return; |
|
| 326 | + // nothing returned (ie, echoVoid) |
|
| 327 | + } else {
|
|
| 328 | + return ""; |
|
| 329 | + } |
|
| 330 | + } |
|
| 331 | + } |
|
| 332 | + } |
|
| 333 | 333 | |
| 334 | - /** |
|
| 335 | - * check WSDL passed as an instance or pulled from an endpoint |
|
| 336 | - * |
|
| 337 | - * @access private |
|
| 338 | - */ |
|
| 339 | - function checkWSDL() {
|
|
| 340 | - $this->appendDebug($this->wsdl->getDebug()); |
|
| 341 | - $this->wsdl->clearDebug(); |
|
| 342 | - $this->debug('checkWSDL');
|
|
| 343 | - // catch errors |
|
| 344 | - if ($errstr = $this->wsdl->getError()) {
|
|
| 345 | - $this->appendDebug($this->wsdl->getDebug()); |
|
| 346 | - $this->wsdl->clearDebug(); |
|
| 347 | - $this->debug('got wsdl error: '.$errstr);
|
|
| 348 | - $this->setError('wsdl error: '.$errstr);
|
|
| 349 | - } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap')) {
|
|
| 350 | - $this->appendDebug($this->wsdl->getDebug()); |
|
| 351 | - $this->wsdl->clearDebug(); |
|
| 352 | - $this->bindingType = 'soap'; |
|
| 353 | - $this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType);
|
|
| 354 | - } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap12')) {
|
|
| 355 | - $this->appendDebug($this->wsdl->getDebug()); |
|
| 356 | - $this->wsdl->clearDebug(); |
|
| 357 | - $this->bindingType = 'soap12'; |
|
| 358 | - $this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType);
|
|
| 359 | - $this->debug('**************** WARNING: SOAP 1.2 BINDING *****************');
|
|
| 360 | - } else {
|
|
| 361 | - $this->appendDebug($this->wsdl->getDebug()); |
|
| 362 | - $this->wsdl->clearDebug(); |
|
| 363 | - $this->debug('getOperations returned false');
|
|
| 364 | - $this->setError('no operations defined in the WSDL document!');
|
|
| 365 | - } |
|
| 366 | - } |
|
| 334 | + /** |
|
| 335 | + * check WSDL passed as an instance or pulled from an endpoint |
|
| 336 | + * |
|
| 337 | + * @access private |
|
| 338 | + */ |
|
| 339 | + function checkWSDL() {
|
|
| 340 | + $this->appendDebug($this->wsdl->getDebug()); |
|
| 341 | + $this->wsdl->clearDebug(); |
|
| 342 | + $this->debug('checkWSDL');
|
|
| 343 | + // catch errors |
|
| 344 | + if ($errstr = $this->wsdl->getError()) {
|
|
| 345 | + $this->appendDebug($this->wsdl->getDebug()); |
|
| 346 | + $this->wsdl->clearDebug(); |
|
| 347 | + $this->debug('got wsdl error: '.$errstr);
|
|
| 348 | + $this->setError('wsdl error: '.$errstr);
|
|
| 349 | + } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap')) {
|
|
| 350 | + $this->appendDebug($this->wsdl->getDebug()); |
|
| 351 | + $this->wsdl->clearDebug(); |
|
| 352 | + $this->bindingType = 'soap'; |
|
| 353 | + $this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType);
|
|
| 354 | + } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap12')) {
|
|
| 355 | + $this->appendDebug($this->wsdl->getDebug()); |
|
| 356 | + $this->wsdl->clearDebug(); |
|
| 357 | + $this->bindingType = 'soap12'; |
|
| 358 | + $this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType);
|
|
| 359 | + $this->debug('**************** WARNING: SOAP 1.2 BINDING *****************');
|
|
| 360 | + } else {
|
|
| 361 | + $this->appendDebug($this->wsdl->getDebug()); |
|
| 362 | + $this->wsdl->clearDebug(); |
|
| 363 | + $this->debug('getOperations returned false');
|
|
| 364 | + $this->setError('no operations defined in the WSDL document!');
|
|
| 365 | + } |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | - /** |
|
| 369 | - * instantiate wsdl object and parse wsdl file |
|
| 370 | - * |
|
| 371 | - * @access public |
|
| 372 | - */ |
|
| 373 | - function loadWSDL() {
|
|
| 374 | - $this->debug('instantiating wsdl class with doc: '.$this->wsdlFile);
|
|
| 375 | - $this->wsdl = new wsdl('',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout,$this->curl_options,$this->use_curl);
|
|
| 376 | - $this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest); |
|
| 377 | - $this->wsdl->fetchWSDL($this->wsdlFile); |
|
| 378 | - $this->checkWSDL(); |
|
| 379 | - } |
|
| 368 | + /** |
|
| 369 | + * instantiate wsdl object and parse wsdl file |
|
| 370 | + * |
|
| 371 | + * @access public |
|
| 372 | + */ |
|
| 373 | + function loadWSDL() {
|
|
| 374 | + $this->debug('instantiating wsdl class with doc: '.$this->wsdlFile);
|
|
| 375 | + $this->wsdl = new wsdl('',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout,$this->curl_options,$this->use_curl);
|
|
| 376 | + $this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest); |
|
| 377 | + $this->wsdl->fetchWSDL($this->wsdlFile); |
|
| 378 | + $this->checkWSDL(); |
|
| 379 | + } |
|
| 380 | 380 | |
| 381 | - /** |
|
| 382 | - * get available data pertaining to an operation |
|
| 383 | - * |
|
| 384 | - * @param string $operation operation name |
|
| 385 | - * @return array array of data pertaining to the operation |
|
| 386 | - * @access public |
|
| 387 | - */ |
|
| 388 | - function getOperationData($operation){
|
|
| 389 | - if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
|
|
| 390 | - $this->loadWSDL(); |
|
| 391 | - if ($this->getError()) |
|
| 392 | - return false; |
|
| 393 | - } |
|
| 394 | - if(isset($this->operations[$operation])){
|
|
| 395 | - return $this->operations[$operation]; |
|
| 396 | - } |
|
| 397 | - $this->debug("No data for operation: $operation");
|
|
| 398 | - } |
|
| 381 | + /** |
|
| 382 | + * get available data pertaining to an operation |
|
| 383 | + * |
|
| 384 | + * @param string $operation operation name |
|
| 385 | + * @return array array of data pertaining to the operation |
|
| 386 | + * @access public |
|
| 387 | + */ |
|
| 388 | + function getOperationData($operation){
|
|
| 389 | + if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
|
|
| 390 | + $this->loadWSDL(); |
|
| 391 | + if ($this->getError()) |
|
| 392 | + return false; |
|
| 393 | + } |
|
| 394 | + if(isset($this->operations[$operation])){
|
|
| 395 | + return $this->operations[$operation]; |
|
| 396 | + } |
|
| 397 | + $this->debug("No data for operation: $operation");
|
|
| 398 | + } |
|
| 399 | 399 | |
| 400 | 400 | /** |
| 401 | - * send the SOAP message |
|
| 402 | - * |
|
| 403 | - * Note: if the operation has multiple return values |
|
| 404 | - * the return value of this method will be an array |
|
| 405 | - * of those values. |
|
| 406 | - * |
|
| 407 | - * @param string $msg a SOAPx4 soapmsg object |
|
| 408 | - * @param string $soapaction SOAPAction value |
|
| 409 | - * @param integer $timeout set connection timeout in seconds |
|
| 410 | - * @param integer $response_timeout set response timeout in seconds |
|
| 411 | - * @return mixed native PHP types. |
|
| 412 | - * @access private |
|
| 413 | - */ |
|
| 414 | - function send($msg, $soapaction = '', $timeout=0, $response_timeout=30) {
|
|
| 415 | - $this->checkCookies(); |
|
| 416 | - // detect transport |
|
| 417 | - switch(true){
|
|
| 418 | - // http(s) |
|
| 419 | - case preg_match('/^http/',$this->endpoint):
|
|
| 420 | - $this->debug('transporting via HTTP');
|
|
| 421 | - if($this->persistentConnection == true && is_object($this->persistentConnection)){
|
|
| 422 | - $http =& $this->persistentConnection; |
|
| 423 | - } else {
|
|
| 424 | - $http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl); |
|
| 425 | - if ($this->persistentConnection) {
|
|
| 426 | - $http->usePersistentConnection(); |
|
| 427 | - } |
|
| 428 | - } |
|
| 429 | - $http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset()); |
|
| 430 | - $http->setSOAPAction($soapaction); |
|
| 431 | - if($this->proxyhost && $this->proxyport){
|
|
| 432 | - $http->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword); |
|
| 433 | - } |
|
| 401 | + * send the SOAP message |
|
| 402 | + * |
|
| 403 | + * Note: if the operation has multiple return values |
|
| 404 | + * the return value of this method will be an array |
|
| 405 | + * of those values. |
|
| 406 | + * |
|
| 407 | + * @param string $msg a SOAPx4 soapmsg object |
|
| 408 | + * @param string $soapaction SOAPAction value |
|
| 409 | + * @param integer $timeout set connection timeout in seconds |
|
| 410 | + * @param integer $response_timeout set response timeout in seconds |
|
| 411 | + * @return mixed native PHP types. |
|
| 412 | + * @access private |
|
| 413 | + */ |
|
| 414 | + function send($msg, $soapaction = '', $timeout=0, $response_timeout=30) {
|
|
| 415 | + $this->checkCookies(); |
|
| 416 | + // detect transport |
|
| 417 | + switch(true){
|
|
| 418 | + // http(s) |
|
| 419 | + case preg_match('/^http/',$this->endpoint):
|
|
| 420 | + $this->debug('transporting via HTTP');
|
|
| 421 | + if($this->persistentConnection == true && is_object($this->persistentConnection)){
|
|
| 422 | + $http =& $this->persistentConnection; |
|
| 423 | + } else {
|
|
| 424 | + $http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl); |
|
| 425 | + if ($this->persistentConnection) {
|
|
| 426 | + $http->usePersistentConnection(); |
|
| 427 | + } |
|
| 428 | + } |
|
| 429 | + $http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset()); |
|
| 430 | + $http->setSOAPAction($soapaction); |
|
| 431 | + if($this->proxyhost && $this->proxyport){
|
|
| 432 | + $http->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword); |
|
| 433 | + } |
|
| 434 | 434 | if($this->authtype != '') {
|
| 435 | - $http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest); |
|
| 436 | - } |
|
| 437 | - if($this->http_encoding != ''){
|
|
| 438 | - $http->setEncoding($this->http_encoding); |
|
| 439 | - } |
|
| 440 | - $this->debug('sending message, length='.strlen($msg));
|
|
| 441 | - if(preg_match('/^http:/',$this->endpoint)){
|
|
| 442 | - //if(strpos($this->endpoint,'http:')){
|
|
| 443 | - $this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies); |
|
| 444 | - } elseif(preg_match('/^https/',$this->endpoint)){
|
|
| 445 | - //} elseif(strpos($this->endpoint,'https:')){
|
|
| 446 | - //if(phpversion() == '4.3.0-dev'){
|
|
| 447 | - //$response = $http->send($msg,$timeout,$response_timeout); |
|
| 448 | - //$this->request = $http->outgoing_payload; |
|
| 449 | - //$this->response = $http->incoming_payload; |
|
| 450 | - //} else |
|
| 451 | - $this->responseData = $http->sendHTTPS($msg,$timeout,$response_timeout,$this->cookies); |
|
| 452 | - } else {
|
|
| 453 | - $this->setError('no http/s in endpoint url');
|
|
| 454 | - } |
|
| 455 | - $this->request = $http->outgoing_payload; |
|
| 456 | - $this->response = $http->incoming_payload; |
|
| 457 | - $this->appendDebug($http->getDebug()); |
|
| 458 | - $this->UpdateCookies($http->incoming_cookies); |
|
| 459 | - |
|
| 460 | - // save transport object if using persistent connections |
|
| 461 | - if ($this->persistentConnection) {
|
|
| 462 | - $http->clearDebug(); |
|
| 463 | - if (!is_object($this->persistentConnection)) {
|
|
| 464 | - $this->persistentConnection = $http; |
|
| 465 | - } |
|
| 466 | - } |
|
| 435 | + $http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest); |
|
| 436 | + } |
|
| 437 | + if($this->http_encoding != ''){
|
|
| 438 | + $http->setEncoding($this->http_encoding); |
|
| 439 | + } |
|
| 440 | + $this->debug('sending message, length='.strlen($msg));
|
|
| 441 | + if(preg_match('/^http:/',$this->endpoint)){
|
|
| 442 | + //if(strpos($this->endpoint,'http:')){
|
|
| 443 | + $this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies); |
|
| 444 | + } elseif(preg_match('/^https/',$this->endpoint)){
|
|
| 445 | + //} elseif(strpos($this->endpoint,'https:')){
|
|
| 446 | + //if(phpversion() == '4.3.0-dev'){
|
|
| 447 | + //$response = $http->send($msg,$timeout,$response_timeout); |
|
| 448 | + //$this->request = $http->outgoing_payload; |
|
| 449 | + //$this->response = $http->incoming_payload; |
|
| 450 | + //} else |
|
| 451 | + $this->responseData = $http->sendHTTPS($msg,$timeout,$response_timeout,$this->cookies); |
|
| 452 | + } else {
|
|
| 453 | + $this->setError('no http/s in endpoint url');
|
|
| 454 | + } |
|
| 455 | + $this->request = $http->outgoing_payload; |
|
| 456 | + $this->response = $http->incoming_payload; |
|
| 457 | + $this->appendDebug($http->getDebug()); |
|
| 458 | + $this->UpdateCookies($http->incoming_cookies); |
|
| 459 | + |
|
| 460 | + // save transport object if using persistent connections |
|
| 461 | + if ($this->persistentConnection) {
|
|
| 462 | + $http->clearDebug(); |
|
| 463 | + if (!is_object($this->persistentConnection)) {
|
|
| 464 | + $this->persistentConnection = $http; |
|
| 465 | + } |
|
| 466 | + } |
|
| 467 | 467 | |
| 468 | - if($err = $http->getError()){
|
|
| 469 | - $this->setError('HTTP Error: '.$err);
|
|
| 470 | - return false; |
|
| 471 | - } elseif($this->getError()){
|
|
| 472 | - return false; |
|
| 473 | - } else {
|
|
| 474 | - $this->debug('got response, length='. strlen($this->responseData).' type='.$http->incoming_headers['content-type']);
|
|
| 475 | - return $this->parseResponse($http->incoming_headers, $this->responseData); |
|
| 476 | - } |
|
| 477 | - break; |
|
| 478 | - default: |
|
| 479 | - $this->setError('no transport found, or selected transport is not yet supported!');
|
|
| 480 | - return false; |
|
| 481 | - break; |
|
| 482 | - } |
|
| 483 | - } |
|
| 468 | + if($err = $http->getError()){
|
|
| 469 | + $this->setError('HTTP Error: '.$err);
|
|
| 470 | + return false; |
|
| 471 | + } elseif($this->getError()){
|
|
| 472 | + return false; |
|
| 473 | + } else {
|
|
| 474 | + $this->debug('got response, length='. strlen($this->responseData).' type='.$http->incoming_headers['content-type']);
|
|
| 475 | + return $this->parseResponse($http->incoming_headers, $this->responseData); |
|
| 476 | + } |
|
| 477 | + break; |
|
| 478 | + default: |
|
| 479 | + $this->setError('no transport found, or selected transport is not yet supported!');
|
|
| 480 | + return false; |
|
| 481 | + break; |
|
| 482 | + } |
|
| 483 | + } |
|
| 484 | 484 | |
| 485 | - /** |
|
| 486 | - * processes SOAP message returned from server |
|
| 487 | - * |
|
| 488 | - * @param array $headers The HTTP headers |
|
| 489 | - * @param string $data unprocessed response data from server |
|
| 490 | - * @return mixed value of the message, decoded into a PHP type |
|
| 491 | - * @access private |
|
| 492 | - */ |
|
| 485 | + /** |
|
| 486 | + * processes SOAP message returned from server |
|
| 487 | + * |
|
| 488 | + * @param array $headers The HTTP headers |
|
| 489 | + * @param string $data unprocessed response data from server |
|
| 490 | + * @return mixed value of the message, decoded into a PHP type |
|
| 491 | + * @access private |
|
| 492 | + */ |
|
| 493 | 493 | function parseResponse($headers, $data) {
|
| 494 | - $this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:');
|
|
| 495 | - $this->appendDebug($this->varDump($headers)); |
|
| 496 | - if (!isset($headers['content-type'])) {
|
|
| 497 | - $this->setError('Response not of type text/xml (no content-type header)');
|
|
| 498 | - return false; |
|
| 499 | - } |
|
| 500 | - if (!strstr($headers['content-type'], 'text/xml')) {
|
|
| 501 | - $this->setError('Response not of type text/xml: ' . $headers['content-type']);
|
|
| 502 | - return false; |
|
| 503 | - } |
|
| 504 | - if (strpos($headers['content-type'], '=')) {
|
|
| 505 | - $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
|
|
| 506 | - $this->debug('Got response encoding: ' . $enc);
|
|
| 507 | - if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
|
|
| 508 | - $this->xml_encoding = strtoupper($enc); |
|
| 509 | - } else {
|
|
| 510 | - $this->xml_encoding = 'US-ASCII'; |
|
| 511 | - } |
|
| 512 | - } else {
|
|
| 513 | - // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 |
|
| 514 | - $this->xml_encoding = 'ISO-8859-1'; |
|
| 515 | - } |
|
| 516 | - $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
|
|
| 517 | - $parser = new nusoap_parser($data,$this->xml_encoding,$this->operation,$this->decode_utf8); |
|
| 518 | - // add parser debug data to our debug |
|
| 519 | - $this->appendDebug($parser->getDebug()); |
|
| 520 | - // if parse errors |
|
| 521 | - if($errstr = $parser->getError()){
|
|
| 522 | - $this->setError( $errstr); |
|
| 523 | - // destroy the parser object |
|
| 524 | - unset($parser); |
|
| 525 | - return false; |
|
| 526 | - } else {
|
|
| 527 | - // get SOAP headers |
|
| 528 | - $this->responseHeaders = $parser->getHeaders(); |
|
| 529 | - // get SOAP headers |
|
| 530 | - $this->responseHeader = $parser->get_soapheader(); |
|
| 531 | - // get decoded message |
|
| 532 | - $return = $parser->get_soapbody(); |
|
| 494 | + $this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:');
|
|
| 495 | + $this->appendDebug($this->varDump($headers)); |
|
| 496 | + if (!isset($headers['content-type'])) {
|
|
| 497 | + $this->setError('Response not of type text/xml (no content-type header)');
|
|
| 498 | + return false; |
|
| 499 | + } |
|
| 500 | + if (!strstr($headers['content-type'], 'text/xml')) {
|
|
| 501 | + $this->setError('Response not of type text/xml: ' . $headers['content-type']);
|
|
| 502 | + return false; |
|
| 503 | + } |
|
| 504 | + if (strpos($headers['content-type'], '=')) {
|
|
| 505 | + $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
|
|
| 506 | + $this->debug('Got response encoding: ' . $enc);
|
|
| 507 | + if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
|
|
| 508 | + $this->xml_encoding = strtoupper($enc); |
|
| 509 | + } else {
|
|
| 510 | + $this->xml_encoding = 'US-ASCII'; |
|
| 511 | + } |
|
| 512 | + } else {
|
|
| 513 | + // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 |
|
| 514 | + $this->xml_encoding = 'ISO-8859-1'; |
|
| 515 | + } |
|
| 516 | + $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
|
|
| 517 | + $parser = new nusoap_parser($data,$this->xml_encoding,$this->operation,$this->decode_utf8); |
|
| 518 | + // add parser debug data to our debug |
|
| 519 | + $this->appendDebug($parser->getDebug()); |
|
| 520 | + // if parse errors |
|
| 521 | + if($errstr = $parser->getError()){
|
|
| 522 | + $this->setError( $errstr); |
|
| 523 | + // destroy the parser object |
|
| 524 | + unset($parser); |
|
| 525 | + return false; |
|
| 526 | + } else {
|
|
| 527 | + // get SOAP headers |
|
| 528 | + $this->responseHeaders = $parser->getHeaders(); |
|
| 529 | + // get SOAP headers |
|
| 530 | + $this->responseHeader = $parser->get_soapheader(); |
|
| 531 | + // get decoded message |
|
| 532 | + $return = $parser->get_soapbody(); |
|
| 533 | 533 | // add document for doclit support |
| 534 | 534 | $this->document = $parser->document; |
| 535 | - // destroy the parser object |
|
| 536 | - unset($parser); |
|
| 537 | - // return decode message |
|
| 538 | - return $return; |
|
| 539 | - } |
|
| 540 | - } |
|
| 541 | - |
|
| 542 | - /** |
|
| 543 | - * sets user-specified cURL options |
|
| 544 | - * |
|
| 545 | - * @param mixed $option The cURL option (always integer?) |
|
| 546 | - * @param mixed $value The cURL option value |
|
| 547 | - * @access public |
|
| 548 | - */ |
|
| 549 | - function setCurlOption($option, $value) {
|
|
| 550 | - $this->debug("setCurlOption option=$option, value=");
|
|
| 551 | - $this->appendDebug($this->varDump($value)); |
|
| 552 | - $this->curl_options[$option] = $value; |
|
| 553 | - } |
|
| 535 | + // destroy the parser object |
|
| 536 | + unset($parser); |
|
| 537 | + // return decode message |
|
| 538 | + return $return; |
|
| 539 | + } |
|
| 540 | + } |
|
| 554 | 541 | |
| 555 | - /** |
|
| 556 | - * sets the SOAP endpoint, which can override WSDL |
|
| 557 | - * |
|
| 558 | - * @param string $endpoint The endpoint URL to use, or empty string or false to prevent override |
|
| 559 | - * @access public |
|
| 560 | - */ |
|
| 561 | - function setEndpoint($endpoint) {
|
|
| 562 | - $this->debug("setEndpoint(\"$endpoint\")");
|
|
| 563 | - $this->forceEndpoint = $endpoint; |
|
| 564 | - } |
|
| 542 | + /** |
|
| 543 | + * sets user-specified cURL options |
|
| 544 | + * |
|
| 545 | + * @param mixed $option The cURL option (always integer?) |
|
| 546 | + * @param mixed $value The cURL option value |
|
| 547 | + * @access public |
|
| 548 | + */ |
|
| 549 | + function setCurlOption($option, $value) {
|
|
| 550 | + $this->debug("setCurlOption option=$option, value=");
|
|
| 551 | + $this->appendDebug($this->varDump($value)); |
|
| 552 | + $this->curl_options[$option] = $value; |
|
| 553 | + } |
|
| 565 | 554 | |
| 566 | - /** |
|
| 567 | - * set the SOAP headers |
|
| 568 | - * |
|
| 569 | - * @param mixed $headers String of XML with SOAP header content, or array of soapval objects for SOAP headers |
|
| 570 | - * @access public |
|
| 571 | - */ |
|
| 572 | - function setHeaders($headers){
|
|
| 573 | - $this->debug("setHeaders headers=");
|
|
| 574 | - $this->appendDebug($this->varDump($headers)); |
|
| 575 | - $this->requestHeaders = $headers; |
|
| 576 | - } |
|
| 555 | + /** |
|
| 556 | + * sets the SOAP endpoint, which can override WSDL |
|
| 557 | + * |
|
| 558 | + * @param string $endpoint The endpoint URL to use, or empty string or false to prevent override |
|
| 559 | + * @access public |
|
| 560 | + */ |
|
| 561 | + function setEndpoint($endpoint) {
|
|
| 562 | + $this->debug("setEndpoint(\"$endpoint\")");
|
|
| 563 | + $this->forceEndpoint = $endpoint; |
|
| 564 | + } |
|
| 577 | 565 | |
| 578 | - /** |
|
| 579 | - * get the SOAP response headers (namespace resolution incomplete) |
|
| 580 | - * |
|
| 581 | - * @return string |
|
| 582 | - * @access public |
|
| 583 | - */ |
|
| 584 | - function getHeaders(){
|
|
| 585 | - return $this->responseHeaders; |
|
| 586 | - } |
|
| 566 | + /** |
|
| 567 | + * set the SOAP headers |
|
| 568 | + * |
|
| 569 | + * @param mixed $headers String of XML with SOAP header content, or array of soapval objects for SOAP headers |
|
| 570 | + * @access public |
|
| 571 | + */ |
|
| 572 | + function setHeaders($headers){
|
|
| 573 | + $this->debug("setHeaders headers=");
|
|
| 574 | + $this->appendDebug($this->varDump($headers)); |
|
| 575 | + $this->requestHeaders = $headers; |
|
| 576 | + } |
|
| 587 | 577 | |
| 588 | - /** |
|
| 589 | - * get the SOAP response Header (parsed) |
|
| 590 | - * |
|
| 591 | - * @return mixed |
|
| 592 | - * @access public |
|
| 593 | - */ |
|
| 594 | - function getHeader(){
|
|
| 595 | - return $this->responseHeader; |
|
| 596 | - } |
|
| 578 | + /** |
|
| 579 | + * get the SOAP response headers (namespace resolution incomplete) |
|
| 580 | + * |
|
| 581 | + * @return string |
|
| 582 | + * @access public |
|
| 583 | + */ |
|
| 584 | + function getHeaders(){
|
|
| 585 | + return $this->responseHeaders; |
|
| 586 | + } |
|
| 597 | 587 | |
| 598 | - /** |
|
| 599 | - * set proxy info here |
|
| 600 | - * |
|
| 601 | - * @param string $proxyhost |
|
| 602 | - * @param string $proxyport |
|
| 603 | - * @param string $proxyusername |
|
| 604 | - * @param string $proxypassword |
|
| 605 | - * @access public |
|
| 606 | - */ |
|
| 607 | - function setHTTPProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '') {
|
|
| 608 | - $this->proxyhost = $proxyhost; |
|
| 609 | - $this->proxyport = $proxyport; |
|
| 610 | - $this->proxyusername = $proxyusername; |
|
| 611 | - $this->proxypassword = $proxypassword; |
|
| 612 | - } |
|
| 588 | + /** |
|
| 589 | + * get the SOAP response Header (parsed) |
|
| 590 | + * |
|
| 591 | + * @return mixed |
|
| 592 | + * @access public |
|
| 593 | + */ |
|
| 594 | + function getHeader(){
|
|
| 595 | + return $this->responseHeader; |
|
| 596 | + } |
|
| 613 | 597 | |
| 614 | - /** |
|
| 615 | - * if authenticating, set user credentials here |
|
| 616 | - * |
|
| 617 | - * @param string $username |
|
| 618 | - * @param string $password |
|
| 619 | - * @param string $authtype (basic|digest|certificate|ntlm) |
|
| 620 | - * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) |
|
| 621 | - * @access public |
|
| 622 | - */ |
|
| 623 | - function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) {
|
|
| 624 | - $this->debug("setCredentials username=$username authtype=$authtype certRequest=");
|
|
| 625 | - $this->appendDebug($this->varDump($certRequest)); |
|
| 626 | - $this->username = $username; |
|
| 627 | - $this->password = $password; |
|
| 628 | - $this->authtype = $authtype; |
|
| 629 | - $this->certRequest = $certRequest; |
|
| 630 | - } |
|
| 598 | + /** |
|
| 599 | + * set proxy info here |
|
| 600 | + * |
|
| 601 | + * @param string $proxyhost |
|
| 602 | + * @param string $proxyport |
|
| 603 | + * @param string $proxyusername |
|
| 604 | + * @param string $proxypassword |
|
| 605 | + * @access public |
|
| 606 | + */ |
|
| 607 | + function setHTTPProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '') {
|
|
| 608 | + $this->proxyhost = $proxyhost; |
|
| 609 | + $this->proxyport = $proxyport; |
|
| 610 | + $this->proxyusername = $proxyusername; |
|
| 611 | + $this->proxypassword = $proxypassword; |
|
| 612 | + } |
|
| 613 | + |
|
| 614 | + /** |
|
| 615 | + * if authenticating, set user credentials here |
|
| 616 | + * |
|
| 617 | + * @param string $username |
|
| 618 | + * @param string $password |
|
| 619 | + * @param string $authtype (basic|digest|certificate|ntlm) |
|
| 620 | + * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) |
|
| 621 | + * @access public |
|
| 622 | + */ |
|
| 623 | + function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) {
|
|
| 624 | + $this->debug("setCredentials username=$username authtype=$authtype certRequest=");
|
|
| 625 | + $this->appendDebug($this->varDump($certRequest)); |
|
| 626 | + $this->username = $username; |
|
| 627 | + $this->password = $password; |
|
| 628 | + $this->authtype = $authtype; |
|
| 629 | + $this->certRequest = $certRequest; |
|
| 630 | + } |
|
| 631 | 631 | |
| 632 | - /** |
|
| 633 | - * use HTTP encoding |
|
| 634 | - * |
|
| 635 | - * @param string $enc HTTP encoding |
|
| 636 | - * @access public |
|
| 637 | - */ |
|
| 638 | - function setHTTPEncoding($enc='gzip, deflate'){
|
|
| 639 | - $this->debug("setHTTPEncoding(\"$enc\")");
|
|
| 640 | - $this->http_encoding = $enc; |
|
| 641 | - } |
|
| 632 | + /** |
|
| 633 | + * use HTTP encoding |
|
| 634 | + * |
|
| 635 | + * @param string $enc HTTP encoding |
|
| 636 | + * @access public |
|
| 637 | + */ |
|
| 638 | + function setHTTPEncoding($enc='gzip, deflate'){
|
|
| 639 | + $this->debug("setHTTPEncoding(\"$enc\")");
|
|
| 640 | + $this->http_encoding = $enc; |
|
| 641 | + } |
|
| 642 | 642 | |
| 643 | - /** |
|
| 644 | - * Set whether to try to use cURL connections if possible |
|
| 645 | - * |
|
| 646 | - * @param boolean $use Whether to try to use cURL |
|
| 647 | - * @access public |
|
| 648 | - */ |
|
| 649 | - function setUseCURL($use) {
|
|
| 650 | - $this->debug("setUseCURL($use)");
|
|
| 651 | - $this->use_curl = $use; |
|
| 652 | - } |
|
| 643 | + /** |
|
| 644 | + * Set whether to try to use cURL connections if possible |
|
| 645 | + * |
|
| 646 | + * @param boolean $use Whether to try to use cURL |
|
| 647 | + * @access public |
|
| 648 | + */ |
|
| 649 | + function setUseCURL($use) {
|
|
| 650 | + $this->debug("setUseCURL($use)");
|
|
| 651 | + $this->use_curl = $use; |
|
| 652 | + } |
|
| 653 | 653 | |
| 654 | - /** |
|
| 655 | - * use HTTP persistent connections if possible |
|
| 656 | - * |
|
| 657 | - * @access public |
|
| 658 | - */ |
|
| 659 | - function useHTTPPersistentConnection(){
|
|
| 660 | - $this->debug("useHTTPPersistentConnection");
|
|
| 661 | - $this->persistentConnection = true; |
|
| 662 | - } |
|
| 654 | + /** |
|
| 655 | + * use HTTP persistent connections if possible |
|
| 656 | + * |
|
| 657 | + * @access public |
|
| 658 | + */ |
|
| 659 | + function useHTTPPersistentConnection(){
|
|
| 660 | + $this->debug("useHTTPPersistentConnection");
|
|
| 661 | + $this->persistentConnection = true; |
|
| 662 | + } |
|
| 663 | 663 | |
| 664 | - /** |
|
| 665 | - * gets the default RPC parameter setting. |
|
| 666 | - * If true, default is that call params are like RPC even for document style. |
|
| 667 | - * Each call() can override this value. |
|
| 668 | - * |
|
| 669 | - * This is no longer used. |
|
| 670 | - * |
|
| 671 | - * @return boolean |
|
| 672 | - * @access public |
|
| 673 | - * @deprecated |
|
| 674 | - */ |
|
| 675 | - function getDefaultRpcParams() {
|
|
| 676 | - return $this->defaultRpcParams; |
|
| 677 | - } |
|
| 664 | + /** |
|
| 665 | + * gets the default RPC parameter setting. |
|
| 666 | + * If true, default is that call params are like RPC even for document style. |
|
| 667 | + * Each call() can override this value. |
|
| 668 | + * |
|
| 669 | + * This is no longer used. |
|
| 670 | + * |
|
| 671 | + * @return boolean |
|
| 672 | + * @access public |
|
| 673 | + * @deprecated |
|
| 674 | + */ |
|
| 675 | + function getDefaultRpcParams() {
|
|
| 676 | + return $this->defaultRpcParams; |
|
| 677 | + } |
|
| 678 | 678 | |
| 679 | - /** |
|
| 680 | - * sets the default RPC parameter setting. |
|
| 681 | - * If true, default is that call params are like RPC even for document style |
|
| 682 | - * Each call() can override this value. |
|
| 683 | - * |
|
| 684 | - * This is no longer used. |
|
| 685 | - * |
|
| 686 | - * @param boolean $rpcParams |
|
| 687 | - * @access public |
|
| 688 | - * @deprecated |
|
| 689 | - */ |
|
| 690 | - function setDefaultRpcParams($rpcParams) {
|
|
| 691 | - $this->defaultRpcParams = $rpcParams; |
|
| 692 | - } |
|
| 679 | + /** |
|
| 680 | + * sets the default RPC parameter setting. |
|
| 681 | + * If true, default is that call params are like RPC even for document style |
|
| 682 | + * Each call() can override this value. |
|
| 683 | + * |
|
| 684 | + * This is no longer used. |
|
| 685 | + * |
|
| 686 | + * @param boolean $rpcParams |
|
| 687 | + * @access public |
|
| 688 | + * @deprecated |
|
| 689 | + */ |
|
| 690 | + function setDefaultRpcParams($rpcParams) {
|
|
| 691 | + $this->defaultRpcParams = $rpcParams; |
|
| 692 | + } |
|
| 693 | 693 | |
| 694 | - /** |
|
| 695 | - * dynamically creates an instance of a proxy class, |
|
| 696 | - * allowing user to directly call methods from wsdl |
|
| 697 | - * |
|
| 698 | - * @return object soap_proxy object |
|
| 699 | - * @access public |
|
| 700 | - */ |
|
| 701 | - function getProxy() {
|
|
| 702 | - $r = rand(); |
|
| 703 | - $evalStr = $this->_getProxyClassCode($r); |
|
| 704 | - //$this->debug("proxy class: $evalStr");
|
|
| 705 | - if ($this->getError()) {
|
|
| 706 | - $this->debug("Error from _getProxyClassCode, so return NULL");
|
|
| 707 | - return null; |
|
| 708 | - } |
|
| 709 | - // eval the class |
|
| 710 | - eval($evalStr); |
|
| 711 | - // instantiate proxy object |
|
| 712 | - eval("\$proxy = new nusoap_proxy_$r('');");
|
|
| 713 | - // transfer current wsdl data to the proxy thereby avoiding parsing the wsdl twice |
|
| 714 | - $proxy->endpointType = 'wsdl'; |
|
| 715 | - $proxy->wsdlFile = $this->wsdlFile; |
|
| 716 | - $proxy->wsdl = $this->wsdl; |
|
| 717 | - $proxy->operations = $this->operations; |
|
| 718 | - $proxy->defaultRpcParams = $this->defaultRpcParams; |
|
| 719 | - // transfer other state |
|
| 720 | - $proxy->soap_defencoding = $this->soap_defencoding; |
|
| 721 | - $proxy->username = $this->username; |
|
| 722 | - $proxy->password = $this->password; |
|
| 723 | - $proxy->authtype = $this->authtype; |
|
| 724 | - $proxy->certRequest = $this->certRequest; |
|
| 725 | - $proxy->requestHeaders = $this->requestHeaders; |
|
| 726 | - $proxy->endpoint = $this->endpoint; |
|
| 727 | - $proxy->forceEndpoint = $this->forceEndpoint; |
|
| 728 | - $proxy->proxyhost = $this->proxyhost; |
|
| 729 | - $proxy->proxyport = $this->proxyport; |
|
| 730 | - $proxy->proxyusername = $this->proxyusername; |
|
| 731 | - $proxy->proxypassword = $this->proxypassword; |
|
| 732 | - $proxy->http_encoding = $this->http_encoding; |
|
| 733 | - $proxy->timeout = $this->timeout; |
|
| 734 | - $proxy->response_timeout = $this->response_timeout; |
|
| 735 | - $proxy->persistentConnection = &$this->persistentConnection; |
|
| 736 | - $proxy->decode_utf8 = $this->decode_utf8; |
|
| 737 | - $proxy->curl_options = $this->curl_options; |
|
| 738 | - $proxy->bindingType = $this->bindingType; |
|
| 739 | - $proxy->use_curl = $this->use_curl; |
|
| 740 | - return $proxy; |
|
| 741 | - } |
|
| 694 | + /** |
|
| 695 | + * dynamically creates an instance of a proxy class, |
|
| 696 | + * allowing user to directly call methods from wsdl |
|
| 697 | + * |
|
| 698 | + * @return object soap_proxy object |
|
| 699 | + * @access public |
|
| 700 | + */ |
|
| 701 | + function getProxy() {
|
|
| 702 | + $r = rand(); |
|
| 703 | + $evalStr = $this->_getProxyClassCode($r); |
|
| 704 | + //$this->debug("proxy class: $evalStr");
|
|
| 705 | + if ($this->getError()) {
|
|
| 706 | + $this->debug("Error from _getProxyClassCode, so return NULL");
|
|
| 707 | + return null; |
|
| 708 | + } |
|
| 709 | + // eval the class |
|
| 710 | + eval($evalStr); |
|
| 711 | + // instantiate proxy object |
|
| 712 | + eval("\$proxy = new nusoap_proxy_$r('');");
|
|
| 713 | + // transfer current wsdl data to the proxy thereby avoiding parsing the wsdl twice |
|
| 714 | + $proxy->endpointType = 'wsdl'; |
|
| 715 | + $proxy->wsdlFile = $this->wsdlFile; |
|
| 716 | + $proxy->wsdl = $this->wsdl; |
|
| 717 | + $proxy->operations = $this->operations; |
|
| 718 | + $proxy->defaultRpcParams = $this->defaultRpcParams; |
|
| 719 | + // transfer other state |
|
| 720 | + $proxy->soap_defencoding = $this->soap_defencoding; |
|
| 721 | + $proxy->username = $this->username; |
|
| 722 | + $proxy->password = $this->password; |
|
| 723 | + $proxy->authtype = $this->authtype; |
|
| 724 | + $proxy->certRequest = $this->certRequest; |
|
| 725 | + $proxy->requestHeaders = $this->requestHeaders; |
|
| 726 | + $proxy->endpoint = $this->endpoint; |
|
| 727 | + $proxy->forceEndpoint = $this->forceEndpoint; |
|
| 728 | + $proxy->proxyhost = $this->proxyhost; |
|
| 729 | + $proxy->proxyport = $this->proxyport; |
|
| 730 | + $proxy->proxyusername = $this->proxyusername; |
|
| 731 | + $proxy->proxypassword = $this->proxypassword; |
|
| 732 | + $proxy->http_encoding = $this->http_encoding; |
|
| 733 | + $proxy->timeout = $this->timeout; |
|
| 734 | + $proxy->response_timeout = $this->response_timeout; |
|
| 735 | + $proxy->persistentConnection = &$this->persistentConnection; |
|
| 736 | + $proxy->decode_utf8 = $this->decode_utf8; |
|
| 737 | + $proxy->curl_options = $this->curl_options; |
|
| 738 | + $proxy->bindingType = $this->bindingType; |
|
| 739 | + $proxy->use_curl = $this->use_curl; |
|
| 740 | + return $proxy; |
|
| 741 | + } |
|
| 742 | 742 | |
| 743 | - /** |
|
| 744 | - * dynamically creates proxy class code |
|
| 745 | - * |
|
| 746 | - * @return string PHP/NuSOAP code for the proxy class |
|
| 747 | - * @access private |
|
| 748 | - */ |
|
| 749 | - function _getProxyClassCode($r) {
|
|
| 750 | - $this->debug("in getProxy endpointType=$this->endpointType");
|
|
| 751 | - $this->appendDebug("wsdl=" . $this->varDump($this->wsdl));
|
|
| 752 | - if ($this->endpointType != 'wsdl') {
|
|
| 753 | - $evalStr = 'A proxy can only be created for a WSDL client'; |
|
| 754 | - $this->setError($evalStr); |
|
| 755 | - $evalStr = "echo \"$evalStr\";"; |
|
| 756 | - return $evalStr; |
|
| 757 | - } |
|
| 758 | - if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
|
|
| 759 | - $this->loadWSDL(); |
|
| 760 | - if ($this->getError()) {
|
|
| 761 | - return "echo \"" . $this->getError() . "\";"; |
|
| 762 | - } |
|
| 763 | - } |
|
| 764 | - $evalStr = ''; |
|
| 765 | - foreach ($this->operations as $operation => $opData) {
|
|
| 766 | - if ($operation != '') {
|
|
| 767 | - // create param string and param comment string |
|
| 768 | - if (sizeof($opData['input']['parts']) > 0) {
|
|
| 769 | - $paramStr = ''; |
|
| 770 | - $paramArrayStr = ''; |
|
| 771 | - $paramCommentStr = ''; |
|
| 772 | - foreach ($opData['input']['parts'] as $name => $type) {
|
|
| 773 | - $paramStr .= "\$$name, "; |
|
| 774 | - $paramArrayStr .= "'$name' => \$$name, "; |
|
| 775 | - $paramCommentStr .= "$type \$$name, "; |
|
| 776 | - } |
|
| 777 | - $paramStr = substr($paramStr, 0, strlen($paramStr)-2); |
|
| 778 | - $paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr)-2); |
|
| 779 | - $paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr)-2); |
|
| 780 | - } else {
|
|
| 781 | - $paramStr = ''; |
|
| 782 | - $paramArrayStr = ''; |
|
| 783 | - $paramCommentStr = 'void'; |
|
| 784 | - } |
|
| 785 | - $opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace']; |
|
| 786 | - $evalStr .= "// $paramCommentStr |
|
| 743 | + /** |
|
| 744 | + * dynamically creates proxy class code |
|
| 745 | + * |
|
| 746 | + * @return string PHP/NuSOAP code for the proxy class |
|
| 747 | + * @access private |
|
| 748 | + */ |
|
| 749 | + function _getProxyClassCode($r) {
|
|
| 750 | + $this->debug("in getProxy endpointType=$this->endpointType");
|
|
| 751 | + $this->appendDebug("wsdl=" . $this->varDump($this->wsdl));
|
|
| 752 | + if ($this->endpointType != 'wsdl') {
|
|
| 753 | + $evalStr = 'A proxy can only be created for a WSDL client'; |
|
| 754 | + $this->setError($evalStr); |
|
| 755 | + $evalStr = "echo \"$evalStr\";"; |
|
| 756 | + return $evalStr; |
|
| 757 | + } |
|
| 758 | + if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
|
|
| 759 | + $this->loadWSDL(); |
|
| 760 | + if ($this->getError()) {
|
|
| 761 | + return "echo \"" . $this->getError() . "\";"; |
|
| 762 | + } |
|
| 763 | + } |
|
| 764 | + $evalStr = ''; |
|
| 765 | + foreach ($this->operations as $operation => $opData) {
|
|
| 766 | + if ($operation != '') {
|
|
| 767 | + // create param string and param comment string |
|
| 768 | + if (sizeof($opData['input']['parts']) > 0) {
|
|
| 769 | + $paramStr = ''; |
|
| 770 | + $paramArrayStr = ''; |
|
| 771 | + $paramCommentStr = ''; |
|
| 772 | + foreach ($opData['input']['parts'] as $name => $type) {
|
|
| 773 | + $paramStr .= "\$$name, "; |
|
| 774 | + $paramArrayStr .= "'$name' => \$$name, "; |
|
| 775 | + $paramCommentStr .= "$type \$$name, "; |
|
| 776 | + } |
|
| 777 | + $paramStr = substr($paramStr, 0, strlen($paramStr)-2); |
|
| 778 | + $paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr)-2); |
|
| 779 | + $paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr)-2); |
|
| 780 | + } else {
|
|
| 781 | + $paramStr = ''; |
|
| 782 | + $paramArrayStr = ''; |
|
| 783 | + $paramCommentStr = 'void'; |
|
| 784 | + } |
|
| 785 | + $opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace']; |
|
| 786 | + $evalStr .= "// $paramCommentStr |
|
| 787 | 787 | function " . str_replace('.', '__', $operation) . "($paramStr) {
|
| 788 | 788 | \$params = array($paramArrayStr); |
| 789 | 789 | return \$this->call('$operation', \$params, '".$opData['namespace']."', '".(isset($opData['soapAction']) ? $opData['soapAction'] : '')."');
|
| 790 | 790 | } |
| 791 | 791 | "; |
| 792 | - unset($paramStr); |
|
| 793 | - unset($paramCommentStr); |
|
| 794 | - } |
|
| 795 | - } |
|
| 796 | - $evalStr = 'class nusoap_proxy_'.$r.' extends nusoap_client {
|
|
| 792 | + unset($paramStr); |
|
| 793 | + unset($paramCommentStr); |
|
| 794 | + } |
|
| 795 | + } |
|
| 796 | + $evalStr = 'class nusoap_proxy_'.$r.' extends nusoap_client {
|
|
| 797 | 797 | '.$evalStr.' |
| 798 | 798 | }'; |
| 799 | - return $evalStr; |
|
| 800 | - } |
|
| 799 | + return $evalStr; |
|
| 800 | + } |
|
| 801 | 801 | |
| 802 | - /** |
|
| 803 | - * dynamically creates proxy class code |
|
| 804 | - * |
|
| 805 | - * @return string PHP/NuSOAP code for the proxy class |
|
| 806 | - * @access public |
|
| 807 | - */ |
|
| 808 | - function getProxyClassCode() {
|
|
| 809 | - $r = rand(); |
|
| 810 | - return $this->_getProxyClassCode($r); |
|
| 811 | - } |
|
| 802 | + /** |
|
| 803 | + * dynamically creates proxy class code |
|
| 804 | + * |
|
| 805 | + * @return string PHP/NuSOAP code for the proxy class |
|
| 806 | + * @access public |
|
| 807 | + */ |
|
| 808 | + function getProxyClassCode() {
|
|
| 809 | + $r = rand(); |
|
| 810 | + return $this->_getProxyClassCode($r); |
|
| 811 | + } |
|
| 812 | 812 | |
| 813 | - /** |
|
| 814 | - * gets the HTTP body for the current request. |
|
| 815 | - * |
|
| 816 | - * @param string $soapmsg The SOAP payload |
|
| 817 | - * @return string The HTTP body, which includes the SOAP payload |
|
| 818 | - * @access private |
|
| 819 | - */ |
|
| 820 | - function getHTTPBody($soapmsg) {
|
|
| 821 | - return $soapmsg; |
|
| 822 | - } |
|
| 813 | + /** |
|
| 814 | + * gets the HTTP body for the current request. |
|
| 815 | + * |
|
| 816 | + * @param string $soapmsg The SOAP payload |
|
| 817 | + * @return string The HTTP body, which includes the SOAP payload |
|
| 818 | + * @access private |
|
| 819 | + */ |
|
| 820 | + function getHTTPBody($soapmsg) {
|
|
| 821 | + return $soapmsg; |
|
| 822 | + } |
|
| 823 | 823 | |
| 824 | - /** |
|
| 825 | - * gets the HTTP content type for the current request. |
|
| 826 | - * |
|
| 827 | - * Note: getHTTPBody must be called before this. |
|
| 828 | - * |
|
| 829 | - * @return string the HTTP content type for the current request. |
|
| 830 | - * @access private |
|
| 831 | - */ |
|
| 832 | - function getHTTPContentType() {
|
|
| 833 | - return 'text/xml'; |
|
| 834 | - } |
|
| 824 | + /** |
|
| 825 | + * gets the HTTP content type for the current request. |
|
| 826 | + * |
|
| 827 | + * Note: getHTTPBody must be called before this. |
|
| 828 | + * |
|
| 829 | + * @return string the HTTP content type for the current request. |
|
| 830 | + * @access private |
|
| 831 | + */ |
|
| 832 | + function getHTTPContentType() {
|
|
| 833 | + return 'text/xml'; |
|
| 834 | + } |
|
| 835 | 835 | |
| 836 | - /** |
|
| 837 | - * gets the HTTP content type charset for the current request. |
|
| 838 | - * returns false for non-text content types. |
|
| 839 | - * |
|
| 840 | - * Note: getHTTPBody must be called before this. |
|
| 841 | - * |
|
| 842 | - * @return string the HTTP content type charset for the current request. |
|
| 843 | - * @access private |
|
| 844 | - */ |
|
| 845 | - function getHTTPContentTypeCharset() {
|
|
| 846 | - return $this->soap_defencoding; |
|
| 847 | - } |
|
| 836 | + /** |
|
| 837 | + * gets the HTTP content type charset for the current request. |
|
| 838 | + * returns false for non-text content types. |
|
| 839 | + * |
|
| 840 | + * Note: getHTTPBody must be called before this. |
|
| 841 | + * |
|
| 842 | + * @return string the HTTP content type charset for the current request. |
|
| 843 | + * @access private |
|
| 844 | + */ |
|
| 845 | + function getHTTPContentTypeCharset() {
|
|
| 846 | + return $this->soap_defencoding; |
|
| 847 | + } |
|
| 848 | 848 | |
| 849 | - /* |
|
| 849 | + /* |
|
| 850 | 850 | * whether or not parser should decode utf8 element content |
| 851 | 851 | * |
| 852 | 852 | * @return always returns true |
| 853 | 853 | * @access public |
| 854 | 854 | */ |
| 855 | 855 | function decodeUTF8($bool){
|
| 856 | - $this->decode_utf8 = $bool; |
|
| 857 | - return true; |
|
| 856 | + $this->decode_utf8 = $bool; |
|
| 857 | + return true; |
|
| 858 | 858 | } |
| 859 | 859 | |
| 860 | - /** |
|
| 861 | - * adds a new Cookie into $this->cookies array |
|
| 862 | - * |
|
| 863 | - * @param string $name Cookie Name |
|
| 864 | - * @param string $value Cookie Value |
|
| 865 | - * @return boolean if cookie-set was successful returns true, else false |
|
| 866 | - * @access public |
|
| 867 | - */ |
|
| 868 | - function setCookie($name, $value) {
|
|
| 869 | - if (strlen($name) == 0) {
|
|
| 870 | - return false; |
|
| 871 | - } |
|
| 872 | - $this->cookies[] = array('name' => $name, 'value' => $value);
|
|
| 873 | - return true; |
|
| 874 | - } |
|
| 860 | + /** |
|
| 861 | + * adds a new Cookie into $this->cookies array |
|
| 862 | + * |
|
| 863 | + * @param string $name Cookie Name |
|
| 864 | + * @param string $value Cookie Value |
|
| 865 | + * @return boolean if cookie-set was successful returns true, else false |
|
| 866 | + * @access public |
|
| 867 | + */ |
|
| 868 | + function setCookie($name, $value) {
|
|
| 869 | + if (strlen($name) == 0) {
|
|
| 870 | + return false; |
|
| 871 | + } |
|
| 872 | + $this->cookies[] = array('name' => $name, 'value' => $value);
|
|
| 873 | + return true; |
|
| 874 | + } |
|
| 875 | 875 | |
| 876 | - /** |
|
| 877 | - * gets all Cookies |
|
| 878 | - * |
|
| 879 | - * @return array with all internal cookies |
|
| 880 | - * @access public |
|
| 881 | - */ |
|
| 882 | - function getCookies() {
|
|
| 883 | - return $this->cookies; |
|
| 884 | - } |
|
| 876 | + /** |
|
| 877 | + * gets all Cookies |
|
| 878 | + * |
|
| 879 | + * @return array with all internal cookies |
|
| 880 | + * @access public |
|
| 881 | + */ |
|
| 882 | + function getCookies() {
|
|
| 883 | + return $this->cookies; |
|
| 884 | + } |
|
| 885 | 885 | |
| 886 | - /** |
|
| 887 | - * checks all Cookies and delete those which are expired |
|
| 888 | - * |
|
| 889 | - * @return boolean always return true |
|
| 890 | - * @access private |
|
| 891 | - */ |
|
| 892 | - function checkCookies() {
|
|
| 893 | - if (sizeof($this->cookies) == 0) {
|
|
| 894 | - return true; |
|
| 895 | - } |
|
| 896 | - $this->debug('checkCookie: check ' . sizeof($this->cookies) . ' cookies');
|
|
| 897 | - $curr_cookies = $this->cookies; |
|
| 898 | - $this->cookies = array(); |
|
| 899 | - foreach ($curr_cookies as $cookie) {
|
|
| 900 | - if (! is_array($cookie)) {
|
|
| 901 | - $this->debug('Remove cookie that is not an array');
|
|
| 902 | - continue; |
|
| 903 | - } |
|
| 904 | - if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
|
|
| 905 | - if (strtotime($cookie['expires']) > time()) {
|
|
| 906 | - $this->cookies[] = $cookie; |
|
| 907 | - } else {
|
|
| 908 | - $this->debug('Remove expired cookie ' . $cookie['name']);
|
|
| 909 | - } |
|
| 910 | - } else {
|
|
| 911 | - $this->cookies[] = $cookie; |
|
| 912 | - } |
|
| 913 | - } |
|
| 914 | - $this->debug('checkCookie: '.sizeof($this->cookies).' cookies left in array');
|
|
| 915 | - return true; |
|
| 916 | - } |
|
| 886 | + /** |
|
| 887 | + * checks all Cookies and delete those which are expired |
|
| 888 | + * |
|
| 889 | + * @return boolean always return true |
|
| 890 | + * @access private |
|
| 891 | + */ |
|
| 892 | + function checkCookies() {
|
|
| 893 | + if (sizeof($this->cookies) == 0) {
|
|
| 894 | + return true; |
|
| 895 | + } |
|
| 896 | + $this->debug('checkCookie: check ' . sizeof($this->cookies) . ' cookies');
|
|
| 897 | + $curr_cookies = $this->cookies; |
|
| 898 | + $this->cookies = array(); |
|
| 899 | + foreach ($curr_cookies as $cookie) {
|
|
| 900 | + if (! is_array($cookie)) {
|
|
| 901 | + $this->debug('Remove cookie that is not an array');
|
|
| 902 | + continue; |
|
| 903 | + } |
|
| 904 | + if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
|
|
| 905 | + if (strtotime($cookie['expires']) > time()) {
|
|
| 906 | + $this->cookies[] = $cookie; |
|
| 907 | + } else {
|
|
| 908 | + $this->debug('Remove expired cookie ' . $cookie['name']);
|
|
| 909 | + } |
|
| 910 | + } else {
|
|
| 911 | + $this->cookies[] = $cookie; |
|
| 912 | + } |
|
| 913 | + } |
|
| 914 | + $this->debug('checkCookie: '.sizeof($this->cookies).' cookies left in array');
|
|
| 915 | + return true; |
|
| 916 | + } |
|
| 917 | 917 | |
| 918 | - /** |
|
| 919 | - * updates the current cookies with a new set |
|
| 920 | - * |
|
| 921 | - * @param array $cookies new cookies with which to update current ones |
|
| 922 | - * @return boolean always return true |
|
| 923 | - * @access private |
|
| 924 | - */ |
|
| 925 | - function UpdateCookies($cookies) {
|
|
| 926 | - if (sizeof($this->cookies) == 0) {
|
|
| 927 | - // no existing cookies: take whatever is new |
|
| 928 | - if (sizeof($cookies) > 0) {
|
|
| 929 | - $this->debug('Setting new cookie(s)');
|
|
| 930 | - $this->cookies = $cookies; |
|
| 931 | - } |
|
| 932 | - return true; |
|
| 933 | - } |
|
| 934 | - if (sizeof($cookies) == 0) {
|
|
| 935 | - // no new cookies: keep what we've got |
|
| 936 | - return true; |
|
| 937 | - } |
|
| 938 | - // merge |
|
| 939 | - foreach ($cookies as $newCookie) {
|
|
| 940 | - if (!is_array($newCookie)) {
|
|
| 941 | - continue; |
|
| 942 | - } |
|
| 943 | - if ((!isset($newCookie['name'])) || (!isset($newCookie['value']))) {
|
|
| 944 | - continue; |
|
| 945 | - } |
|
| 946 | - $newName = $newCookie['name']; |
|
| 947 | - |
|
| 948 | - $found = false; |
|
| 949 | - for ($i = 0; $i < count($this->cookies); $i++) {
|
|
| 950 | - $cookie = $this->cookies[$i]; |
|
| 951 | - if (!is_array($cookie)) {
|
|
| 952 | - continue; |
|
| 953 | - } |
|
| 954 | - if (!isset($cookie['name'])) {
|
|
| 955 | - continue; |
|
| 956 | - } |
|
| 957 | - if ($newName != $cookie['name']) {
|
|
| 958 | - continue; |
|
| 959 | - } |
|
| 960 | - $newDomain = isset($newCookie['domain']) ? $newCookie['domain'] : 'NODOMAIN'; |
|
| 961 | - $domain = isset($cookie['domain']) ? $cookie['domain'] : 'NODOMAIN'; |
|
| 962 | - if ($newDomain != $domain) {
|
|
| 963 | - continue; |
|
| 964 | - } |
|
| 965 | - $newPath = isset($newCookie['path']) ? $newCookie['path'] : 'NOPATH'; |
|
| 966 | - $path = isset($cookie['path']) ? $cookie['path'] : 'NOPATH'; |
|
| 967 | - if ($newPath != $path) {
|
|
| 968 | - continue; |
|
| 969 | - } |
|
| 970 | - $this->cookies[$i] = $newCookie; |
|
| 971 | - $found = true; |
|
| 972 | - $this->debug('Update cookie ' . $newName . '=' . $newCookie['value']);
|
|
| 973 | - break; |
|
| 974 | - } |
|
| 975 | - if (! $found) {
|
|
| 976 | - $this->debug('Add cookie ' . $newName . '=' . $newCookie['value']);
|
|
| 977 | - $this->cookies[] = $newCookie; |
|
| 978 | - } |
|
| 979 | - } |
|
| 980 | - return true; |
|
| 981 | - } |
|
| 918 | + /** |
|
| 919 | + * updates the current cookies with a new set |
|
| 920 | + * |
|
| 921 | + * @param array $cookies new cookies with which to update current ones |
|
| 922 | + * @return boolean always return true |
|
| 923 | + * @access private |
|
| 924 | + */ |
|
| 925 | + function UpdateCookies($cookies) {
|
|
| 926 | + if (sizeof($this->cookies) == 0) {
|
|
| 927 | + // no existing cookies: take whatever is new |
|
| 928 | + if (sizeof($cookies) > 0) {
|
|
| 929 | + $this->debug('Setting new cookie(s)');
|
|
| 930 | + $this->cookies = $cookies; |
|
| 931 | + } |
|
| 932 | + return true; |
|
| 933 | + } |
|
| 934 | + if (sizeof($cookies) == 0) {
|
|
| 935 | + // no new cookies: keep what we've got |
|
| 936 | + return true; |
|
| 937 | + } |
|
| 938 | + // merge |
|
| 939 | + foreach ($cookies as $newCookie) {
|
|
| 940 | + if (!is_array($newCookie)) {
|
|
| 941 | + continue; |
|
| 942 | + } |
|
| 943 | + if ((!isset($newCookie['name'])) || (!isset($newCookie['value']))) {
|
|
| 944 | + continue; |
|
| 945 | + } |
|
| 946 | + $newName = $newCookie['name']; |
|
| 947 | + |
|
| 948 | + $found = false; |
|
| 949 | + for ($i = 0; $i < count($this->cookies); $i++) {
|
|
| 950 | + $cookie = $this->cookies[$i]; |
|
| 951 | + if (!is_array($cookie)) {
|
|
| 952 | + continue; |
|
| 953 | + } |
|
| 954 | + if (!isset($cookie['name'])) {
|
|
| 955 | + continue; |
|
| 956 | + } |
|
| 957 | + if ($newName != $cookie['name']) {
|
|
| 958 | + continue; |
|
| 959 | + } |
|
| 960 | + $newDomain = isset($newCookie['domain']) ? $newCookie['domain'] : 'NODOMAIN'; |
|
| 961 | + $domain = isset($cookie['domain']) ? $cookie['domain'] : 'NODOMAIN'; |
|
| 962 | + if ($newDomain != $domain) {
|
|
| 963 | + continue; |
|
| 964 | + } |
|
| 965 | + $newPath = isset($newCookie['path']) ? $newCookie['path'] : 'NOPATH'; |
|
| 966 | + $path = isset($cookie['path']) ? $cookie['path'] : 'NOPATH'; |
|
| 967 | + if ($newPath != $path) {
|
|
| 968 | + continue; |
|
| 969 | + } |
|
| 970 | + $this->cookies[$i] = $newCookie; |
|
| 971 | + $found = true; |
|
| 972 | + $this->debug('Update cookie ' . $newName . '=' . $newCookie['value']);
|
|
| 973 | + break; |
|
| 974 | + } |
|
| 975 | + if (! $found) {
|
|
| 976 | + $this->debug('Add cookie ' . $newName . '=' . $newCookie['value']);
|
|
| 977 | + $this->cookies[] = $newCookie; |
|
| 978 | + } |
|
| 979 | + } |
|
| 980 | + return true; |
|
| 981 | + } |
|
| 982 | 982 | } |
| 983 | 983 | |
| 984 | 984 | if (!extension_loaded('soap')) {
|
| 985 | - /** |
|
| 986 | - * For backwards compatiblity, define soapclient unless the PHP SOAP extension is loaded. |
|
| 987 | - */ |
|
| 988 | - class soapclient extends nusoap_client {
|
|
| 989 | - } |
|
| 985 | + /** |
|
| 986 | + * For backwards compatiblity, define soapclient unless the PHP SOAP extension is loaded. |
|
| 987 | + */ |
|
| 988 | + class soapclient extends nusoap_client {
|
|
| 989 | + } |
|
| 990 | 990 | } |
| 991 | 991 | ?> |
@@ -23,39 +23,39 @@ discard block |
||
| 23 | 23 | * @version $Id: class.soapclient.php,v 1.69 2010/04/26 20:15:08 snichol Exp $ |
| 24 | 24 | * @access public |
| 25 | 25 | */ |
| 26 | -class nusoap_client extends nusoap_base {
|
|
| 27 | - |
|
| 28 | - var $username = ''; // Username for HTTP authentication |
|
| 29 | - var $password = ''; // Password for HTTP authentication |
|
| 30 | - var $authtype = ''; // Type of HTTP authentication |
|
| 31 | - var $certRequest = array(); // Certificate for HTTP SSL authentication |
|
| 32 | - var $requestHeaders = false; // SOAP headers in request (text) |
|
| 33 | - var $responseHeaders = ''; // SOAP headers from response (incomplete namespace resolution) (text) |
|
| 34 | - var $responseHeader = NULL; // SOAP Header from response (parsed) |
|
| 35 | - var $document = ''; // SOAP body response portion (incomplete namespace resolution) (text) |
|
| 26 | +class nusoap_client extends nusoap_base {
|
|
| 27 | + |
|
| 28 | + var $username = ''; // Username for HTTP authentication |
|
| 29 | + var $password = ''; // Password for HTTP authentication |
|
| 30 | + var $authtype = ''; // Type of HTTP authentication |
|
| 31 | + var $certRequest = array(); // Certificate for HTTP SSL authentication |
|
| 32 | + var $requestHeaders = false; // SOAP headers in request (text) |
|
| 33 | + var $responseHeaders = ''; // SOAP headers from response (incomplete namespace resolution) (text) |
|
| 34 | + var $responseHeader = NULL; // SOAP Header from response (parsed) |
|
| 35 | + var $document = ''; // SOAP body response portion (incomplete namespace resolution) (text) |
|
| 36 | 36 | var $endpoint; |
| 37 | - var $forceEndpoint = ''; // overrides WSDL endpoint |
|
| 37 | + var $forceEndpoint = ''; // overrides WSDL endpoint |
|
| 38 | 38 | var $proxyhost = ''; |
| 39 | 39 | var $proxyport = ''; |
| 40 | 40 | var $proxyusername = ''; |
| 41 | 41 | var $proxypassword = ''; |
| 42 | - var $portName = ''; // port name to use in WSDL |
|
| 43 | - var $xml_encoding = ''; // character set encoding of incoming (response) messages |
|
| 42 | + var $portName = ''; // port name to use in WSDL |
|
| 43 | + var $xml_encoding = ''; // character set encoding of incoming (response) messages |
|
| 44 | 44 | var $http_encoding = false; |
| 45 | - var $timeout = 0; // HTTP connection timeout |
|
| 46 | - var $response_timeout = 30; // HTTP response timeout |
|
| 47 | - var $endpointType = ''; // soap|wsdl, empty for WSDL initialization error |
|
| 45 | + var $timeout = 0; // HTTP connection timeout |
|
| 46 | + var $response_timeout = 30; // HTTP response timeout |
|
| 47 | + var $endpointType = ''; // soap|wsdl, empty for WSDL initialization error |
|
| 48 | 48 | var $persistentConnection = false; |
| 49 | - var $defaultRpcParams = false; // This is no longer used |
|
| 50 | - var $request = ''; // HTTP request |
|
| 51 | - var $response = ''; // HTTP response |
|
| 52 | - var $responseData = ''; // SOAP payload of response |
|
| 53 | - var $cookies = array(); // Cookies from response or for request |
|
| 54 | - var $decode_utf8 = true; // toggles whether the parser decodes element content w/ utf8_decode() |
|
| 55 | - var $operations = array(); // WSDL operations, empty for WSDL initialization error |
|
| 56 | - var $curl_options = array(); // User-specified cURL options |
|
| 57 | - var $bindingType = ''; // WSDL operation binding type |
|
| 58 | - var $use_curl = false; // whether to always try to use cURL |
|
| 49 | + var $defaultRpcParams = false; // This is no longer used |
|
| 50 | + var $request = ''; // HTTP request |
|
| 51 | + var $response = ''; // HTTP response |
|
| 52 | + var $responseData = ''; // SOAP payload of response |
|
| 53 | + var $cookies = array(); // Cookies from response or for request |
|
| 54 | + var $decode_utf8 = true; // toggles whether the parser decodes element content w/ utf8_decode() |
|
| 55 | + var $operations = array(); // WSDL operations, empty for WSDL initialization error |
|
| 56 | + var $curl_options = array(); // User-specified cURL options |
|
| 57 | + var $bindingType = ''; // WSDL operation binding type |
|
| 58 | + var $use_curl = false; // whether to always try to use cURL |
|
| 59 | 59 | |
| 60 | 60 | /* |
| 61 | 61 | * fault related variables |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @param string $portName optional portName in WSDL document |
| 96 | 96 | * @access public |
| 97 | 97 | */ |
| 98 | - function nusoap_client($endpoint,$wsdl = false,$proxyhost = false,$proxyport = false,$proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = ''){
|
|
| 98 | + function nusoap_client($endpoint, $wsdl = false, $proxyhost = false, $proxyport = false, $proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = '') {
|
|
| 99 | 99 | parent::nusoap_base(); |
| 100 | 100 | $this->endpoint = $endpoint; |
| 101 | 101 | $this->proxyhost = $proxyhost; |
@@ -107,20 +107,20 @@ discard block |
||
| 107 | 107 | $this->portName = $portName; |
| 108 | 108 | |
| 109 | 109 | $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
|
| 110 | - $this->appendDebug('endpoint=' . $this->varDump($endpoint));
|
|
| 110 | + $this->appendDebug('endpoint='.$this->varDump($endpoint));
|
|
| 111 | 111 | |
| 112 | 112 | // make values |
| 113 | - if($wsdl){
|
|
| 113 | + if ($wsdl) {
|
|
| 114 | 114 | if (is_object($endpoint) && (get_class($endpoint) == 'wsdl')) {
|
| 115 | 115 | $this->wsdl = $endpoint; |
| 116 | 116 | $this->endpoint = $this->wsdl->wsdl; |
| 117 | 117 | $this->wsdlFile = $this->endpoint; |
| 118 | - $this->debug('existing wsdl instance created from ' . $this->endpoint);
|
|
| 118 | + $this->debug('existing wsdl instance created from '.$this->endpoint);
|
|
| 119 | 119 | $this->checkWSDL(); |
| 120 | 120 | } else {
|
| 121 | 121 | $this->wsdlFile = $this->endpoint; |
| 122 | 122 | $this->wsdl = null; |
| 123 | - $this->debug('will use lazy evaluation of wsdl from ' . $this->endpoint);
|
|
| 123 | + $this->debug('will use lazy evaluation of wsdl from '.$this->endpoint);
|
|
| 124 | 124 | } |
| 125 | 125 | $this->endpointType = 'wsdl'; |
| 126 | 126 | } else {
|
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @return mixed response from SOAP call, normally an associative array mirroring the structure of the XML response, false for certain fatal errors |
| 155 | 155 | * @access public |
| 156 | 156 | */ |
| 157 | - function call($operation,$params=array(),$namespace='http://tempuri.org',$soapAction='',$headers=false,$rpcParams=null,$style='rpc',$use='encoded'){
|
|
| 157 | + function call($operation, $params = array(), $namespace = 'http://tempuri.org', $soapAction = '', $headers = false, $rpcParams = null, $style = 'rpc', $use = 'encoded') {
|
|
| 158 | 158 | $this->operation = $operation; |
| 159 | 159 | $this->fault = false; |
| 160 | 160 | $this->setError('');
|
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | $this->opData = array(); |
| 167 | 167 | |
| 168 | 168 | $this->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType");
|
| 169 | - $this->appendDebug('params=' . $this->varDump($params));
|
|
| 170 | - $this->appendDebug('headers=' . $this->varDump($headers));
|
|
| 169 | + $this->appendDebug('params='.$this->varDump($params));
|
|
| 170 | + $this->appendDebug('headers='.$this->varDump($headers));
|
|
| 171 | 171 | if ($headers) {
|
| 172 | 172 | $this->requestHeaders = $headers; |
| 173 | 173 | } |
@@ -177,25 +177,25 @@ discard block |
||
| 177 | 177 | return false; |
| 178 | 178 | } |
| 179 | 179 | // serialize parameters |
| 180 | - if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){
|
|
| 180 | + if ($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)) {
|
|
| 181 | 181 | // use WSDL for operation |
| 182 | 182 | $this->opData = $opData; |
| 183 | 183 | $this->debug("found operation");
|
| 184 | - $this->appendDebug('opData=' . $this->varDump($opData));
|
|
| 184 | + $this->appendDebug('opData='.$this->varDump($opData));
|
|
| 185 | 185 | if (isset($opData['soapAction'])) {
|
| 186 | 186 | $soapAction = $opData['soapAction']; |
| 187 | 187 | } |
| 188 | - if (! $this->forceEndpoint) {
|
|
| 188 | + if (!$this->forceEndpoint) {
|
|
| 189 | 189 | $this->endpoint = $opData['endpoint']; |
| 190 | 190 | } else {
|
| 191 | 191 | $this->endpoint = $this->forceEndpoint; |
| 192 | 192 | } |
| 193 | - $namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] : $namespace; |
|
| 193 | + $namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] : $namespace; |
|
| 194 | 194 | $style = $opData['style']; |
| 195 | 195 | $use = $opData['input']['use']; |
| 196 | 196 | // add ns to ns array |
| 197 | - if($namespace != '' && !isset($this->wsdl->namespaces[$namespace])){
|
|
| 198 | - $nsPrefix = 'ns' . rand(1000, 9999); |
|
| 197 | + if ($namespace != '' && !isset($this->wsdl->namespaces[$namespace])) {
|
|
| 198 | + $nsPrefix = 'ns'.rand(1000, 9999); |
|
| 199 | 199 | $this->wsdl->namespaces[$nsPrefix] = $namespace; |
| 200 | 200 | } |
| 201 | 201 | $nsPrefix = $this->wsdl->getPrefixFromNamespace($namespace); |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | $payload = $params; |
| 206 | 206 | } elseif (is_array($params)) {
|
| 207 | 207 | $this->debug("serializing param array for WSDL operation $operation");
|
| 208 | - $payload = $this->wsdl->serializeRPCParameters($operation,'input',$params,$this->bindingType); |
|
| 208 | + $payload = $this->wsdl->serializeRPCParameters($operation, 'input', $params, $this->bindingType); |
|
| 209 | 209 | } else {
|
| 210 | 210 | $this->debug('params must be array or string');
|
| 211 | 211 | $this->setError('params must be array or string');
|
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | $this->setError('wsdl error: '.$errstr);
|
| 225 | 225 | return false; |
| 226 | 226 | } |
| 227 | - } elseif($this->endpointType == 'wsdl') {
|
|
| 227 | + } elseif ($this->endpointType == 'wsdl') {
|
|
| 228 | 228 | // operation not in WSDL |
| 229 | 229 | $this->appendDebug($this->wsdl->getDebug()); |
| 230 | 230 | $this->wsdl->clearDebug(); |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | } else {
|
| 235 | 235 | // no WSDL |
| 236 | 236 | //$this->namespaces['ns1'] = $namespace; |
| 237 | - $nsPrefix = 'ns' . rand(1000, 9999); |
|
| 237 | + $nsPrefix = 'ns'.rand(1000, 9999); |
|
| 238 | 238 | // serialize |
| 239 | 239 | $payload = ''; |
| 240 | 240 | if (is_string($params)) {
|
@@ -242,8 +242,8 @@ discard block |
||
| 242 | 242 | $payload = $params; |
| 243 | 243 | } elseif (is_array($params)) {
|
| 244 | 244 | $this->debug("serializing param array for operation $operation");
|
| 245 | - foreach($params as $k => $v){
|
|
| 246 | - $payload .= $this->serialize_val($v,$k,false,false,false,false,$use); |
|
| 245 | + foreach ($params as $k => $v) {
|
|
| 246 | + $payload .= $this->serialize_val($v, $k, false, false, false, false, $use); |
|
| 247 | 247 | } |
| 248 | 248 | } else {
|
| 249 | 249 | $this->debug('params must be array or string');
|
@@ -263,45 +263,45 @@ discard block |
||
| 263 | 263 | $this->debug("wrapping RPC request with literal method element");
|
| 264 | 264 | if ($namespace) {
|
| 265 | 265 | // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace |
| 266 | - $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . |
|
| 267 | - $payload . |
|
| 266 | + $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">". |
|
| 267 | + $payload. |
|
| 268 | 268 | "</$nsPrefix:$operation>"; |
| 269 | 269 | } else {
|
| 270 | - $payload = "<$operation>" . $payload . "</$operation>"; |
|
| 270 | + $payload = "<$operation>".$payload."</$operation>"; |
|
| 271 | 271 | } |
| 272 | 272 | } else {
|
| 273 | 273 | $this->debug("wrapping RPC request with encoded method element");
|
| 274 | 274 | if ($namespace) {
|
| 275 | - $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . |
|
| 276 | - $payload . |
|
| 275 | + $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">". |
|
| 276 | + $payload. |
|
| 277 | 277 | "</$nsPrefix:$operation>"; |
| 278 | 278 | } else {
|
| 279 | - $payload = "<$operation>" . |
|
| 280 | - $payload . |
|
| 279 | + $payload = "<$operation>". |
|
| 280 | + $payload. |
|
| 281 | 281 | "</$operation>"; |
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | // serialize envelope |
| 286 | - $soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders,$usedNamespaces,$style,$use,$encodingStyle); |
|
| 286 | + $soapmsg = $this->serializeEnvelope($payload, $this->requestHeaders, $usedNamespaces, $style, $use, $encodingStyle); |
|
| 287 | 287 | $this->debug("endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style, use=$use, encodingStyle=$encodingStyle");
|
| 288 | - $this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000));
|
|
| 288 | + $this->debug('SOAP message length='.strlen($soapmsg).' contents (max 1000 bytes)='.substr($soapmsg, 0, 1000));
|
|
| 289 | 289 | // send |
| 290 | - $return = $this->send($this->getHTTPBody($soapmsg),$soapAction,$this->timeout,$this->response_timeout); |
|
| 291 | - if($errstr = $this->getError()){
|
|
| 290 | + $return = $this->send($this->getHTTPBody($soapmsg), $soapAction, $this->timeout, $this->response_timeout); |
|
| 291 | + if ($errstr = $this->getError()) {
|
|
| 292 | 292 | $this->debug('Error: '.$errstr);
|
| 293 | 293 | return false; |
| 294 | 294 | } else {
|
| 295 | 295 | $this->return = $return; |
| 296 | 296 | $this->debug('sent message successfully and got a(n) '.gettype($return));
|
| 297 | - $this->appendDebug('return=' . $this->varDump($return));
|
|
| 297 | + $this->appendDebug('return='.$this->varDump($return));
|
|
| 298 | 298 | |
| 299 | 299 | // fault? |
| 300 | - if(is_array($return) && isset($return['faultcode'])){
|
|
| 300 | + if (is_array($return) && isset($return['faultcode'])) {
|
|
| 301 | 301 | $this->debug('got fault');
|
| 302 | 302 | $this->setError($return['faultcode'].': '.$return['faultstring']); |
| 303 | 303 | $this->fault = true; |
| 304 | - foreach($return as $k => $v){
|
|
| 304 | + foreach ($return as $k => $v) {
|
|
| 305 | 305 | $this->$k = $v; |
| 306 | 306 | $this->debug("$k = $v<br>");
|
| 307 | 307 | } |
@@ -312,10 +312,10 @@ discard block |
||
| 312 | 312 | return $return; |
| 313 | 313 | } else {
|
| 314 | 314 | // array of return values |
| 315 | - if(is_array($return)){
|
|
| 315 | + if (is_array($return)) {
|
|
| 316 | 316 | // multiple 'out' parameters, which we return wrapped up |
| 317 | 317 | // in the array |
| 318 | - if(sizeof($return) > 1){
|
|
| 318 | + if (sizeof($return) > 1) {
|
|
| 319 | 319 | return $return; |
| 320 | 320 | } |
| 321 | 321 | // single 'out' parameter (normally the return value) |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | */ |
| 373 | 373 | function loadWSDL() {
|
| 374 | 374 | $this->debug('instantiating wsdl class with doc: '.$this->wsdlFile);
|
| 375 | - $this->wsdl = new wsdl('',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout,$this->curl_options,$this->use_curl);
|
|
| 375 | + $this->wsdl = new wsdl('', $this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword, $this->timeout, $this->response_timeout, $this->curl_options, $this->use_curl);
|
|
| 376 | 376 | $this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest); |
| 377 | 377 | $this->wsdl->fetchWSDL($this->wsdlFile); |
| 378 | 378 | $this->checkWSDL(); |
@@ -385,13 +385,13 @@ discard block |
||
| 385 | 385 | * @return array array of data pertaining to the operation |
| 386 | 386 | * @access public |
| 387 | 387 | */ |
| 388 | - function getOperationData($operation){
|
|
| 388 | + function getOperationData($operation) {
|
|
| 389 | 389 | if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
|
| 390 | 390 | $this->loadWSDL(); |
| 391 | 391 | if ($this->getError()) |
| 392 | 392 | return false; |
| 393 | 393 | } |
| 394 | - if(isset($this->operations[$operation])){
|
|
| 394 | + if (isset($this->operations[$operation])) {
|
|
| 395 | 395 | return $this->operations[$operation]; |
| 396 | 396 | } |
| 397 | 397 | $this->debug("No data for operation: $operation");
|
@@ -411,15 +411,15 @@ discard block |
||
| 411 | 411 | * @return mixed native PHP types. |
| 412 | 412 | * @access private |
| 413 | 413 | */ |
| 414 | - function send($msg, $soapaction = '', $timeout=0, $response_timeout=30) {
|
|
| 414 | + function send($msg, $soapaction = '', $timeout = 0, $response_timeout = 30) {
|
|
| 415 | 415 | $this->checkCookies(); |
| 416 | 416 | // detect transport |
| 417 | - switch(true){
|
|
| 417 | + switch (true) {
|
|
| 418 | 418 | // http(s) |
| 419 | - case preg_match('/^http/',$this->endpoint):
|
|
| 419 | + case preg_match('/^http/', $this->endpoint):
|
|
| 420 | 420 | $this->debug('transporting via HTTP');
|
| 421 | - if($this->persistentConnection == true && is_object($this->persistentConnection)){
|
|
| 422 | - $http =& $this->persistentConnection; |
|
| 421 | + if ($this->persistentConnection == true && is_object($this->persistentConnection)) {
|
|
| 422 | + $http = & $this->persistentConnection; |
|
| 423 | 423 | } else {
|
| 424 | 424 | $http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl); |
| 425 | 425 | if ($this->persistentConnection) {
|
@@ -428,27 +428,27 @@ discard block |
||
| 428 | 428 | } |
| 429 | 429 | $http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset()); |
| 430 | 430 | $http->setSOAPAction($soapaction); |
| 431 | - if($this->proxyhost && $this->proxyport){
|
|
| 432 | - $http->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword); |
|
| 431 | + if ($this->proxyhost && $this->proxyport) {
|
|
| 432 | + $http->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword); |
|
| 433 | 433 | } |
| 434 | - if($this->authtype != '') {
|
|
| 434 | + if ($this->authtype != '') {
|
|
| 435 | 435 | $http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest); |
| 436 | 436 | } |
| 437 | - if($this->http_encoding != ''){
|
|
| 437 | + if ($this->http_encoding != '') {
|
|
| 438 | 438 | $http->setEncoding($this->http_encoding); |
| 439 | 439 | } |
| 440 | 440 | $this->debug('sending message, length='.strlen($msg));
|
| 441 | - if(preg_match('/^http:/',$this->endpoint)){
|
|
| 441 | + if (preg_match('/^http:/', $this->endpoint)) {
|
|
| 442 | 442 | //if(strpos($this->endpoint,'http:')){
|
| 443 | - $this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies); |
|
| 444 | - } elseif(preg_match('/^https/',$this->endpoint)){
|
|
| 443 | + $this->responseData = $http->send($msg, $timeout, $response_timeout, $this->cookies); |
|
| 444 | + } elseif (preg_match('/^https/', $this->endpoint)) {
|
|
| 445 | 445 | //} elseif(strpos($this->endpoint,'https:')){
|
| 446 | 446 | //if(phpversion() == '4.3.0-dev'){
|
| 447 | 447 | //$response = $http->send($msg,$timeout,$response_timeout); |
| 448 | 448 | //$this->request = $http->outgoing_payload; |
| 449 | 449 | //$this->response = $http->incoming_payload; |
| 450 | 450 | //} else |
| 451 | - $this->responseData = $http->sendHTTPS($msg,$timeout,$response_timeout,$this->cookies); |
|
| 451 | + $this->responseData = $http->sendHTTPS($msg, $timeout, $response_timeout, $this->cookies); |
|
| 452 | 452 | } else {
|
| 453 | 453 | $this->setError('no http/s in endpoint url');
|
| 454 | 454 | } |
@@ -465,13 +465,13 @@ discard block |
||
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - if($err = $http->getError()){
|
|
| 468 | + if ($err = $http->getError()) {
|
|
| 469 | 469 | $this->setError('HTTP Error: '.$err);
|
| 470 | 470 | return false; |
| 471 | - } elseif($this->getError()){
|
|
| 471 | + } elseif ($this->getError()) {
|
|
| 472 | 472 | return false; |
| 473 | 473 | } else {
|
| 474 | - $this->debug('got response, length='. strlen($this->responseData).' type='.$http->incoming_headers['content-type']);
|
|
| 474 | + $this->debug('got response, length='.strlen($this->responseData).' type='.$http->incoming_headers['content-type']);
|
|
| 475 | 475 | return $this->parseResponse($http->incoming_headers, $this->responseData); |
| 476 | 476 | } |
| 477 | 477 | break; |
@@ -491,20 +491,20 @@ discard block |
||
| 491 | 491 | * @access private |
| 492 | 492 | */ |
| 493 | 493 | function parseResponse($headers, $data) {
|
| 494 | - $this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:');
|
|
| 494 | + $this->debug('Entering parseResponse() for data of length '.strlen($data).' headers:');
|
|
| 495 | 495 | $this->appendDebug($this->varDump($headers)); |
| 496 | 496 | if (!isset($headers['content-type'])) {
|
| 497 | 497 | $this->setError('Response not of type text/xml (no content-type header)');
|
| 498 | 498 | return false; |
| 499 | 499 | } |
| 500 | 500 | if (!strstr($headers['content-type'], 'text/xml')) {
|
| 501 | - $this->setError('Response not of type text/xml: ' . $headers['content-type']);
|
|
| 501 | + $this->setError('Response not of type text/xml: '.$headers['content-type']);
|
|
| 502 | 502 | return false; |
| 503 | 503 | } |
| 504 | 504 | if (strpos($headers['content-type'], '=')) {
|
| 505 | 505 | $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
|
| 506 | - $this->debug('Got response encoding: ' . $enc);
|
|
| 507 | - if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
|
|
| 506 | + $this->debug('Got response encoding: '.$enc);
|
|
| 507 | + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
|
|
| 508 | 508 | $this->xml_encoding = strtoupper($enc); |
| 509 | 509 | } else {
|
| 510 | 510 | $this->xml_encoding = 'US-ASCII'; |
@@ -513,13 +513,13 @@ discard block |
||
| 513 | 513 | // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 |
| 514 | 514 | $this->xml_encoding = 'ISO-8859-1'; |
| 515 | 515 | } |
| 516 | - $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
|
|
| 517 | - $parser = new nusoap_parser($data,$this->xml_encoding,$this->operation,$this->decode_utf8); |
|
| 516 | + $this->debug('Use encoding: '.$this->xml_encoding.' when creating nusoap_parser');
|
|
| 517 | + $parser = new nusoap_parser($data, $this->xml_encoding, $this->operation, $this->decode_utf8); |
|
| 518 | 518 | // add parser debug data to our debug |
| 519 | 519 | $this->appendDebug($parser->getDebug()); |
| 520 | 520 | // if parse errors |
| 521 | - if($errstr = $parser->getError()){
|
|
| 522 | - $this->setError( $errstr); |
|
| 521 | + if ($errstr = $parser->getError()) {
|
|
| 522 | + $this->setError($errstr); |
|
| 523 | 523 | // destroy the parser object |
| 524 | 524 | unset($parser); |
| 525 | 525 | return false; |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | * @param mixed $headers String of XML with SOAP header content, or array of soapval objects for SOAP headers |
| 570 | 570 | * @access public |
| 571 | 571 | */ |
| 572 | - function setHeaders($headers){
|
|
| 572 | + function setHeaders($headers) {
|
|
| 573 | 573 | $this->debug("setHeaders headers=");
|
| 574 | 574 | $this->appendDebug($this->varDump($headers)); |
| 575 | 575 | $this->requestHeaders = $headers; |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | * @return string |
| 582 | 582 | * @access public |
| 583 | 583 | */ |
| 584 | - function getHeaders(){
|
|
| 584 | + function getHeaders() {
|
|
| 585 | 585 | return $this->responseHeaders; |
| 586 | 586 | } |
| 587 | 587 | |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | * @return mixed |
| 592 | 592 | * @access public |
| 593 | 593 | */ |
| 594 | - function getHeader(){
|
|
| 594 | + function getHeader() {
|
|
| 595 | 595 | return $this->responseHeader; |
| 596 | 596 | } |
| 597 | 597 | |
@@ -635,7 +635,7 @@ discard block |
||
| 635 | 635 | * @param string $enc HTTP encoding |
| 636 | 636 | * @access public |
| 637 | 637 | */ |
| 638 | - function setHTTPEncoding($enc='gzip, deflate'){
|
|
| 638 | + function setHTTPEncoding($enc = 'gzip, deflate') {
|
|
| 639 | 639 | $this->debug("setHTTPEncoding(\"$enc\")");
|
| 640 | 640 | $this->http_encoding = $enc; |
| 641 | 641 | } |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | * |
| 657 | 657 | * @access public |
| 658 | 658 | */ |
| 659 | - function useHTTPPersistentConnection(){
|
|
| 659 | + function useHTTPPersistentConnection() {
|
|
| 660 | 660 | $this->debug("useHTTPPersistentConnection");
|
| 661 | 661 | $this->persistentConnection = true; |
| 662 | 662 | } |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | */ |
| 749 | 749 | function _getProxyClassCode($r) {
|
| 750 | 750 | $this->debug("in getProxy endpointType=$this->endpointType");
|
| 751 | - $this->appendDebug("wsdl=" . $this->varDump($this->wsdl));
|
|
| 751 | + $this->appendDebug("wsdl=".$this->varDump($this->wsdl));
|
|
| 752 | 752 | if ($this->endpointType != 'wsdl') {
|
| 753 | 753 | $evalStr = 'A proxy can only be created for a WSDL client'; |
| 754 | 754 | $this->setError($evalStr); |
@@ -758,7 +758,7 @@ discard block |
||
| 758 | 758 | if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
|
| 759 | 759 | $this->loadWSDL(); |
| 760 | 760 | if ($this->getError()) {
|
| 761 | - return "echo \"" . $this->getError() . "\";"; |
|
| 761 | + return "echo \"".$this->getError()."\";"; |
|
| 762 | 762 | } |
| 763 | 763 | } |
| 764 | 764 | $evalStr = ''; |
@@ -774,9 +774,9 @@ discard block |
||
| 774 | 774 | $paramArrayStr .= "'$name' => \$$name, "; |
| 775 | 775 | $paramCommentStr .= "$type \$$name, "; |
| 776 | 776 | } |
| 777 | - $paramStr = substr($paramStr, 0, strlen($paramStr)-2); |
|
| 778 | - $paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr)-2); |
|
| 779 | - $paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr)-2); |
|
| 777 | + $paramStr = substr($paramStr, 0, strlen($paramStr) - 2); |
|
| 778 | + $paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr) - 2); |
|
| 779 | + $paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr) - 2); |
|
| 780 | 780 | } else {
|
| 781 | 781 | $paramStr = ''; |
| 782 | 782 | $paramArrayStr = ''; |
@@ -784,7 +784,7 @@ discard block |
||
| 784 | 784 | } |
| 785 | 785 | $opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace']; |
| 786 | 786 | $evalStr .= "// $paramCommentStr |
| 787 | - function " . str_replace('.', '__', $operation) . "($paramStr) {
|
|
| 787 | + function ".str_replace('.', '__', $operation)."($paramStr) {
|
|
| 788 | 788 | \$params = array($paramArrayStr); |
| 789 | 789 | return \$this->call('$operation', \$params, '".$opData['namespace']."', '".(isset($opData['soapAction']) ? $opData['soapAction'] : '')."');
|
| 790 | 790 | } |
@@ -852,7 +852,7 @@ discard block |
||
| 852 | 852 | * @return always returns true |
| 853 | 853 | * @access public |
| 854 | 854 | */ |
| 855 | - function decodeUTF8($bool){
|
|
| 855 | + function decodeUTF8($bool) {
|
|
| 856 | 856 | $this->decode_utf8 = $bool; |
| 857 | 857 | return true; |
| 858 | 858 | } |
@@ -893,19 +893,19 @@ discard block |
||
| 893 | 893 | if (sizeof($this->cookies) == 0) {
|
| 894 | 894 | return true; |
| 895 | 895 | } |
| 896 | - $this->debug('checkCookie: check ' . sizeof($this->cookies) . ' cookies');
|
|
| 896 | + $this->debug('checkCookie: check '.sizeof($this->cookies).' cookies');
|
|
| 897 | 897 | $curr_cookies = $this->cookies; |
| 898 | 898 | $this->cookies = array(); |
| 899 | 899 | foreach ($curr_cookies as $cookie) {
|
| 900 | - if (! is_array($cookie)) {
|
|
| 900 | + if (!is_array($cookie)) {
|
|
| 901 | 901 | $this->debug('Remove cookie that is not an array');
|
| 902 | 902 | continue; |
| 903 | 903 | } |
| 904 | - if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
|
|
| 904 | + if ((isset($cookie['expires'])) && (!empty($cookie['expires']))) {
|
|
| 905 | 905 | if (strtotime($cookie['expires']) > time()) {
|
| 906 | 906 | $this->cookies[] = $cookie; |
| 907 | 907 | } else {
|
| 908 | - $this->debug('Remove expired cookie ' . $cookie['name']);
|
|
| 908 | + $this->debug('Remove expired cookie '.$cookie['name']);
|
|
| 909 | 909 | } |
| 910 | 910 | } else {
|
| 911 | 911 | $this->cookies[] = $cookie; |
@@ -969,11 +969,11 @@ discard block |
||
| 969 | 969 | } |
| 970 | 970 | $this->cookies[$i] = $newCookie; |
| 971 | 971 | $found = true; |
| 972 | - $this->debug('Update cookie ' . $newName . '=' . $newCookie['value']);
|
|
| 972 | + $this->debug('Update cookie '.$newName.'='.$newCookie['value']);
|
|
| 973 | 973 | break; |
| 974 | 974 | } |
| 975 | - if (! $found) {
|
|
| 976 | - $this->debug('Add cookie ' . $newName . '=' . $newCookie['value']);
|
|
| 975 | + if (!$found) {
|
|
| 976 | + $this->debug('Add cookie '.$newName.'='.$newCookie['value']);
|
|
| 977 | 977 | $this->cookies[] = $newCookie; |
| 978 | 978 | } |
| 979 | 979 | } |
@@ -173,8 +173,9 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
|
| 175 | 175 | $this->loadWSDL(); |
| 176 | - if ($this->getError()) |
|
| 177 | - return false; |
|
| 176 | + if ($this->getError()) { |
|
| 177 | + return false; |
|
| 178 | + } |
|
| 178 | 179 | } |
| 179 | 180 | // serialize parameters |
| 180 | 181 | if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){
|
@@ -388,8 +389,9 @@ discard block |
||
| 388 | 389 | function getOperationData($operation){
|
| 389 | 390 | if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
|
| 390 | 391 | $this->loadWSDL(); |
| 391 | - if ($this->getError()) |
|
| 392 | - return false; |
|
| 392 | + if ($this->getError()) { |
|
| 393 | + return false; |
|
| 394 | + } |
|
| 393 | 395 | } |
| 394 | 396 | if(isset($this->operations[$operation])){
|
| 395 | 397 | return $this->operations[$operation]; |
@@ -883,7 +883,7 @@ discard block |
||
| 883 | 883 | /** |
| 884 | 884 | * serialize the parsed wsdl |
| 885 | 885 | * |
| 886 | - * @param mixed $debug whether to put debug=1 in endpoint URL |
|
| 886 | + * @param integer $debug whether to put debug=1 in endpoint URL |
|
| 887 | 887 | * @return string serialization of WSDL |
| 888 | 888 | * @access public |
| 889 | 889 | */ |
@@ -1106,7 +1106,7 @@ discard block |
||
| 1106 | 1106 | * @param string $direction (input|output) |
| 1107 | 1107 | * @param mixed $parameters parameter value(s) |
| 1108 | 1108 | * @param string $bindingType (soap|soap12) |
| 1109 | - * @return mixed parameters serialized as XML or false on error (e.g. operation not found) |
|
| 1109 | + * @return false|string parameters serialized as XML or false on error (e.g. operation not found) |
|
| 1110 | 1110 | * @access public |
| 1111 | 1111 | */ |
| 1112 | 1112 | function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') {
|
@@ -1206,7 +1206,7 @@ discard block |
||
| 1206 | 1206 | * @param string $operation operation name |
| 1207 | 1207 | * @param string $direction (input|output) |
| 1208 | 1208 | * @param mixed $parameters parameter value(s) |
| 1209 | - * @return mixed parameters serialized as XML or false on error (e.g. operation not found) |
|
| 1209 | + * @return false|string parameters serialized as XML or false on error (e.g. operation not found) |
|
| 1210 | 1210 | * @access public |
| 1211 | 1211 | * @deprecated |
| 1212 | 1212 | */ |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * @access public |
| 14 | 14 | */ |
| 15 | 15 | class wsdl extends nusoap_base {
|
| 16 | - // URL or filename of the root of this WSDL |
|
| 16 | + // URL or filename of the root of this WSDL |
|
| 17 | 17 | var $wsdl; |
| 18 | 18 | // define internal arrays of bindings, ports, operations, messages, etc. |
| 19 | 19 | var $schemas = array(); |
@@ -40,142 +40,142 @@ discard block |
||
| 40 | 40 | var $position = 0; |
| 41 | 41 | var $depth = 0; |
| 42 | 42 | var $depth_array = array(); |
| 43 | - // for getting wsdl |
|
| 44 | - var $proxyhost = ''; |
|
| 43 | + // for getting wsdl |
|
| 44 | + var $proxyhost = ''; |
|
| 45 | 45 | var $proxyport = ''; |
| 46 | - var $proxyusername = ''; |
|
| 47 | - var $proxypassword = ''; |
|
| 48 | - var $timeout = 0; |
|
| 49 | - var $response_timeout = 30; |
|
| 50 | - var $curl_options = array(); // User-specified cURL options |
|
| 51 | - var $use_curl = false; // whether to always try to use cURL |
|
| 52 | - // for HTTP authentication |
|
| 53 | - var $username = ''; // Username for HTTP authentication |
|
| 54 | - var $password = ''; // Password for HTTP authentication |
|
| 55 | - var $authtype = ''; // Type of HTTP authentication |
|
| 56 | - var $certRequest = array(); // Certificate for HTTP SSL authentication |
|
| 46 | + var $proxyusername = ''; |
|
| 47 | + var $proxypassword = ''; |
|
| 48 | + var $timeout = 0; |
|
| 49 | + var $response_timeout = 30; |
|
| 50 | + var $curl_options = array(); // User-specified cURL options |
|
| 51 | + var $use_curl = false; // whether to always try to use cURL |
|
| 52 | + // for HTTP authentication |
|
| 53 | + var $username = ''; // Username for HTTP authentication |
|
| 54 | + var $password = ''; // Password for HTTP authentication |
|
| 55 | + var $authtype = ''; // Type of HTTP authentication |
|
| 56 | + var $certRequest = array(); // Certificate for HTTP SSL authentication |
|
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * constructor |
| 60 | 60 | * |
| 61 | 61 | * @param string $wsdl WSDL document URL |
| 62 | - * @param string $proxyhost |
|
| 63 | - * @param string $proxyport |
|
| 64 | - * @param string $proxyusername |
|
| 65 | - * @param string $proxypassword |
|
| 66 | - * @param integer $timeout set the connection timeout |
|
| 67 | - * @param integer $response_timeout set the response timeout |
|
| 68 | - * @param array $curl_options user-specified cURL options |
|
| 69 | - * @param boolean $use_curl try to use cURL |
|
| 62 | + * @param string $proxyhost |
|
| 63 | + * @param string $proxyport |
|
| 64 | + * @param string $proxyusername |
|
| 65 | + * @param string $proxypassword |
|
| 66 | + * @param integer $timeout set the connection timeout |
|
| 67 | + * @param integer $response_timeout set the response timeout |
|
| 68 | + * @param array $curl_options user-specified cURL options |
|
| 69 | + * @param boolean $use_curl try to use cURL |
|
| 70 | 70 | * @access public |
| 71 | 71 | */ |
| 72 | 72 | function wsdl($wsdl = '',$proxyhost=false,$proxyport=false,$proxyusername=false,$proxypassword=false,$timeout=0,$response_timeout=30,$curl_options=null,$use_curl=false){
|
| 73 | - parent::nusoap_base(); |
|
| 74 | - $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
|
|
| 73 | + parent::nusoap_base(); |
|
| 74 | + $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
|
|
| 75 | 75 | $this->proxyhost = $proxyhost; |
| 76 | 76 | $this->proxyport = $proxyport; |
| 77 | - $this->proxyusername = $proxyusername; |
|
| 78 | - $this->proxypassword = $proxypassword; |
|
| 79 | - $this->timeout = $timeout; |
|
| 80 | - $this->response_timeout = $response_timeout; |
|
| 81 | - if (is_array($curl_options)) |
|
| 82 | - $this->curl_options = $curl_options; |
|
| 83 | - $this->use_curl = $use_curl; |
|
| 84 | - $this->fetchWSDL($wsdl); |
|
| 77 | + $this->proxyusername = $proxyusername; |
|
| 78 | + $this->proxypassword = $proxypassword; |
|
| 79 | + $this->timeout = $timeout; |
|
| 80 | + $this->response_timeout = $response_timeout; |
|
| 81 | + if (is_array($curl_options)) |
|
| 82 | + $this->curl_options = $curl_options; |
|
| 83 | + $this->use_curl = $use_curl; |
|
| 84 | + $this->fetchWSDL($wsdl); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * fetches the WSDL document and parses it |
|
| 89 | - * |
|
| 90 | - * @access public |
|
| 91 | - */ |
|
| 92 | - function fetchWSDL($wsdl) {
|
|
| 93 | - $this->debug("parse and process WSDL path=$wsdl");
|
|
| 94 | - $this->wsdl = $wsdl; |
|
| 87 | + /** |
|
| 88 | + * fetches the WSDL document and parses it |
|
| 89 | + * |
|
| 90 | + * @access public |
|
| 91 | + */ |
|
| 92 | + function fetchWSDL($wsdl) {
|
|
| 93 | + $this->debug("parse and process WSDL path=$wsdl");
|
|
| 94 | + $this->wsdl = $wsdl; |
|
| 95 | 95 | // parse wsdl file |
| 96 | 96 | if ($this->wsdl != "") {
|
| 97 | 97 | $this->parseWSDL($this->wsdl); |
| 98 | 98 | } |
| 99 | 99 | // imports |
| 100 | 100 | // TODO: handle imports more properly, grabbing them in-line and nesting them |
| 101 | - $imported_urls = array(); |
|
| 102 | - $imported = 1; |
|
| 103 | - while ($imported > 0) {
|
|
| 104 | - $imported = 0; |
|
| 105 | - // Schema imports |
|
| 106 | - foreach ($this->schemas as $ns => $list) {
|
|
| 107 | - foreach ($list as $xs) {
|
|
| 108 | - $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! |
|
| 109 | - foreach ($xs->imports as $ns2 => $list2) {
|
|
| 110 | - for ($ii = 0; $ii < count($list2); $ii++) {
|
|
| 111 | - if (! $list2[$ii]['loaded']) {
|
|
| 112 | - $this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true; |
|
| 113 | - $url = $list2[$ii]['location']; |
|
| 114 | - if ($url != '') {
|
|
| 115 | - $urlparts = parse_url($url); |
|
| 116 | - if (!isset($urlparts['host'])) {
|
|
| 117 | - $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' .$wsdlparts['port'] : '') . |
|
| 118 | - substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path']; |
|
| 119 | - } |
|
| 120 | - if (! in_array($url, $imported_urls)) {
|
|
| 121 | - $this->parseWSDL($url); |
|
| 122 | - $imported++; |
|
| 123 | - $imported_urls[] = $url; |
|
| 124 | - } |
|
| 125 | - } else {
|
|
| 126 | - $this->debug("Unexpected scenario: empty URL for unloaded import");
|
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - } |
|
| 132 | - } |
|
| 133 | - // WSDL imports |
|
| 134 | - $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! |
|
| 101 | + $imported_urls = array(); |
|
| 102 | + $imported = 1; |
|
| 103 | + while ($imported > 0) {
|
|
| 104 | + $imported = 0; |
|
| 105 | + // Schema imports |
|
| 106 | + foreach ($this->schemas as $ns => $list) {
|
|
| 107 | + foreach ($list as $xs) {
|
|
| 108 | + $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! |
|
| 109 | + foreach ($xs->imports as $ns2 => $list2) {
|
|
| 110 | + for ($ii = 0; $ii < count($list2); $ii++) {
|
|
| 111 | + if (! $list2[$ii]['loaded']) {
|
|
| 112 | + $this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true; |
|
| 113 | + $url = $list2[$ii]['location']; |
|
| 114 | + if ($url != '') {
|
|
| 115 | + $urlparts = parse_url($url); |
|
| 116 | + if (!isset($urlparts['host'])) {
|
|
| 117 | + $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' .$wsdlparts['port'] : '') . |
|
| 118 | + substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path']; |
|
| 119 | + } |
|
| 120 | + if (! in_array($url, $imported_urls)) {
|
|
| 121 | + $this->parseWSDL($url); |
|
| 122 | + $imported++; |
|
| 123 | + $imported_urls[] = $url; |
|
| 124 | + } |
|
| 125 | + } else {
|
|
| 126 | + $this->debug("Unexpected scenario: empty URL for unloaded import");
|
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | + // WSDL imports |
|
| 134 | + $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! |
|
| 135 | 135 | foreach ($this->import as $ns => $list) {
|
| 136 | 136 | for ($ii = 0; $ii < count($list); $ii++) {
|
| 137 | - if (! $list[$ii]['loaded']) {
|
|
| 138 | - $this->import[$ns][$ii]['loaded'] = true; |
|
| 139 | - $url = $list[$ii]['location']; |
|
| 140 | - if ($url != '') {
|
|
| 141 | - $urlparts = parse_url($url); |
|
| 142 | - if (!isset($urlparts['host'])) {
|
|
| 143 | - $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') . |
|
| 144 | - substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path']; |
|
| 145 | - } |
|
| 146 | - if (! in_array($url, $imported_urls)) {
|
|
| 147 | - $this->parseWSDL($url); |
|
| 148 | - $imported++; |
|
| 149 | - $imported_urls[] = $url; |
|
| 150 | - } |
|
| 151 | - } else {
|
|
| 152 | - $this->debug("Unexpected scenario: empty URL for unloaded import");
|
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - } |
|
| 137 | + if (! $list[$ii]['loaded']) {
|
|
| 138 | + $this->import[$ns][$ii]['loaded'] = true; |
|
| 139 | + $url = $list[$ii]['location']; |
|
| 140 | + if ($url != '') {
|
|
| 141 | + $urlparts = parse_url($url); |
|
| 142 | + if (!isset($urlparts['host'])) {
|
|
| 143 | + $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') . |
|
| 144 | + substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path']; |
|
| 145 | + } |
|
| 146 | + if (! in_array($url, $imported_urls)) {
|
|
| 147 | + $this->parseWSDL($url); |
|
| 148 | + $imported++; |
|
| 149 | + $imported_urls[] = $url; |
|
| 150 | + } |
|
| 151 | + } else {
|
|
| 152 | + $this->debug("Unexpected scenario: empty URL for unloaded import");
|
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | 156 | } |
| 157 | - } |
|
| 157 | + } |
|
| 158 | 158 | // add new data to operation data |
| 159 | 159 | foreach($this->bindings as $binding => $bindingData) {
|
| 160 | 160 | if (isset($bindingData['operations']) && is_array($bindingData['operations'])) {
|
| 161 | 161 | foreach($bindingData['operations'] as $operation => $data) {
|
| 162 | 162 | $this->debug('post-parse data gathering for ' . $operation);
|
| 163 | 163 | $this->bindings[$binding]['operations'][$operation]['input'] = |
| 164 | - isset($this->bindings[$binding]['operations'][$operation]['input']) ? |
|
| 165 | - array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) : |
|
| 166 | - $this->portTypes[ $bindingData['portType'] ][$operation]['input']; |
|
| 164 | + isset($this->bindings[$binding]['operations'][$operation]['input']) ? |
|
| 165 | + array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) : |
|
| 166 | + $this->portTypes[ $bindingData['portType'] ][$operation]['input']; |
|
| 167 | 167 | $this->bindings[$binding]['operations'][$operation]['output'] = |
| 168 | - isset($this->bindings[$binding]['operations'][$operation]['output']) ? |
|
| 169 | - array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) : |
|
| 170 | - $this->portTypes[ $bindingData['portType'] ][$operation]['output']; |
|
| 168 | + isset($this->bindings[$binding]['operations'][$operation]['output']) ? |
|
| 169 | + array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) : |
|
| 170 | + $this->portTypes[ $bindingData['portType'] ][$operation]['output']; |
|
| 171 | 171 | if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ])){
|
| 172 | - $this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ]; |
|
| 173 | - } |
|
| 174 | - if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ])){
|
|
| 175 | - $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ]; |
|
| 172 | + $this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ]; |
|
| 173 | + } |
|
| 174 | + if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ])){
|
|
| 175 | + $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ]; |
|
| 176 | 176 | } |
| 177 | 177 | // Set operation style if necessary, but do not override one already provided |
| 178 | - if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['style'])) {
|
|
| 178 | + if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['style'])) {
|
|
| 179 | 179 | $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style']; |
| 180 | 180 | } |
| 181 | 181 | $this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : ''; |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | - } |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | 189 | /** |
| 190 | 190 | * parses the wsdl document |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @access private |
| 194 | 194 | */ |
| 195 | 195 | function parseWSDL($wsdl = '') {
|
| 196 | - $this->debug("parse WSDL at path=$wsdl");
|
|
| 196 | + $this->debug("parse WSDL at path=$wsdl");
|
|
| 197 | 197 | |
| 198 | 198 | if ($wsdl == '') {
|
| 199 | 199 | $this->debug('no wsdl passed to parseWSDL()!!');
|
@@ -206,38 +206,38 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'http' || $wsdl_props['scheme'] == 'https')) {
|
| 208 | 208 | $this->debug('getting WSDL http(s) URL ' . $wsdl);
|
| 209 | - // get wsdl |
|
| 210 | - $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl); |
|
| 211 | - $tr->request_method = 'GET'; |
|
| 212 | - $tr->useSOAPAction = false; |
|
| 213 | - if($this->proxyhost && $this->proxyport){
|
|
| 214 | - $tr->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword); |
|
| 215 | - } |
|
| 216 | - if ($this->authtype != '') {
|
|
| 217 | - $tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest); |
|
| 218 | - } |
|
| 219 | - $tr->setEncoding('gzip, deflate');
|
|
| 220 | - $wsdl_string = $tr->send('', $this->timeout, $this->response_timeout);
|
|
| 221 | - //$this->debug("WSDL request\n" . $tr->outgoing_payload);
|
|
| 222 | - //$this->debug("WSDL response\n" . $tr->incoming_payload);
|
|
| 223 | - $this->appendDebug($tr->getDebug()); |
|
| 224 | - // catch errors |
|
| 225 | - if($err = $tr->getError() ){
|
|
| 226 | - $errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: '.$err; |
|
| 227 | - $this->debug($errstr); |
|
| 228 | - $this->setError($errstr); |
|
| 229 | - unset($tr); |
|
| 230 | - return false; |
|
| 231 | - } |
|
| 232 | - unset($tr); |
|
| 233 | - $this->debug("got WSDL URL");
|
|
| 209 | + // get wsdl |
|
| 210 | + $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl); |
|
| 211 | + $tr->request_method = 'GET'; |
|
| 212 | + $tr->useSOAPAction = false; |
|
| 213 | + if($this->proxyhost && $this->proxyport){
|
|
| 214 | + $tr->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword); |
|
| 215 | + } |
|
| 216 | + if ($this->authtype != '') {
|
|
| 217 | + $tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest); |
|
| 218 | + } |
|
| 219 | + $tr->setEncoding('gzip, deflate');
|
|
| 220 | + $wsdl_string = $tr->send('', $this->timeout, $this->response_timeout);
|
|
| 221 | + //$this->debug("WSDL request\n" . $tr->outgoing_payload);
|
|
| 222 | + //$this->debug("WSDL response\n" . $tr->incoming_payload);
|
|
| 223 | + $this->appendDebug($tr->getDebug()); |
|
| 224 | + // catch errors |
|
| 225 | + if($err = $tr->getError() ){
|
|
| 226 | + $errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: '.$err; |
|
| 227 | + $this->debug($errstr); |
|
| 228 | + $this->setError($errstr); |
|
| 229 | + unset($tr); |
|
| 230 | + return false; |
|
| 231 | + } |
|
| 232 | + unset($tr); |
|
| 233 | + $this->debug("got WSDL URL");
|
|
| 234 | 234 | } else {
|
| 235 | 235 | // $wsdl is not http(s), so treat it as a file URL or plain file path |
| 236 | - if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) {
|
|
| 237 | - $path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path']; |
|
| 238 | - } else {
|
|
| 239 | - $path = $wsdl; |
|
| 240 | - } |
|
| 236 | + if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) {
|
|
| 237 | + $path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path']; |
|
| 238 | + } else {
|
|
| 239 | + $path = $wsdl; |
|
| 240 | + } |
|
| 241 | 241 | $this->debug('getting WSDL file ' . $path);
|
| 242 | 242 | if ($fp = @fopen($path, 'r')) {
|
| 243 | 243 | $wsdl_string = ''; |
@@ -246,8 +246,8 @@ discard block |
||
| 246 | 246 | } |
| 247 | 247 | fclose($fp); |
| 248 | 248 | } else {
|
| 249 | - $errstr = "Bad path to WSDL file $path"; |
|
| 250 | - $this->debug($errstr); |
|
| 249 | + $errstr = "Bad path to WSDL file $path"; |
|
| 250 | + $this->debug($errstr); |
|
| 251 | 251 | $this->setError($errstr); |
| 252 | 252 | return false; |
| 253 | 253 | } |
@@ -268,23 +268,23 @@ discard block |
||
| 268 | 268 | if (!xml_parse($this->parser, $wsdl_string, true)) {
|
| 269 | 269 | // Display an error message. |
| 270 | 270 | $errstr = sprintf( |
| 271 | - 'XML error parsing WSDL from %s on line %d: %s', |
|
| 272 | - $wsdl, |
|
| 271 | + 'XML error parsing WSDL from %s on line %d: %s', |
|
| 272 | + $wsdl, |
|
| 273 | 273 | xml_get_current_line_number($this->parser), |
| 274 | 274 | xml_error_string(xml_get_error_code($this->parser)) |
| 275 | 275 | ); |
| 276 | 276 | $this->debug($errstr); |
| 277 | - $this->debug("XML payload:\n" . $wsdl_string);
|
|
| 277 | + $this->debug("XML payload:\n" . $wsdl_string);
|
|
| 278 | 278 | $this->setError($errstr); |
| 279 | 279 | return false; |
| 280 | 280 | } |
| 281 | - // free the parser |
|
| 281 | + // free the parser |
|
| 282 | 282 | xml_parser_free($this->parser); |
| 283 | 283 | $this->debug('Parsing WSDL done');
|
| 284 | - // catch wsdl parse errors |
|
| 285 | - if($this->getError()){
|
|
| 286 | - return false; |
|
| 287 | - } |
|
| 284 | + // catch wsdl parse errors |
|
| 285 | + if($this->getError()){
|
|
| 286 | + return false; |
|
| 287 | + } |
|
| 288 | 288 | return true; |
| 289 | 289 | } |
| 290 | 290 | |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | $this->appendDebug($this->currentSchema->getDebug()); |
| 304 | 304 | $this->currentSchema->clearDebug(); |
| 305 | 305 | } elseif (preg_match('/schema$/', $name)) {
|
| 306 | - $this->debug('Parsing WSDL schema');
|
|
| 306 | + $this->debug('Parsing WSDL schema');
|
|
| 307 | 307 | // $this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalPart($name).")");
|
| 308 | 308 | $this->status = 'schema'; |
| 309 | 309 | $this->currentSchema = new nusoap_xmlschema('', '', $this->namespaces);
|
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | $this->message[$pos] = array('cdata' => '');
|
| 320 | 320 | // process attributes |
| 321 | 321 | if (count($attrs) > 0) {
|
| 322 | - // register namespace declarations |
|
| 322 | + // register namespace declarations |
|
| 323 | 323 | foreach($attrs as $k => $v) {
|
| 324 | 324 | if (preg_match('/^xmlns/',$k)) {
|
| 325 | 325 | if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
|
@@ -354,417 +354,417 @@ discard block |
||
| 354 | 354 | // get unqualified name |
| 355 | 355 | $name = substr(strstr($name, ':'), 1); |
| 356 | 356 | } |
| 357 | - // process attributes, expanding any prefixes to namespaces |
|
| 357 | + // process attributes, expanding any prefixes to namespaces |
|
| 358 | 358 | // find status, register data |
| 359 | 359 | switch ($this->status) {
|
| 360 | 360 | case 'message': |
| 361 | 361 | if ($name == 'part') {
|
| 362 | - if (isset($attrs['type'])) {
|
|
| 363 | - $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs));
|
|
| 364 | - $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type']; |
|
| 365 | - } |
|
| 366 | - if (isset($attrs['element'])) {
|
|
| 367 | - $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs));
|
|
| 368 | - $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^'; |
|
| 369 | - } |
|
| 370 | - } |
|
| 371 | - break; |
|
| 372 | - case 'portType': |
|
| 373 | - switch ($name) {
|
|
| 374 | - case 'operation': |
|
| 375 | - $this->currentPortOperation = $attrs['name']; |
|
| 376 | - $this->debug("portType $this->currentPortType operation: $this->currentPortOperation");
|
|
| 377 | - if (isset($attrs['parameterOrder'])) {
|
|
| 378 | - $this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder']; |
|
| 379 | - } |
|
| 380 | - break; |
|
| 381 | - case 'documentation': |
|
| 382 | - $this->documentation = true; |
|
| 383 | - break; |
|
| 384 | - // merge input/output data |
|
| 385 | - default: |
|
| 386 | - $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : ''; |
|
| 387 | - $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m; |
|
| 388 | - break; |
|
| 389 | - } |
|
| 390 | - break; |
|
| 391 | - case 'binding': |
|
| 392 | - switch ($name) {
|
|
| 393 | - case 'binding': |
|
| 394 | - // get ns prefix |
|
| 395 | - if (isset($attrs['style'])) {
|
|
| 396 | - $this->bindings[$this->currentBinding]['prefix'] = $prefix; |
|
| 397 | - } |
|
| 398 | - $this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs); |
|
| 399 | - break; |
|
| 400 | - case 'header': |
|
| 401 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs; |
|
| 402 | - break; |
|
| 403 | - case 'operation': |
|
| 404 | - if (isset($attrs['soapAction'])) {
|
|
| 405 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction']; |
|
| 406 | - } |
|
| 407 | - if (isset($attrs['style'])) {
|
|
| 408 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style']; |
|
| 409 | - } |
|
| 410 | - if (isset($attrs['name'])) {
|
|
| 411 | - $this->currentOperation = $attrs['name']; |
|
| 412 | - $this->debug("current binding operation: $this->currentOperation");
|
|
| 413 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name']; |
|
| 414 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding; |
|
| 415 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : ''; |
|
| 416 | - } |
|
| 417 | - break; |
|
| 418 | - case 'input': |
|
| 419 | - $this->opStatus = 'input'; |
|
| 420 | - break; |
|
| 421 | - case 'output': |
|
| 422 | - $this->opStatus = 'output'; |
|
| 423 | - break; |
|
| 424 | - case 'body': |
|
| 425 | - if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) {
|
|
| 426 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs); |
|
| 427 | - } else {
|
|
| 428 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs; |
|
| 429 | - } |
|
| 430 | - break; |
|
| 431 | - } |
|
| 432 | - break; |
|
| 433 | - case 'service': |
|
| 434 | - switch ($name) {
|
|
| 435 | - case 'port': |
|
| 436 | - $this->currentPort = $attrs['name']; |
|
| 437 | - $this->debug('current port: ' . $this->currentPort);
|
|
| 438 | - $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']); |
|
| 362 | + if (isset($attrs['type'])) {
|
|
| 363 | + $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs));
|
|
| 364 | + $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type']; |
|
| 365 | + } |
|
| 366 | + if (isset($attrs['element'])) {
|
|
| 367 | + $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs));
|
|
| 368 | + $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^'; |
|
| 369 | + } |
|
| 370 | + } |
|
| 371 | + break; |
|
| 372 | + case 'portType': |
|
| 373 | + switch ($name) {
|
|
| 374 | + case 'operation': |
|
| 375 | + $this->currentPortOperation = $attrs['name']; |
|
| 376 | + $this->debug("portType $this->currentPortType operation: $this->currentPortOperation");
|
|
| 377 | + if (isset($attrs['parameterOrder'])) {
|
|
| 378 | + $this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder']; |
|
| 379 | + } |
|
| 380 | + break; |
|
| 381 | + case 'documentation': |
|
| 382 | + $this->documentation = true; |
|
| 383 | + break; |
|
| 384 | + // merge input/output data |
|
| 385 | + default: |
|
| 386 | + $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : ''; |
|
| 387 | + $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m; |
|
| 388 | + break; |
|
| 389 | + } |
|
| 390 | + break; |
|
| 391 | + case 'binding': |
|
| 392 | + switch ($name) {
|
|
| 393 | + case 'binding': |
|
| 394 | + // get ns prefix |
|
| 395 | + if (isset($attrs['style'])) {
|
|
| 396 | + $this->bindings[$this->currentBinding]['prefix'] = $prefix; |
|
| 397 | + } |
|
| 398 | + $this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs); |
|
| 399 | + break; |
|
| 400 | + case 'header': |
|
| 401 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs; |
|
| 402 | + break; |
|
| 403 | + case 'operation': |
|
| 404 | + if (isset($attrs['soapAction'])) {
|
|
| 405 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction']; |
|
| 406 | + } |
|
| 407 | + if (isset($attrs['style'])) {
|
|
| 408 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style']; |
|
| 409 | + } |
|
| 410 | + if (isset($attrs['name'])) {
|
|
| 411 | + $this->currentOperation = $attrs['name']; |
|
| 412 | + $this->debug("current binding operation: $this->currentOperation");
|
|
| 413 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name']; |
|
| 414 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding; |
|
| 415 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : ''; |
|
| 416 | + } |
|
| 417 | + break; |
|
| 418 | + case 'input': |
|
| 419 | + $this->opStatus = 'input'; |
|
| 420 | + break; |
|
| 421 | + case 'output': |
|
| 422 | + $this->opStatus = 'output'; |
|
| 423 | + break; |
|
| 424 | + case 'body': |
|
| 425 | + if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) {
|
|
| 426 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs); |
|
| 427 | + } else {
|
|
| 428 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs; |
|
| 429 | + } |
|
| 430 | + break; |
|
| 431 | + } |
|
| 432 | + break; |
|
| 433 | + case 'service': |
|
| 434 | + switch ($name) {
|
|
| 435 | + case 'port': |
|
| 436 | + $this->currentPort = $attrs['name']; |
|
| 437 | + $this->debug('current port: ' . $this->currentPort);
|
|
| 438 | + $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']); |
|
| 439 | 439 | |
| 440 | - break; |
|
| 441 | - case 'address': |
|
| 442 | - $this->ports[$this->currentPort]['location'] = $attrs['location']; |
|
| 443 | - $this->ports[$this->currentPort]['bindingType'] = $namespace; |
|
| 444 | - $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace; |
|
| 445 | - $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location']; |
|
| 446 | - break; |
|
| 447 | - } |
|
| 448 | - break; |
|
| 449 | - } |
|
| 450 | - // set status |
|
| 451 | - switch ($name) {
|
|
| 452 | - case 'import': |
|
| 453 | - if (isset($attrs['location'])) {
|
|
| 440 | + break; |
|
| 441 | + case 'address': |
|
| 442 | + $this->ports[$this->currentPort]['location'] = $attrs['location']; |
|
| 443 | + $this->ports[$this->currentPort]['bindingType'] = $namespace; |
|
| 444 | + $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace; |
|
| 445 | + $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location']; |
|
| 446 | + break; |
|
| 447 | + } |
|
| 448 | + break; |
|
| 449 | + } |
|
| 450 | + // set status |
|
| 451 | + switch ($name) {
|
|
| 452 | + case 'import': |
|
| 453 | + if (isset($attrs['location'])) {
|
|
| 454 | 454 | $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false);
|
| 455 | 455 | $this->debug('parsing import ' . $attrs['namespace']. ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]).')');
|
| 456 | - } else {
|
|
| 456 | + } else {
|
|
| 457 | 457 | $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
|
| 458 | - if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
|
|
| 459 | - $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace']; |
|
| 460 | - } |
|
| 458 | + if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
|
|
| 459 | + $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace']; |
|
| 460 | + } |
|
| 461 | 461 | $this->debug('parsing import ' . $attrs['namespace']. ' - [no location] (' . count($this->import[$attrs['namespace']]).')');
|
| 462 | - } |
|
| 463 | - break; |
|
| 464 | - //wait for schema |
|
| 465 | - //case 'types': |
|
| 466 | - // $this->status = 'schema'; |
|
| 467 | - // break; |
|
| 468 | - case 'message': |
|
| 469 | - $this->status = 'message'; |
|
| 470 | - $this->messages[$attrs['name']] = array(); |
|
| 471 | - $this->currentMessage = $attrs['name']; |
|
| 472 | - break; |
|
| 473 | - case 'portType': |
|
| 474 | - $this->status = 'portType'; |
|
| 475 | - $this->portTypes[$attrs['name']] = array(); |
|
| 476 | - $this->currentPortType = $attrs['name']; |
|
| 477 | - break; |
|
| 478 | - case "binding": |
|
| 479 | - if (isset($attrs['name'])) {
|
|
| 480 | - // get binding name |
|
| 481 | - if (strpos($attrs['name'], ':')) {
|
|
| 482 | - $this->currentBinding = $this->getLocalPart($attrs['name']); |
|
| 483 | - } else {
|
|
| 484 | - $this->currentBinding = $attrs['name']; |
|
| 485 | - } |
|
| 486 | - $this->status = 'binding'; |
|
| 487 | - $this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']); |
|
| 488 | - $this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
|
|
| 489 | - } |
|
| 490 | - break; |
|
| 491 | - case 'service': |
|
| 492 | - $this->serviceName = $attrs['name']; |
|
| 493 | - $this->status = 'service'; |
|
| 494 | - $this->debug('current service: ' . $this->serviceName);
|
|
| 495 | - break; |
|
| 496 | - case 'definitions': |
|
| 497 | - foreach ($attrs as $name => $value) {
|
|
| 498 | - $this->wsdl_info[$name] = $value; |
|
| 499 | - } |
|
| 500 | - break; |
|
| 501 | - } |
|
| 502 | - } |
|
| 503 | - } |
|
| 462 | + } |
|
| 463 | + break; |
|
| 464 | + //wait for schema |
|
| 465 | + //case 'types': |
|
| 466 | + // $this->status = 'schema'; |
|
| 467 | + // break; |
|
| 468 | + case 'message': |
|
| 469 | + $this->status = 'message'; |
|
| 470 | + $this->messages[$attrs['name']] = array(); |
|
| 471 | + $this->currentMessage = $attrs['name']; |
|
| 472 | + break; |
|
| 473 | + case 'portType': |
|
| 474 | + $this->status = 'portType'; |
|
| 475 | + $this->portTypes[$attrs['name']] = array(); |
|
| 476 | + $this->currentPortType = $attrs['name']; |
|
| 477 | + break; |
|
| 478 | + case "binding": |
|
| 479 | + if (isset($attrs['name'])) {
|
|
| 480 | + // get binding name |
|
| 481 | + if (strpos($attrs['name'], ':')) {
|
|
| 482 | + $this->currentBinding = $this->getLocalPart($attrs['name']); |
|
| 483 | + } else {
|
|
| 484 | + $this->currentBinding = $attrs['name']; |
|
| 485 | + } |
|
| 486 | + $this->status = 'binding'; |
|
| 487 | + $this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']); |
|
| 488 | + $this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
|
|
| 489 | + } |
|
| 490 | + break; |
|
| 491 | + case 'service': |
|
| 492 | + $this->serviceName = $attrs['name']; |
|
| 493 | + $this->status = 'service'; |
|
| 494 | + $this->debug('current service: ' . $this->serviceName);
|
|
| 495 | + break; |
|
| 496 | + case 'definitions': |
|
| 497 | + foreach ($attrs as $name => $value) {
|
|
| 498 | + $this->wsdl_info[$name] = $value; |
|
| 499 | + } |
|
| 500 | + break; |
|
| 501 | + } |
|
| 502 | + } |
|
| 503 | + } |
|
| 504 | 504 | |
| 505 | - /** |
|
| 506 | - * end-element handler |
|
| 507 | - * |
|
| 508 | - * @param string $parser XML parser object |
|
| 509 | - * @param string $name element name |
|
| 510 | - * @access private |
|
| 511 | - */ |
|
| 512 | - function end_element($parser, $name){
|
|
| 513 | - // unset schema status |
|
| 514 | - if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) {
|
|
| 515 | - $this->status = ""; |
|
| 505 | + /** |
|
| 506 | + * end-element handler |
|
| 507 | + * |
|
| 508 | + * @param string $parser XML parser object |
|
| 509 | + * @param string $name element name |
|
| 510 | + * @access private |
|
| 511 | + */ |
|
| 512 | + function end_element($parser, $name){
|
|
| 513 | + // unset schema status |
|
| 514 | + if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) {
|
|
| 515 | + $this->status = ""; |
|
| 516 | 516 | $this->appendDebug($this->currentSchema->getDebug()); |
| 517 | 517 | $this->currentSchema->clearDebug(); |
| 518 | - $this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema; |
|
| 519 | - $this->debug('Parsing WSDL schema done');
|
|
| 520 | - } |
|
| 521 | - if ($this->status == 'schema') {
|
|
| 522 | - $this->currentSchema->schemaEndElement($parser, $name); |
|
| 523 | - } else {
|
|
| 524 | - // bring depth down a notch |
|
| 525 | - $this->depth--; |
|
| 526 | - } |
|
| 527 | - // end documentation |
|
| 528 | - if ($this->documentation) {
|
|
| 529 | - //TODO: track the node to which documentation should be assigned; it can be a part, message, etc. |
|
| 530 | - //$this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation; |
|
| 531 | - $this->documentation = false; |
|
| 532 | - } |
|
| 533 | - } |
|
| 518 | + $this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema; |
|
| 519 | + $this->debug('Parsing WSDL schema done');
|
|
| 520 | + } |
|
| 521 | + if ($this->status == 'schema') {
|
|
| 522 | + $this->currentSchema->schemaEndElement($parser, $name); |
|
| 523 | + } else {
|
|
| 524 | + // bring depth down a notch |
|
| 525 | + $this->depth--; |
|
| 526 | + } |
|
| 527 | + // end documentation |
|
| 528 | + if ($this->documentation) {
|
|
| 529 | + //TODO: track the node to which documentation should be assigned; it can be a part, message, etc. |
|
| 530 | + //$this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation; |
|
| 531 | + $this->documentation = false; |
|
| 532 | + } |
|
| 533 | + } |
|
| 534 | 534 | |
| 535 | - /** |
|
| 536 | - * element content handler |
|
| 537 | - * |
|
| 538 | - * @param string $parser XML parser object |
|
| 539 | - * @param string $data element content |
|
| 540 | - * @access private |
|
| 541 | - */ |
|
| 542 | - function character_data($parser, $data) |
|
| 543 | - {
|
|
| 544 | - $pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0; |
|
| 545 | - if (isset($this->message[$pos]['cdata'])) {
|
|
| 546 | - $this->message[$pos]['cdata'] .= $data; |
|
| 547 | - } |
|
| 548 | - if ($this->documentation) {
|
|
| 549 | - $this->documentation .= $data; |
|
| 550 | - } |
|
| 551 | - } |
|
| 535 | + /** |
|
| 536 | + * element content handler |
|
| 537 | + * |
|
| 538 | + * @param string $parser XML parser object |
|
| 539 | + * @param string $data element content |
|
| 540 | + * @access private |
|
| 541 | + */ |
|
| 542 | + function character_data($parser, $data) |
|
| 543 | + {
|
|
| 544 | + $pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0; |
|
| 545 | + if (isset($this->message[$pos]['cdata'])) {
|
|
| 546 | + $this->message[$pos]['cdata'] .= $data; |
|
| 547 | + } |
|
| 548 | + if ($this->documentation) {
|
|
| 549 | + $this->documentation .= $data; |
|
| 550 | + } |
|
| 551 | + } |
|
| 552 | 552 | |
| 553 | - /** |
|
| 554 | - * if authenticating, set user credentials here |
|
| 555 | - * |
|
| 556 | - * @param string $username |
|
| 557 | - * @param string $password |
|
| 558 | - * @param string $authtype (basic|digest|certificate|ntlm) |
|
| 559 | - * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) |
|
| 560 | - * @access public |
|
| 561 | - */ |
|
| 562 | - function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) {
|
|
| 563 | - $this->debug("setCredentials username=$username authtype=$authtype certRequest=");
|
|
| 564 | - $this->appendDebug($this->varDump($certRequest)); |
|
| 565 | - $this->username = $username; |
|
| 566 | - $this->password = $password; |
|
| 567 | - $this->authtype = $authtype; |
|
| 568 | - $this->certRequest = $certRequest; |
|
| 569 | - } |
|
| 553 | + /** |
|
| 554 | + * if authenticating, set user credentials here |
|
| 555 | + * |
|
| 556 | + * @param string $username |
|
| 557 | + * @param string $password |
|
| 558 | + * @param string $authtype (basic|digest|certificate|ntlm) |
|
| 559 | + * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) |
|
| 560 | + * @access public |
|
| 561 | + */ |
|
| 562 | + function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) {
|
|
| 563 | + $this->debug("setCredentials username=$username authtype=$authtype certRequest=");
|
|
| 564 | + $this->appendDebug($this->varDump($certRequest)); |
|
| 565 | + $this->username = $username; |
|
| 566 | + $this->password = $password; |
|
| 567 | + $this->authtype = $authtype; |
|
| 568 | + $this->certRequest = $certRequest; |
|
| 569 | + } |
|
| 570 | 570 | |
| 571 | - function getBindingData($binding) |
|
| 572 | - {
|
|
| 573 | - if (is_array($this->bindings[$binding])) {
|
|
| 574 | - return $this->bindings[$binding]; |
|
| 575 | - } |
|
| 576 | - } |
|
| 571 | + function getBindingData($binding) |
|
| 572 | + {
|
|
| 573 | + if (is_array($this->bindings[$binding])) {
|
|
| 574 | + return $this->bindings[$binding]; |
|
| 575 | + } |
|
| 576 | + } |
|
| 577 | 577 | |
| 578 | - /** |
|
| 579 | - * returns an assoc array of operation names => operation data |
|
| 580 | - * |
|
| 581 | - * @param string $portName WSDL port name |
|
| 582 | - * @param string $bindingType eg: soap, smtp, dime (only soap and soap12 are currently supported) |
|
| 583 | - * @return array |
|
| 584 | - * @access public |
|
| 585 | - */ |
|
| 586 | - function getOperations($portName = '', $bindingType = 'soap') {
|
|
| 587 | - $ops = array(); |
|
| 588 | - if ($bindingType == 'soap') {
|
|
| 589 | - $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; |
|
| 590 | - } elseif ($bindingType == 'soap12') {
|
|
| 591 | - $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; |
|
| 592 | - } else {
|
|
| 593 | - $this->debug("getOperations bindingType $bindingType may not be supported");
|
|
| 594 | - } |
|
| 595 | - $this->debug("getOperations for port '$portName' bindingType $bindingType");
|
|
| 596 | - // loop thru ports |
|
| 597 | - foreach($this->ports as $port => $portData) {
|
|
| 598 | - $this->debug("getOperations checking port $port bindingType " . $portData['bindingType']);
|
|
| 599 | - if ($portName == '' || $port == $portName) {
|
|
| 600 | - // binding type of port matches parameter |
|
| 601 | - if ($portData['bindingType'] == $bindingType) {
|
|
| 602 | - $this->debug("getOperations found port $port bindingType $bindingType");
|
|
| 603 | - //$this->debug("port data: " . $this->varDump($portData));
|
|
| 604 | - //$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ]));
|
|
| 605 | - // merge bindings |
|
| 606 | - if (isset($this->bindings[ $portData['binding'] ]['operations'])) {
|
|
| 607 | - $ops = array_merge ($ops, $this->bindings[ $portData['binding'] ]['operations']); |
|
| 608 | - } |
|
| 609 | - } |
|
| 610 | - } |
|
| 611 | - } |
|
| 612 | - if (count($ops) == 0) {
|
|
| 613 | - $this->debug("getOperations found no operations for port '$portName' bindingType $bindingType");
|
|
| 614 | - } |
|
| 615 | - return $ops; |
|
| 616 | - } |
|
| 578 | + /** |
|
| 579 | + * returns an assoc array of operation names => operation data |
|
| 580 | + * |
|
| 581 | + * @param string $portName WSDL port name |
|
| 582 | + * @param string $bindingType eg: soap, smtp, dime (only soap and soap12 are currently supported) |
|
| 583 | + * @return array |
|
| 584 | + * @access public |
|
| 585 | + */ |
|
| 586 | + function getOperations($portName = '', $bindingType = 'soap') {
|
|
| 587 | + $ops = array(); |
|
| 588 | + if ($bindingType == 'soap') {
|
|
| 589 | + $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; |
|
| 590 | + } elseif ($bindingType == 'soap12') {
|
|
| 591 | + $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; |
|
| 592 | + } else {
|
|
| 593 | + $this->debug("getOperations bindingType $bindingType may not be supported");
|
|
| 594 | + } |
|
| 595 | + $this->debug("getOperations for port '$portName' bindingType $bindingType");
|
|
| 596 | + // loop thru ports |
|
| 597 | + foreach($this->ports as $port => $portData) {
|
|
| 598 | + $this->debug("getOperations checking port $port bindingType " . $portData['bindingType']);
|
|
| 599 | + if ($portName == '' || $port == $portName) {
|
|
| 600 | + // binding type of port matches parameter |
|
| 601 | + if ($portData['bindingType'] == $bindingType) {
|
|
| 602 | + $this->debug("getOperations found port $port bindingType $bindingType");
|
|
| 603 | + //$this->debug("port data: " . $this->varDump($portData));
|
|
| 604 | + //$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ]));
|
|
| 605 | + // merge bindings |
|
| 606 | + if (isset($this->bindings[ $portData['binding'] ]['operations'])) {
|
|
| 607 | + $ops = array_merge ($ops, $this->bindings[ $portData['binding'] ]['operations']); |
|
| 608 | + } |
|
| 609 | + } |
|
| 610 | + } |
|
| 611 | + } |
|
| 612 | + if (count($ops) == 0) {
|
|
| 613 | + $this->debug("getOperations found no operations for port '$portName' bindingType $bindingType");
|
|
| 614 | + } |
|
| 615 | + return $ops; |
|
| 616 | + } |
|
| 617 | 617 | |
| 618 | - /** |
|
| 619 | - * returns an associative array of data necessary for calling an operation |
|
| 620 | - * |
|
| 621 | - * @param string $operation name of operation |
|
| 622 | - * @param string $bindingType type of binding eg: soap, soap12 |
|
| 623 | - * @return array |
|
| 624 | - * @access public |
|
| 625 | - */ |
|
| 626 | - function getOperationData($operation, $bindingType = 'soap') |
|
| 627 | - {
|
|
| 628 | - if ($bindingType == 'soap') {
|
|
| 629 | - $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; |
|
| 630 | - } elseif ($bindingType == 'soap12') {
|
|
| 631 | - $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; |
|
| 632 | - } |
|
| 633 | - // loop thru ports |
|
| 634 | - foreach($this->ports as $port => $portData) {
|
|
| 635 | - // binding type of port matches parameter |
|
| 636 | - if ($portData['bindingType'] == $bindingType) {
|
|
| 637 | - // get binding |
|
| 638 | - //foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
|
|
| 639 | - foreach(array_keys($this->bindings[ $portData['binding'] ]['operations']) as $bOperation) {
|
|
| 640 | - // note that we could/should also check the namespace here |
|
| 641 | - if ($operation == $bOperation) {
|
|
| 642 | - $opData = $this->bindings[ $portData['binding'] ]['operations'][$operation]; |
|
| 643 | - return $opData; |
|
| 644 | - } |
|
| 645 | - } |
|
| 646 | - } |
|
| 647 | - } |
|
| 648 | - } |
|
| 618 | + /** |
|
| 619 | + * returns an associative array of data necessary for calling an operation |
|
| 620 | + * |
|
| 621 | + * @param string $operation name of operation |
|
| 622 | + * @param string $bindingType type of binding eg: soap, soap12 |
|
| 623 | + * @return array |
|
| 624 | + * @access public |
|
| 625 | + */ |
|
| 626 | + function getOperationData($operation, $bindingType = 'soap') |
|
| 627 | + {
|
|
| 628 | + if ($bindingType == 'soap') {
|
|
| 629 | + $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; |
|
| 630 | + } elseif ($bindingType == 'soap12') {
|
|
| 631 | + $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; |
|
| 632 | + } |
|
| 633 | + // loop thru ports |
|
| 634 | + foreach($this->ports as $port => $portData) {
|
|
| 635 | + // binding type of port matches parameter |
|
| 636 | + if ($portData['bindingType'] == $bindingType) {
|
|
| 637 | + // get binding |
|
| 638 | + //foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
|
|
| 639 | + foreach(array_keys($this->bindings[ $portData['binding'] ]['operations']) as $bOperation) {
|
|
| 640 | + // note that we could/should also check the namespace here |
|
| 641 | + if ($operation == $bOperation) {
|
|
| 642 | + $opData = $this->bindings[ $portData['binding'] ]['operations'][$operation]; |
|
| 643 | + return $opData; |
|
| 644 | + } |
|
| 645 | + } |
|
| 646 | + } |
|
| 647 | + } |
|
| 648 | + } |
|
| 649 | 649 | |
| 650 | - /** |
|
| 651 | - * returns an associative array of data necessary for calling an operation |
|
| 652 | - * |
|
| 653 | - * @param string $soapAction soapAction for operation |
|
| 654 | - * @param string $bindingType type of binding eg: soap, soap12 |
|
| 655 | - * @return array |
|
| 656 | - * @access public |
|
| 657 | - */ |
|
| 658 | - function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') {
|
|
| 659 | - if ($bindingType == 'soap') {
|
|
| 660 | - $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; |
|
| 661 | - } elseif ($bindingType == 'soap12') {
|
|
| 662 | - $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; |
|
| 663 | - } |
|
| 664 | - // loop thru ports |
|
| 665 | - foreach($this->ports as $port => $portData) {
|
|
| 666 | - // binding type of port matches parameter |
|
| 667 | - if ($portData['bindingType'] == $bindingType) {
|
|
| 668 | - // loop through operations for the binding |
|
| 669 | - foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
|
|
| 670 | - if ($opData['soapAction'] == $soapAction) {
|
|
| 671 | - return $opData; |
|
| 672 | - } |
|
| 673 | - } |
|
| 674 | - } |
|
| 675 | - } |
|
| 676 | - } |
|
| 650 | + /** |
|
| 651 | + * returns an associative array of data necessary for calling an operation |
|
| 652 | + * |
|
| 653 | + * @param string $soapAction soapAction for operation |
|
| 654 | + * @param string $bindingType type of binding eg: soap, soap12 |
|
| 655 | + * @return array |
|
| 656 | + * @access public |
|
| 657 | + */ |
|
| 658 | + function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') {
|
|
| 659 | + if ($bindingType == 'soap') {
|
|
| 660 | + $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/'; |
|
| 661 | + } elseif ($bindingType == 'soap12') {
|
|
| 662 | + $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; |
|
| 663 | + } |
|
| 664 | + // loop thru ports |
|
| 665 | + foreach($this->ports as $port => $portData) {
|
|
| 666 | + // binding type of port matches parameter |
|
| 667 | + if ($portData['bindingType'] == $bindingType) {
|
|
| 668 | + // loop through operations for the binding |
|
| 669 | + foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
|
|
| 670 | + if ($opData['soapAction'] == $soapAction) {
|
|
| 671 | + return $opData; |
|
| 672 | + } |
|
| 673 | + } |
|
| 674 | + } |
|
| 675 | + } |
|
| 676 | + } |
|
| 677 | 677 | |
| 678 | - /** |
|
| 679 | - * returns an array of information about a given type |
|
| 680 | - * returns false if no type exists by the given name |
|
| 681 | - * |
|
| 682 | - * typeDef = array( |
|
| 683 | - * 'elements' => array(), // refs to elements array |
|
| 684 | - * 'restrictionBase' => '', |
|
| 685 | - * 'phpType' => '', |
|
| 686 | - * 'order' => '(sequence|all)', |
|
| 687 | - * 'attrs' => array() // refs to attributes array |
|
| 688 | - * ) |
|
| 689 | - * |
|
| 690 | - * @param string $type the type |
|
| 691 | - * @param string $ns namespace (not prefix) of the type |
|
| 692 | - * @return mixed |
|
| 693 | - * @access public |
|
| 694 | - * @see nusoap_xmlschema |
|
| 695 | - */ |
|
| 696 | - function getTypeDef($type, $ns) {
|
|
| 697 | - $this->debug("in getTypeDef: type=$type, ns=$ns");
|
|
| 698 | - if ((! $ns) && isset($this->namespaces['tns'])) {
|
|
| 699 | - $ns = $this->namespaces['tns']; |
|
| 700 | - $this->debug("in getTypeDef: type namespace forced to $ns");
|
|
| 701 | - } |
|
| 702 | - if (!isset($this->schemas[$ns])) {
|
|
| 703 | - foreach ($this->schemas as $ns0 => $schema0) {
|
|
| 704 | - if (strcasecmp($ns, $ns0) == 0) {
|
|
| 705 | - $this->debug("in getTypeDef: replacing schema namespace $ns with $ns0");
|
|
| 706 | - $ns = $ns0; |
|
| 707 | - break; |
|
| 708 | - } |
|
| 709 | - } |
|
| 710 | - } |
|
| 711 | - if (isset($this->schemas[$ns])) {
|
|
| 712 | - $this->debug("in getTypeDef: have schema for namespace $ns");
|
|
| 713 | - for ($i = 0; $i < count($this->schemas[$ns]); $i++) {
|
|
| 714 | - $xs = &$this->schemas[$ns][$i]; |
|
| 715 | - $t = $xs->getTypeDef($type); |
|
| 716 | - $this->appendDebug($xs->getDebug()); |
|
| 717 | - $xs->clearDebug(); |
|
| 718 | - if ($t) {
|
|
| 719 | - $this->debug("in getTypeDef: found type $type");
|
|
| 720 | - if (!isset($t['phpType'])) {
|
|
| 721 | - // get info for type to tack onto the element |
|
| 722 | - $uqType = substr($t['type'], strrpos($t['type'], ':') + 1); |
|
| 723 | - $ns = substr($t['type'], 0, strrpos($t['type'], ':')); |
|
| 724 | - $etype = $this->getTypeDef($uqType, $ns); |
|
| 725 | - if ($etype) {
|
|
| 726 | - $this->debug("found type for [element] $type:");
|
|
| 727 | - $this->debug($this->varDump($etype)); |
|
| 728 | - if (isset($etype['phpType'])) {
|
|
| 729 | - $t['phpType'] = $etype['phpType']; |
|
| 730 | - } |
|
| 731 | - if (isset($etype['elements'])) {
|
|
| 732 | - $t['elements'] = $etype['elements']; |
|
| 733 | - } |
|
| 734 | - if (isset($etype['attrs'])) {
|
|
| 735 | - $t['attrs'] = $etype['attrs']; |
|
| 736 | - } |
|
| 737 | - } else {
|
|
| 738 | - $this->debug("did not find type for [element] $type");
|
|
| 739 | - } |
|
| 740 | - } |
|
| 741 | - return $t; |
|
| 742 | - } |
|
| 743 | - } |
|
| 744 | - $this->debug("in getTypeDef: did not find type $type");
|
|
| 745 | - } else {
|
|
| 746 | - $this->debug("in getTypeDef: do not have schema for namespace $ns");
|
|
| 747 | - } |
|
| 748 | - return false; |
|
| 749 | - } |
|
| 678 | + /** |
|
| 679 | + * returns an array of information about a given type |
|
| 680 | + * returns false if no type exists by the given name |
|
| 681 | + * |
|
| 682 | + * typeDef = array( |
|
| 683 | + * 'elements' => array(), // refs to elements array |
|
| 684 | + * 'restrictionBase' => '', |
|
| 685 | + * 'phpType' => '', |
|
| 686 | + * 'order' => '(sequence|all)', |
|
| 687 | + * 'attrs' => array() // refs to attributes array |
|
| 688 | + * ) |
|
| 689 | + * |
|
| 690 | + * @param string $type the type |
|
| 691 | + * @param string $ns namespace (not prefix) of the type |
|
| 692 | + * @return mixed |
|
| 693 | + * @access public |
|
| 694 | + * @see nusoap_xmlschema |
|
| 695 | + */ |
|
| 696 | + function getTypeDef($type, $ns) {
|
|
| 697 | + $this->debug("in getTypeDef: type=$type, ns=$ns");
|
|
| 698 | + if ((! $ns) && isset($this->namespaces['tns'])) {
|
|
| 699 | + $ns = $this->namespaces['tns']; |
|
| 700 | + $this->debug("in getTypeDef: type namespace forced to $ns");
|
|
| 701 | + } |
|
| 702 | + if (!isset($this->schemas[$ns])) {
|
|
| 703 | + foreach ($this->schemas as $ns0 => $schema0) {
|
|
| 704 | + if (strcasecmp($ns, $ns0) == 0) {
|
|
| 705 | + $this->debug("in getTypeDef: replacing schema namespace $ns with $ns0");
|
|
| 706 | + $ns = $ns0; |
|
| 707 | + break; |
|
| 708 | + } |
|
| 709 | + } |
|
| 710 | + } |
|
| 711 | + if (isset($this->schemas[$ns])) {
|
|
| 712 | + $this->debug("in getTypeDef: have schema for namespace $ns");
|
|
| 713 | + for ($i = 0; $i < count($this->schemas[$ns]); $i++) {
|
|
| 714 | + $xs = &$this->schemas[$ns][$i]; |
|
| 715 | + $t = $xs->getTypeDef($type); |
|
| 716 | + $this->appendDebug($xs->getDebug()); |
|
| 717 | + $xs->clearDebug(); |
|
| 718 | + if ($t) {
|
|
| 719 | + $this->debug("in getTypeDef: found type $type");
|
|
| 720 | + if (!isset($t['phpType'])) {
|
|
| 721 | + // get info for type to tack onto the element |
|
| 722 | + $uqType = substr($t['type'], strrpos($t['type'], ':') + 1); |
|
| 723 | + $ns = substr($t['type'], 0, strrpos($t['type'], ':')); |
|
| 724 | + $etype = $this->getTypeDef($uqType, $ns); |
|
| 725 | + if ($etype) {
|
|
| 726 | + $this->debug("found type for [element] $type:");
|
|
| 727 | + $this->debug($this->varDump($etype)); |
|
| 728 | + if (isset($etype['phpType'])) {
|
|
| 729 | + $t['phpType'] = $etype['phpType']; |
|
| 730 | + } |
|
| 731 | + if (isset($etype['elements'])) {
|
|
| 732 | + $t['elements'] = $etype['elements']; |
|
| 733 | + } |
|
| 734 | + if (isset($etype['attrs'])) {
|
|
| 735 | + $t['attrs'] = $etype['attrs']; |
|
| 736 | + } |
|
| 737 | + } else {
|
|
| 738 | + $this->debug("did not find type for [element] $type");
|
|
| 739 | + } |
|
| 740 | + } |
|
| 741 | + return $t; |
|
| 742 | + } |
|
| 743 | + } |
|
| 744 | + $this->debug("in getTypeDef: did not find type $type");
|
|
| 745 | + } else {
|
|
| 746 | + $this->debug("in getTypeDef: do not have schema for namespace $ns");
|
|
| 747 | + } |
|
| 748 | + return false; |
|
| 749 | + } |
|
| 750 | 750 | |
| 751 | 751 | /** |
| 752 | - * prints html description of services |
|
| 753 | - * |
|
| 754 | - * @access private |
|
| 755 | - */ |
|
| 752 | + * prints html description of services |
|
| 753 | + * |
|
| 754 | + * @access private |
|
| 755 | + */ |
|
| 756 | 756 | function webDescription(){
|
| 757 | - global $HTTP_SERVER_VARS; |
|
| 757 | + global $HTTP_SERVER_VARS; |
|
| 758 | 758 | |
| 759 | - if (isset($_SERVER)) {
|
|
| 760 | - $PHP_SELF = $_SERVER['PHP_SELF']; |
|
| 761 | - } elseif (isset($HTTP_SERVER_VARS)) {
|
|
| 762 | - $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF']; |
|
| 763 | - } else {
|
|
| 764 | - $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
|
|
| 765 | - } |
|
| 759 | + if (isset($_SERVER)) {
|
|
| 760 | + $PHP_SELF = $_SERVER['PHP_SELF']; |
|
| 761 | + } elseif (isset($HTTP_SERVER_VARS)) {
|
|
| 762 | + $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF']; |
|
| 763 | + } else {
|
|
| 764 | + $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
|
|
| 765 | + } |
|
| 766 | 766 | |
| 767 | - $b = ' |
|
| 767 | + $b = ' |
|
| 768 | 768 | <html><head><title>NuSOAP: '.$this->serviceName.'</title> |
| 769 | 769 | <style type="text/css"> |
| 770 | 770 | body { font-family: arial; color: #000000; background-color: #ffffff; margin: 0px 0px 0px 0px; }
|
@@ -847,1092 +847,1092 @@ discard block |
||
| 847 | 847 | <p>View the <a href="'.$PHP_SELF.'?wsdl">WSDL</a> for the service. |
| 848 | 848 | Click on an operation name to view it's details.</p> |
| 849 | 849 | <ul>'; |
| 850 | - foreach($this->getOperations() as $op => $data){
|
|
| 851 | - $b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>";
|
|
| 852 | - // create hidden div |
|
| 853 | - $b .= "<div id='$op' class='hidden'> |
|
| 850 | + foreach($this->getOperations() as $op => $data){
|
|
| 851 | + $b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>";
|
|
| 852 | + // create hidden div |
|
| 853 | + $b .= "<div id='$op' class='hidden'> |
|
| 854 | 854 | <a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>"; |
| 855 | - foreach($data as $donnie => $marie){ // loop through opdata
|
|
| 856 | - if($donnie == 'input' || $donnie == 'output'){ // show input/output data
|
|
| 857 | - $b .= "<font color='white'>".ucfirst($donnie).':</font><br>'; |
|
| 858 | - foreach($marie as $captain => $tenille){ // loop through data
|
|
| 859 | - if($captain == 'parts'){ // loop thru parts
|
|
| 860 | - $b .= " $captain:<br>"; |
|
| 861 | - //if(is_array($tenille)){
|
|
| 862 | - foreach($tenille as $joanie => $chachi){
|
|
| 863 | - $b .= " $joanie: $chachi<br>"; |
|
| 864 | - } |
|
| 865 | - //} |
|
| 866 | - } else {
|
|
| 867 | - $b .= " $captain: $tenille<br>"; |
|
| 868 | - } |
|
| 869 | - } |
|
| 870 | - } else {
|
|
| 871 | - $b .= "<font color='white'>".ucfirst($donnie).":</font> $marie<br>"; |
|
| 872 | - } |
|
| 873 | - } |
|
| 874 | - $b .= '</div>'; |
|
| 875 | - } |
|
| 876 | - $b .= ' |
|
| 855 | + foreach($data as $donnie => $marie){ // loop through opdata
|
|
| 856 | + if($donnie == 'input' || $donnie == 'output'){ // show input/output data
|
|
| 857 | + $b .= "<font color='white'>".ucfirst($donnie).':</font><br>'; |
|
| 858 | + foreach($marie as $captain => $tenille){ // loop through data
|
|
| 859 | + if($captain == 'parts'){ // loop thru parts
|
|
| 860 | + $b .= " $captain:<br>"; |
|
| 861 | + //if(is_array($tenille)){
|
|
| 862 | + foreach($tenille as $joanie => $chachi){
|
|
| 863 | + $b .= " $joanie: $chachi<br>"; |
|
| 864 | + } |
|
| 865 | + //} |
|
| 866 | + } else {
|
|
| 867 | + $b .= " $captain: $tenille<br>"; |
|
| 868 | + } |
|
| 869 | + } |
|
| 870 | + } else {
|
|
| 871 | + $b .= "<font color='white'>".ucfirst($donnie).":</font> $marie<br>"; |
|
| 872 | + } |
|
| 873 | + } |
|
| 874 | + $b .= '</div>'; |
|
| 875 | + } |
|
| 876 | + $b .= ' |
|
| 877 | 877 | <ul> |
| 878 | 878 | </div> |
| 879 | 879 | </div></body></html>'; |
| 880 | - return $b; |
|
| 880 | + return $b; |
|
| 881 | 881 | } |
| 882 | 882 | |
| 883 | - /** |
|
| 884 | - * serialize the parsed wsdl |
|
| 885 | - * |
|
| 886 | - * @param mixed $debug whether to put debug=1 in endpoint URL |
|
| 887 | - * @return string serialization of WSDL |
|
| 888 | - * @access public |
|
| 889 | - */ |
|
| 890 | - function serialize($debug = 0) |
|
| 891 | - {
|
|
| 892 | - $xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'; |
|
| 893 | - $xml .= "\n<definitions"; |
|
| 894 | - foreach($this->namespaces as $k => $v) {
|
|
| 895 | - $xml .= " xmlns:$k=\"$v\""; |
|
| 896 | - } |
|
| 897 | - // 10.9.02 - add poulter fix for wsdl and tns declarations |
|
| 898 | - if (isset($this->namespaces['wsdl'])) {
|
|
| 899 | - $xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\""; |
|
| 900 | - } |
|
| 901 | - if (isset($this->namespaces['tns'])) {
|
|
| 902 | - $xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\""; |
|
| 903 | - } |
|
| 904 | - $xml .= '>'; |
|
| 905 | - // imports |
|
| 906 | - if (sizeof($this->import) > 0) {
|
|
| 907 | - foreach($this->import as $ns => $list) {
|
|
| 908 | - foreach ($list as $ii) {
|
|
| 909 | - if ($ii['location'] != '') {
|
|
| 910 | - $xml .= '<import location="' . $ii['location'] . '" namespace="' . $ns . '" />'; |
|
| 911 | - } else {
|
|
| 912 | - $xml .= '<import namespace="' . $ns . '" />'; |
|
| 913 | - } |
|
| 914 | - } |
|
| 915 | - } |
|
| 916 | - } |
|
| 917 | - // types |
|
| 918 | - if (count($this->schemas)>=1) {
|
|
| 919 | - $xml .= "\n<types>\n"; |
|
| 920 | - foreach ($this->schemas as $ns => $list) {
|
|
| 921 | - foreach ($list as $xs) {
|
|
| 922 | - $xml .= $xs->serializeSchema(); |
|
| 923 | - } |
|
| 924 | - } |
|
| 925 | - $xml .= '</types>'; |
|
| 926 | - } |
|
| 927 | - // messages |
|
| 928 | - if (count($this->messages) >= 1) {
|
|
| 929 | - foreach($this->messages as $msgName => $msgParts) {
|
|
| 930 | - $xml .= "\n<message name=\"" . $msgName . '">'; |
|
| 931 | - if(is_array($msgParts)){
|
|
| 932 | - foreach($msgParts as $partName => $partType) {
|
|
| 933 | - // print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>'; |
|
| 934 | - if (strpos($partType, ':')) {
|
|
| 935 | - $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType)); |
|
| 936 | - } elseif (isset($this->typemap[$this->namespaces['xsd']][$partType])) {
|
|
| 937 | - // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>'; |
|
| 938 | - $typePrefix = 'xsd'; |
|
| 939 | - } else {
|
|
| 940 | - foreach($this->typemap as $ns => $types) {
|
|
| 941 | - if (isset($types[$partType])) {
|
|
| 942 | - $typePrefix = $this->getPrefixFromNamespace($ns); |
|
| 943 | - } |
|
| 944 | - } |
|
| 945 | - if (!isset($typePrefix)) {
|
|
| 946 | - die("$partType has no namespace!");
|
|
| 947 | - } |
|
| 948 | - } |
|
| 949 | - $ns = $this->getNamespaceFromPrefix($typePrefix); |
|
| 950 | - $localPart = $this->getLocalPart($partType); |
|
| 951 | - $typeDef = $this->getTypeDef($localPart, $ns); |
|
| 952 | - if ($typeDef['typeClass'] == 'element') {
|
|
| 953 | - $elementortype = 'element'; |
|
| 954 | - if (substr($localPart, -1) == '^') {
|
|
| 955 | - $localPart = substr($localPart, 0, -1); |
|
| 956 | - } |
|
| 957 | - } else {
|
|
| 958 | - $elementortype = 'type'; |
|
| 959 | - } |
|
| 960 | - $xml .= "\n" . ' <part name="' . $partName . '" ' . $elementortype . '="' . $typePrefix . ':' . $localPart . '" />'; |
|
| 961 | - } |
|
| 962 | - } |
|
| 963 | - $xml .= '</message>'; |
|
| 964 | - } |
|
| 965 | - } |
|
| 966 | - // bindings & porttypes |
|
| 967 | - if (count($this->bindings) >= 1) {
|
|
| 968 | - $binding_xml = ''; |
|
| 969 | - $portType_xml = ''; |
|
| 970 | - foreach($this->bindings as $bindingName => $attrs) {
|
|
| 971 | - $binding_xml .= "\n<binding name=\"" . $bindingName . '" type="tns:' . $attrs['portType'] . '">'; |
|
| 972 | - $binding_xml .= "\n" . ' <soap:binding style="' . $attrs['style'] . '" transport="' . $attrs['transport'] . '"/>'; |
|
| 973 | - $portType_xml .= "\n<portType name=\"" . $attrs['portType'] . '">'; |
|
| 974 | - foreach($attrs['operations'] as $opName => $opParts) {
|
|
| 975 | - $binding_xml .= "\n" . ' <operation name="' . $opName . '">'; |
|
| 976 | - $binding_xml .= "\n" . ' <soap:operation soapAction="' . $opParts['soapAction'] . '" style="'. $opParts['style'] . '"/>'; |
|
| 977 | - if (isset($opParts['input']['encodingStyle']) && $opParts['input']['encodingStyle'] != '') {
|
|
| 978 | - $enc_style = ' encodingStyle="' . $opParts['input']['encodingStyle'] . '"'; |
|
| 979 | - } else {
|
|
| 980 | - $enc_style = ''; |
|
| 981 | - } |
|
| 982 | - $binding_xml .= "\n" . ' <input><soap:body use="' . $opParts['input']['use'] . '" namespace="' . $opParts['input']['namespace'] . '"' . $enc_style . '/></input>'; |
|
| 983 | - if (isset($opParts['output']['encodingStyle']) && $opParts['output']['encodingStyle'] != '') {
|
|
| 984 | - $enc_style = ' encodingStyle="' . $opParts['output']['encodingStyle'] . '"'; |
|
| 985 | - } else {
|
|
| 986 | - $enc_style = ''; |
|
| 987 | - } |
|
| 988 | - $binding_xml .= "\n" . ' <output><soap:body use="' . $opParts['output']['use'] . '" namespace="' . $opParts['output']['namespace'] . '"' . $enc_style . '/></output>'; |
|
| 989 | - $binding_xml .= "\n" . ' </operation>'; |
|
| 990 | - $portType_xml .= "\n" . ' <operation name="' . $opParts['name'] . '"'; |
|
| 991 | - if (isset($opParts['parameterOrder'])) {
|
|
| 992 | - $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"'; |
|
| 993 | - } |
|
| 994 | - $portType_xml .= '>'; |
|
| 995 | - if(isset($opParts['documentation']) && $opParts['documentation'] != '') {
|
|
| 996 | - $portType_xml .= "\n" . ' <documentation>' . htmlspecialchars($opParts['documentation']) . '</documentation>'; |
|
| 997 | - } |
|
| 998 | - $portType_xml .= "\n" . ' <input message="tns:' . $opParts['input']['message'] . '"/>'; |
|
| 999 | - $portType_xml .= "\n" . ' <output message="tns:' . $opParts['output']['message'] . '"/>'; |
|
| 1000 | - $portType_xml .= "\n" . ' </operation>'; |
|
| 1001 | - } |
|
| 1002 | - $portType_xml .= "\n" . '</portType>'; |
|
| 1003 | - $binding_xml .= "\n" . '</binding>'; |
|
| 1004 | - } |
|
| 1005 | - $xml .= $portType_xml . $binding_xml; |
|
| 1006 | - } |
|
| 1007 | - // services |
|
| 1008 | - $xml .= "\n<service name=\"" . $this->serviceName . '">'; |
|
| 1009 | - if (count($this->ports) >= 1) {
|
|
| 1010 | - foreach($this->ports as $pName => $attrs) {
|
|
| 1011 | - $xml .= "\n" . ' <port name="' . $pName . '" binding="tns:' . $attrs['binding'] . '">'; |
|
| 1012 | - $xml .= "\n" . ' <soap:address location="' . $attrs['location'] . ($debug ? '?debug=1' : '') . '"/>'; |
|
| 1013 | - $xml .= "\n" . ' </port>'; |
|
| 1014 | - } |
|
| 1015 | - } |
|
| 1016 | - $xml .= "\n" . '</service>'; |
|
| 1017 | - return $xml . "\n</definitions>"; |
|
| 1018 | - } |
|
| 883 | + /** |
|
| 884 | + * serialize the parsed wsdl |
|
| 885 | + * |
|
| 886 | + * @param mixed $debug whether to put debug=1 in endpoint URL |
|
| 887 | + * @return string serialization of WSDL |
|
| 888 | + * @access public |
|
| 889 | + */ |
|
| 890 | + function serialize($debug = 0) |
|
| 891 | + {
|
|
| 892 | + $xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'; |
|
| 893 | + $xml .= "\n<definitions"; |
|
| 894 | + foreach($this->namespaces as $k => $v) {
|
|
| 895 | + $xml .= " xmlns:$k=\"$v\""; |
|
| 896 | + } |
|
| 897 | + // 10.9.02 - add poulter fix for wsdl and tns declarations |
|
| 898 | + if (isset($this->namespaces['wsdl'])) {
|
|
| 899 | + $xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\""; |
|
| 900 | + } |
|
| 901 | + if (isset($this->namespaces['tns'])) {
|
|
| 902 | + $xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\""; |
|
| 903 | + } |
|
| 904 | + $xml .= '>'; |
|
| 905 | + // imports |
|
| 906 | + if (sizeof($this->import) > 0) {
|
|
| 907 | + foreach($this->import as $ns => $list) {
|
|
| 908 | + foreach ($list as $ii) {
|
|
| 909 | + if ($ii['location'] != '') {
|
|
| 910 | + $xml .= '<import location="' . $ii['location'] . '" namespace="' . $ns . '" />'; |
|
| 911 | + } else {
|
|
| 912 | + $xml .= '<import namespace="' . $ns . '" />'; |
|
| 913 | + } |
|
| 914 | + } |
|
| 915 | + } |
|
| 916 | + } |
|
| 917 | + // types |
|
| 918 | + if (count($this->schemas)>=1) {
|
|
| 919 | + $xml .= "\n<types>\n"; |
|
| 920 | + foreach ($this->schemas as $ns => $list) {
|
|
| 921 | + foreach ($list as $xs) {
|
|
| 922 | + $xml .= $xs->serializeSchema(); |
|
| 923 | + } |
|
| 924 | + } |
|
| 925 | + $xml .= '</types>'; |
|
| 926 | + } |
|
| 927 | + // messages |
|
| 928 | + if (count($this->messages) >= 1) {
|
|
| 929 | + foreach($this->messages as $msgName => $msgParts) {
|
|
| 930 | + $xml .= "\n<message name=\"" . $msgName . '">'; |
|
| 931 | + if(is_array($msgParts)){
|
|
| 932 | + foreach($msgParts as $partName => $partType) {
|
|
| 933 | + // print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>'; |
|
| 934 | + if (strpos($partType, ':')) {
|
|
| 935 | + $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType)); |
|
| 936 | + } elseif (isset($this->typemap[$this->namespaces['xsd']][$partType])) {
|
|
| 937 | + // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>'; |
|
| 938 | + $typePrefix = 'xsd'; |
|
| 939 | + } else {
|
|
| 940 | + foreach($this->typemap as $ns => $types) {
|
|
| 941 | + if (isset($types[$partType])) {
|
|
| 942 | + $typePrefix = $this->getPrefixFromNamespace($ns); |
|
| 943 | + } |
|
| 944 | + } |
|
| 945 | + if (!isset($typePrefix)) {
|
|
| 946 | + die("$partType has no namespace!");
|
|
| 947 | + } |
|
| 948 | + } |
|
| 949 | + $ns = $this->getNamespaceFromPrefix($typePrefix); |
|
| 950 | + $localPart = $this->getLocalPart($partType); |
|
| 951 | + $typeDef = $this->getTypeDef($localPart, $ns); |
|
| 952 | + if ($typeDef['typeClass'] == 'element') {
|
|
| 953 | + $elementortype = 'element'; |
|
| 954 | + if (substr($localPart, -1) == '^') {
|
|
| 955 | + $localPart = substr($localPart, 0, -1); |
|
| 956 | + } |
|
| 957 | + } else {
|
|
| 958 | + $elementortype = 'type'; |
|
| 959 | + } |
|
| 960 | + $xml .= "\n" . ' <part name="' . $partName . '" ' . $elementortype . '="' . $typePrefix . ':' . $localPart . '" />'; |
|
| 961 | + } |
|
| 962 | + } |
|
| 963 | + $xml .= '</message>'; |
|
| 964 | + } |
|
| 965 | + } |
|
| 966 | + // bindings & porttypes |
|
| 967 | + if (count($this->bindings) >= 1) {
|
|
| 968 | + $binding_xml = ''; |
|
| 969 | + $portType_xml = ''; |
|
| 970 | + foreach($this->bindings as $bindingName => $attrs) {
|
|
| 971 | + $binding_xml .= "\n<binding name=\"" . $bindingName . '" type="tns:' . $attrs['portType'] . '">'; |
|
| 972 | + $binding_xml .= "\n" . ' <soap:binding style="' . $attrs['style'] . '" transport="' . $attrs['transport'] . '"/>'; |
|
| 973 | + $portType_xml .= "\n<portType name=\"" . $attrs['portType'] . '">'; |
|
| 974 | + foreach($attrs['operations'] as $opName => $opParts) {
|
|
| 975 | + $binding_xml .= "\n" . ' <operation name="' . $opName . '">'; |
|
| 976 | + $binding_xml .= "\n" . ' <soap:operation soapAction="' . $opParts['soapAction'] . '" style="'. $opParts['style'] . '"/>'; |
|
| 977 | + if (isset($opParts['input']['encodingStyle']) && $opParts['input']['encodingStyle'] != '') {
|
|
| 978 | + $enc_style = ' encodingStyle="' . $opParts['input']['encodingStyle'] . '"'; |
|
| 979 | + } else {
|
|
| 980 | + $enc_style = ''; |
|
| 981 | + } |
|
| 982 | + $binding_xml .= "\n" . ' <input><soap:body use="' . $opParts['input']['use'] . '" namespace="' . $opParts['input']['namespace'] . '"' . $enc_style . '/></input>'; |
|
| 983 | + if (isset($opParts['output']['encodingStyle']) && $opParts['output']['encodingStyle'] != '') {
|
|
| 984 | + $enc_style = ' encodingStyle="' . $opParts['output']['encodingStyle'] . '"'; |
|
| 985 | + } else {
|
|
| 986 | + $enc_style = ''; |
|
| 987 | + } |
|
| 988 | + $binding_xml .= "\n" . ' <output><soap:body use="' . $opParts['output']['use'] . '" namespace="' . $opParts['output']['namespace'] . '"' . $enc_style . '/></output>'; |
|
| 989 | + $binding_xml .= "\n" . ' </operation>'; |
|
| 990 | + $portType_xml .= "\n" . ' <operation name="' . $opParts['name'] . '"'; |
|
| 991 | + if (isset($opParts['parameterOrder'])) {
|
|
| 992 | + $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"'; |
|
| 993 | + } |
|
| 994 | + $portType_xml .= '>'; |
|
| 995 | + if(isset($opParts['documentation']) && $opParts['documentation'] != '') {
|
|
| 996 | + $portType_xml .= "\n" . ' <documentation>' . htmlspecialchars($opParts['documentation']) . '</documentation>'; |
|
| 997 | + } |
|
| 998 | + $portType_xml .= "\n" . ' <input message="tns:' . $opParts['input']['message'] . '"/>'; |
|
| 999 | + $portType_xml .= "\n" . ' <output message="tns:' . $opParts['output']['message'] . '"/>'; |
|
| 1000 | + $portType_xml .= "\n" . ' </operation>'; |
|
| 1001 | + } |
|
| 1002 | + $portType_xml .= "\n" . '</portType>'; |
|
| 1003 | + $binding_xml .= "\n" . '</binding>'; |
|
| 1004 | + } |
|
| 1005 | + $xml .= $portType_xml . $binding_xml; |
|
| 1006 | + } |
|
| 1007 | + // services |
|
| 1008 | + $xml .= "\n<service name=\"" . $this->serviceName . '">'; |
|
| 1009 | + if (count($this->ports) >= 1) {
|
|
| 1010 | + foreach($this->ports as $pName => $attrs) {
|
|
| 1011 | + $xml .= "\n" . ' <port name="' . $pName . '" binding="tns:' . $attrs['binding'] . '">'; |
|
| 1012 | + $xml .= "\n" . ' <soap:address location="' . $attrs['location'] . ($debug ? '?debug=1' : '') . '"/>'; |
|
| 1013 | + $xml .= "\n" . ' </port>'; |
|
| 1014 | + } |
|
| 1015 | + } |
|
| 1016 | + $xml .= "\n" . '</service>'; |
|
| 1017 | + return $xml . "\n</definitions>"; |
|
| 1018 | + } |
|
| 1019 | 1019 | |
| 1020 | - /** |
|
| 1021 | - * determine whether a set of parameters are unwrapped |
|
| 1022 | - * when they are expect to be wrapped, Microsoft-style. |
|
| 1023 | - * |
|
| 1024 | - * @param string $type the type (element name) of the wrapper |
|
| 1025 | - * @param array $parameters the parameter values for the SOAP call |
|
| 1026 | - * @return boolean whether they parameters are unwrapped (and should be wrapped) |
|
| 1027 | - * @access private |
|
| 1028 | - */ |
|
| 1029 | - function parametersMatchWrapped($type, &$parameters) {
|
|
| 1030 | - $this->debug("in parametersMatchWrapped type=$type, parameters=");
|
|
| 1031 | - $this->appendDebug($this->varDump($parameters)); |
|
| 1020 | + /** |
|
| 1021 | + * determine whether a set of parameters are unwrapped |
|
| 1022 | + * when they are expect to be wrapped, Microsoft-style. |
|
| 1023 | + * |
|
| 1024 | + * @param string $type the type (element name) of the wrapper |
|
| 1025 | + * @param array $parameters the parameter values for the SOAP call |
|
| 1026 | + * @return boolean whether they parameters are unwrapped (and should be wrapped) |
|
| 1027 | + * @access private |
|
| 1028 | + */ |
|
| 1029 | + function parametersMatchWrapped($type, &$parameters) {
|
|
| 1030 | + $this->debug("in parametersMatchWrapped type=$type, parameters=");
|
|
| 1031 | + $this->appendDebug($this->varDump($parameters)); |
|
| 1032 | 1032 | |
| 1033 | - // split type into namespace:unqualified-type |
|
| 1034 | - if (strpos($type, ':')) {
|
|
| 1035 | - $uqType = substr($type, strrpos($type, ':') + 1); |
|
| 1036 | - $ns = substr($type, 0, strrpos($type, ':')); |
|
| 1037 | - $this->debug("in parametersMatchWrapped: got a prefixed type: $uqType, $ns");
|
|
| 1038 | - if ($this->getNamespaceFromPrefix($ns)) {
|
|
| 1039 | - $ns = $this->getNamespaceFromPrefix($ns); |
|
| 1040 | - $this->debug("in parametersMatchWrapped: expanded prefixed type: $uqType, $ns");
|
|
| 1041 | - } |
|
| 1042 | - } else {
|
|
| 1043 | - // TODO: should the type be compared to types in XSD, and the namespace |
|
| 1044 | - // set to XSD if the type matches? |
|
| 1045 | - $this->debug("in parametersMatchWrapped: No namespace for type $type");
|
|
| 1046 | - $ns = ''; |
|
| 1047 | - $uqType = $type; |
|
| 1048 | - } |
|
| 1033 | + // split type into namespace:unqualified-type |
|
| 1034 | + if (strpos($type, ':')) {
|
|
| 1035 | + $uqType = substr($type, strrpos($type, ':') + 1); |
|
| 1036 | + $ns = substr($type, 0, strrpos($type, ':')); |
|
| 1037 | + $this->debug("in parametersMatchWrapped: got a prefixed type: $uqType, $ns");
|
|
| 1038 | + if ($this->getNamespaceFromPrefix($ns)) {
|
|
| 1039 | + $ns = $this->getNamespaceFromPrefix($ns); |
|
| 1040 | + $this->debug("in parametersMatchWrapped: expanded prefixed type: $uqType, $ns");
|
|
| 1041 | + } |
|
| 1042 | + } else {
|
|
| 1043 | + // TODO: should the type be compared to types in XSD, and the namespace |
|
| 1044 | + // set to XSD if the type matches? |
|
| 1045 | + $this->debug("in parametersMatchWrapped: No namespace for type $type");
|
|
| 1046 | + $ns = ''; |
|
| 1047 | + $uqType = $type; |
|
| 1048 | + } |
|
| 1049 | 1049 | |
| 1050 | - // get the type information |
|
| 1051 | - if (!$typeDef = $this->getTypeDef($uqType, $ns)) {
|
|
| 1052 | - $this->debug("in parametersMatchWrapped: $type ($uqType) is not a supported type.");
|
|
| 1053 | - return false; |
|
| 1054 | - } |
|
| 1055 | - $this->debug("in parametersMatchWrapped: found typeDef=");
|
|
| 1056 | - $this->appendDebug($this->varDump($typeDef)); |
|
| 1057 | - if (substr($uqType, -1) == '^') {
|
|
| 1058 | - $uqType = substr($uqType, 0, -1); |
|
| 1059 | - } |
|
| 1060 | - $phpType = $typeDef['phpType']; |
|
| 1061 | - $arrayType = (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : ''); |
|
| 1062 | - $this->debug("in parametersMatchWrapped: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: $arrayType");
|
|
| 1050 | + // get the type information |
|
| 1051 | + if (!$typeDef = $this->getTypeDef($uqType, $ns)) {
|
|
| 1052 | + $this->debug("in parametersMatchWrapped: $type ($uqType) is not a supported type.");
|
|
| 1053 | + return false; |
|
| 1054 | + } |
|
| 1055 | + $this->debug("in parametersMatchWrapped: found typeDef=");
|
|
| 1056 | + $this->appendDebug($this->varDump($typeDef)); |
|
| 1057 | + if (substr($uqType, -1) == '^') {
|
|
| 1058 | + $uqType = substr($uqType, 0, -1); |
|
| 1059 | + } |
|
| 1060 | + $phpType = $typeDef['phpType']; |
|
| 1061 | + $arrayType = (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : ''); |
|
| 1062 | + $this->debug("in parametersMatchWrapped: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: $arrayType");
|
|
| 1063 | 1063 | |
| 1064 | - // we expect a complexType or element of complexType |
|
| 1065 | - if ($phpType != 'struct') {
|
|
| 1066 | - $this->debug("in parametersMatchWrapped: not a struct");
|
|
| 1067 | - return false; |
|
| 1068 | - } |
|
| 1064 | + // we expect a complexType or element of complexType |
|
| 1065 | + if ($phpType != 'struct') {
|
|
| 1066 | + $this->debug("in parametersMatchWrapped: not a struct");
|
|
| 1067 | + return false; |
|
| 1068 | + } |
|
| 1069 | 1069 | |
| 1070 | - // see whether the parameter names match the elements |
|
| 1071 | - if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
|
|
| 1072 | - $elements = 0; |
|
| 1073 | - $matches = 0; |
|
| 1074 | - foreach ($typeDef['elements'] as $name => $attrs) {
|
|
| 1075 | - if (isset($parameters[$name])) {
|
|
| 1076 | - $this->debug("in parametersMatchWrapped: have parameter named $name");
|
|
| 1077 | - $matches++; |
|
| 1078 | - } else {
|
|
| 1079 | - $this->debug("in parametersMatchWrapped: do not have parameter named $name");
|
|
| 1080 | - } |
|
| 1081 | - $elements++; |
|
| 1082 | - } |
|
| 1070 | + // see whether the parameter names match the elements |
|
| 1071 | + if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
|
|
| 1072 | + $elements = 0; |
|
| 1073 | + $matches = 0; |
|
| 1074 | + foreach ($typeDef['elements'] as $name => $attrs) {
|
|
| 1075 | + if (isset($parameters[$name])) {
|
|
| 1076 | + $this->debug("in parametersMatchWrapped: have parameter named $name");
|
|
| 1077 | + $matches++; |
|
| 1078 | + } else {
|
|
| 1079 | + $this->debug("in parametersMatchWrapped: do not have parameter named $name");
|
|
| 1080 | + } |
|
| 1081 | + $elements++; |
|
| 1082 | + } |
|
| 1083 | 1083 | |
| 1084 | - $this->debug("in parametersMatchWrapped: $matches parameter names match $elements wrapped parameter names");
|
|
| 1085 | - if ($matches == 0) {
|
|
| 1086 | - return false; |
|
| 1087 | - } |
|
| 1088 | - return true; |
|
| 1089 | - } |
|
| 1084 | + $this->debug("in parametersMatchWrapped: $matches parameter names match $elements wrapped parameter names");
|
|
| 1085 | + if ($matches == 0) {
|
|
| 1086 | + return false; |
|
| 1087 | + } |
|
| 1088 | + return true; |
|
| 1089 | + } |
|
| 1090 | 1090 | |
| 1091 | - // since there are no elements for the type, if the user passed no |
|
| 1092 | - // parameters, the parameters match wrapped. |
|
| 1093 | - $this->debug("in parametersMatchWrapped: no elements type $ns:$uqType");
|
|
| 1094 | - return count($parameters) == 0; |
|
| 1095 | - } |
|
| 1091 | + // since there are no elements for the type, if the user passed no |
|
| 1092 | + // parameters, the parameters match wrapped. |
|
| 1093 | + $this->debug("in parametersMatchWrapped: no elements type $ns:$uqType");
|
|
| 1094 | + return count($parameters) == 0; |
|
| 1095 | + } |
|
| 1096 | 1096 | |
| 1097 | - /** |
|
| 1098 | - * serialize PHP values according to a WSDL message definition |
|
| 1099 | - * contrary to the method name, this is not limited to RPC |
|
| 1100 | - * |
|
| 1101 | - * TODO |
|
| 1102 | - * - multi-ref serialization |
|
| 1103 | - * - validate PHP values against type definitions, return errors if invalid |
|
| 1104 | - * |
|
| 1105 | - * @param string $operation operation name |
|
| 1106 | - * @param string $direction (input|output) |
|
| 1107 | - * @param mixed $parameters parameter value(s) |
|
| 1108 | - * @param string $bindingType (soap|soap12) |
|
| 1109 | - * @return mixed parameters serialized as XML or false on error (e.g. operation not found) |
|
| 1110 | - * @access public |
|
| 1111 | - */ |
|
| 1112 | - function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') {
|
|
| 1113 | - $this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType");
|
|
| 1114 | - $this->appendDebug('parameters=' . $this->varDump($parameters));
|
|
| 1097 | + /** |
|
| 1098 | + * serialize PHP values according to a WSDL message definition |
|
| 1099 | + * contrary to the method name, this is not limited to RPC |
|
| 1100 | + * |
|
| 1101 | + * TODO |
|
| 1102 | + * - multi-ref serialization |
|
| 1103 | + * - validate PHP values against type definitions, return errors if invalid |
|
| 1104 | + * |
|
| 1105 | + * @param string $operation operation name |
|
| 1106 | + * @param string $direction (input|output) |
|
| 1107 | + * @param mixed $parameters parameter value(s) |
|
| 1108 | + * @param string $bindingType (soap|soap12) |
|
| 1109 | + * @return mixed parameters serialized as XML or false on error (e.g. operation not found) |
|
| 1110 | + * @access public |
|
| 1111 | + */ |
|
| 1112 | + function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') {
|
|
| 1113 | + $this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType");
|
|
| 1114 | + $this->appendDebug('parameters=' . $this->varDump($parameters));
|
|
| 1115 | 1115 | |
| 1116 | - if ($direction != 'input' && $direction != 'output') {
|
|
| 1117 | - $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
|
|
| 1118 | - $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
|
|
| 1119 | - return false; |
|
| 1120 | - } |
|
| 1121 | - if (!$opData = $this->getOperationData($operation, $bindingType)) {
|
|
| 1122 | - $this->debug('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
|
|
| 1123 | - $this->setError('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
|
|
| 1124 | - return false; |
|
| 1125 | - } |
|
| 1126 | - $this->debug('in serializeRPCParameters: opData:');
|
|
| 1127 | - $this->appendDebug($this->varDump($opData)); |
|
| 1116 | + if ($direction != 'input' && $direction != 'output') {
|
|
| 1117 | + $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
|
|
| 1118 | + $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
|
|
| 1119 | + return false; |
|
| 1120 | + } |
|
| 1121 | + if (!$opData = $this->getOperationData($operation, $bindingType)) {
|
|
| 1122 | + $this->debug('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
|
|
| 1123 | + $this->setError('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
|
|
| 1124 | + return false; |
|
| 1125 | + } |
|
| 1126 | + $this->debug('in serializeRPCParameters: opData:');
|
|
| 1127 | + $this->appendDebug($this->varDump($opData)); |
|
| 1128 | 1128 | |
| 1129 | - // Get encoding style for output and set to current |
|
| 1130 | - $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; |
|
| 1131 | - if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
|
|
| 1132 | - $encodingStyle = $opData['output']['encodingStyle']; |
|
| 1133 | - $enc_style = $encodingStyle; |
|
| 1134 | - } |
|
| 1129 | + // Get encoding style for output and set to current |
|
| 1130 | + $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; |
|
| 1131 | + if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
|
|
| 1132 | + $encodingStyle = $opData['output']['encodingStyle']; |
|
| 1133 | + $enc_style = $encodingStyle; |
|
| 1134 | + } |
|
| 1135 | 1135 | |
| 1136 | - // set input params |
|
| 1137 | - $xml = ''; |
|
| 1138 | - if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
|
|
| 1139 | - $parts = &$opData[$direction]['parts']; |
|
| 1140 | - $part_count = sizeof($parts); |
|
| 1141 | - $style = $opData['style']; |
|
| 1142 | - $use = $opData[$direction]['use']; |
|
| 1143 | - $this->debug("have $part_count part(s) to serialize using $style/$use");
|
|
| 1144 | - if (is_array($parameters)) {
|
|
| 1145 | - $parametersArrayType = $this->isArraySimpleOrStruct($parameters); |
|
| 1146 | - $parameter_count = count($parameters); |
|
| 1147 | - $this->debug("have $parameter_count parameter(s) provided as $parametersArrayType to serialize");
|
|
| 1148 | - // check for Microsoft-style wrapped parameters |
|
| 1149 | - if ($style == 'document' && $use == 'literal' && $part_count == 1 && isset($parts['parameters'])) {
|
|
| 1150 | - $this->debug('check whether the caller has wrapped the parameters');
|
|
| 1151 | - if ($direction == 'output' && $parametersArrayType == 'arraySimple' && $parameter_count == 1) {
|
|
| 1152 | - // TODO: consider checking here for double-wrapping, when |
|
| 1153 | - // service function wraps, then NuSOAP wraps again |
|
| 1154 | - $this->debug("change simple array to associative with 'parameters' element");
|
|
| 1155 | - $parameters['parameters'] = $parameters[0]; |
|
| 1156 | - unset($parameters[0]); |
|
| 1157 | - } |
|
| 1158 | - if (($parametersArrayType == 'arrayStruct' || $parameter_count == 0) && !isset($parameters['parameters'])) {
|
|
| 1159 | - $this->debug('check whether caller\'s parameters match the wrapped ones');
|
|
| 1160 | - if ($this->parametersMatchWrapped($parts['parameters'], $parameters)) {
|
|
| 1161 | - $this->debug('wrap the parameters for the caller');
|
|
| 1162 | - $parameters = array('parameters' => $parameters);
|
|
| 1163 | - $parameter_count = 1; |
|
| 1164 | - } |
|
| 1165 | - } |
|
| 1166 | - } |
|
| 1167 | - foreach ($parts as $name => $type) {
|
|
| 1168 | - $this->debug("serializing part $name of type $type");
|
|
| 1169 | - // Track encoding style |
|
| 1170 | - if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
|
|
| 1171 | - $encodingStyle = $opData[$direction]['encodingStyle']; |
|
| 1172 | - $enc_style = $encodingStyle; |
|
| 1173 | - } else {
|
|
| 1174 | - $enc_style = false; |
|
| 1175 | - } |
|
| 1176 | - // NOTE: add error handling here |
|
| 1177 | - // if serializeType returns false, then catch global error and fault |
|
| 1178 | - if ($parametersArrayType == 'arraySimple') {
|
|
| 1179 | - $p = array_shift($parameters); |
|
| 1180 | - $this->debug('calling serializeType w/indexed param');
|
|
| 1181 | - $xml .= $this->serializeType($name, $type, $p, $use, $enc_style); |
|
| 1182 | - } elseif (isset($parameters[$name])) {
|
|
| 1183 | - $this->debug('calling serializeType w/named param');
|
|
| 1184 | - $xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style); |
|
| 1185 | - } else {
|
|
| 1186 | - // TODO: only send nillable |
|
| 1187 | - $this->debug('calling serializeType w/null param');
|
|
| 1188 | - $xml .= $this->serializeType($name, $type, null, $use, $enc_style); |
|
| 1189 | - } |
|
| 1190 | - } |
|
| 1191 | - } else {
|
|
| 1192 | - $this->debug('no parameters passed.');
|
|
| 1193 | - } |
|
| 1194 | - } |
|
| 1195 | - $this->debug("serializeRPCParameters returning: $xml");
|
|
| 1196 | - return $xml; |
|
| 1197 | - } |
|
| 1136 | + // set input params |
|
| 1137 | + $xml = ''; |
|
| 1138 | + if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
|
|
| 1139 | + $parts = &$opData[$direction]['parts']; |
|
| 1140 | + $part_count = sizeof($parts); |
|
| 1141 | + $style = $opData['style']; |
|
| 1142 | + $use = $opData[$direction]['use']; |
|
| 1143 | + $this->debug("have $part_count part(s) to serialize using $style/$use");
|
|
| 1144 | + if (is_array($parameters)) {
|
|
| 1145 | + $parametersArrayType = $this->isArraySimpleOrStruct($parameters); |
|
| 1146 | + $parameter_count = count($parameters); |
|
| 1147 | + $this->debug("have $parameter_count parameter(s) provided as $parametersArrayType to serialize");
|
|
| 1148 | + // check for Microsoft-style wrapped parameters |
|
| 1149 | + if ($style == 'document' && $use == 'literal' && $part_count == 1 && isset($parts['parameters'])) {
|
|
| 1150 | + $this->debug('check whether the caller has wrapped the parameters');
|
|
| 1151 | + if ($direction == 'output' && $parametersArrayType == 'arraySimple' && $parameter_count == 1) {
|
|
| 1152 | + // TODO: consider checking here for double-wrapping, when |
|
| 1153 | + // service function wraps, then NuSOAP wraps again |
|
| 1154 | + $this->debug("change simple array to associative with 'parameters' element");
|
|
| 1155 | + $parameters['parameters'] = $parameters[0]; |
|
| 1156 | + unset($parameters[0]); |
|
| 1157 | + } |
|
| 1158 | + if (($parametersArrayType == 'arrayStruct' || $parameter_count == 0) && !isset($parameters['parameters'])) {
|
|
| 1159 | + $this->debug('check whether caller\'s parameters match the wrapped ones');
|
|
| 1160 | + if ($this->parametersMatchWrapped($parts['parameters'], $parameters)) {
|
|
| 1161 | + $this->debug('wrap the parameters for the caller');
|
|
| 1162 | + $parameters = array('parameters' => $parameters);
|
|
| 1163 | + $parameter_count = 1; |
|
| 1164 | + } |
|
| 1165 | + } |
|
| 1166 | + } |
|
| 1167 | + foreach ($parts as $name => $type) {
|
|
| 1168 | + $this->debug("serializing part $name of type $type");
|
|
| 1169 | + // Track encoding style |
|
| 1170 | + if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
|
|
| 1171 | + $encodingStyle = $opData[$direction]['encodingStyle']; |
|
| 1172 | + $enc_style = $encodingStyle; |
|
| 1173 | + } else {
|
|
| 1174 | + $enc_style = false; |
|
| 1175 | + } |
|
| 1176 | + // NOTE: add error handling here |
|
| 1177 | + // if serializeType returns false, then catch global error and fault |
|
| 1178 | + if ($parametersArrayType == 'arraySimple') {
|
|
| 1179 | + $p = array_shift($parameters); |
|
| 1180 | + $this->debug('calling serializeType w/indexed param');
|
|
| 1181 | + $xml .= $this->serializeType($name, $type, $p, $use, $enc_style); |
|
| 1182 | + } elseif (isset($parameters[$name])) {
|
|
| 1183 | + $this->debug('calling serializeType w/named param');
|
|
| 1184 | + $xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style); |
|
| 1185 | + } else {
|
|
| 1186 | + // TODO: only send nillable |
|
| 1187 | + $this->debug('calling serializeType w/null param');
|
|
| 1188 | + $xml .= $this->serializeType($name, $type, null, $use, $enc_style); |
|
| 1189 | + } |
|
| 1190 | + } |
|
| 1191 | + } else {
|
|
| 1192 | + $this->debug('no parameters passed.');
|
|
| 1193 | + } |
|
| 1194 | + } |
|
| 1195 | + $this->debug("serializeRPCParameters returning: $xml");
|
|
| 1196 | + return $xml; |
|
| 1197 | + } |
|
| 1198 | 1198 | |
| 1199 | - /** |
|
| 1200 | - * serialize a PHP value according to a WSDL message definition |
|
| 1201 | - * |
|
| 1202 | - * TODO |
|
| 1203 | - * - multi-ref serialization |
|
| 1204 | - * - validate PHP values against type definitions, return errors if invalid |
|
| 1205 | - * |
|
| 1206 | - * @param string $operation operation name |
|
| 1207 | - * @param string $direction (input|output) |
|
| 1208 | - * @param mixed $parameters parameter value(s) |
|
| 1209 | - * @return mixed parameters serialized as XML or false on error (e.g. operation not found) |
|
| 1210 | - * @access public |
|
| 1211 | - * @deprecated |
|
| 1212 | - */ |
|
| 1213 | - function serializeParameters($operation, $direction, $parameters) |
|
| 1214 | - {
|
|
| 1215 | - $this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
|
|
| 1216 | - $this->appendDebug('parameters=' . $this->varDump($parameters));
|
|
| 1199 | + /** |
|
| 1200 | + * serialize a PHP value according to a WSDL message definition |
|
| 1201 | + * |
|
| 1202 | + * TODO |
|
| 1203 | + * - multi-ref serialization |
|
| 1204 | + * - validate PHP values against type definitions, return errors if invalid |
|
| 1205 | + * |
|
| 1206 | + * @param string $operation operation name |
|
| 1207 | + * @param string $direction (input|output) |
|
| 1208 | + * @param mixed $parameters parameter value(s) |
|
| 1209 | + * @return mixed parameters serialized as XML or false on error (e.g. operation not found) |
|
| 1210 | + * @access public |
|
| 1211 | + * @deprecated |
|
| 1212 | + */ |
|
| 1213 | + function serializeParameters($operation, $direction, $parameters) |
|
| 1214 | + {
|
|
| 1215 | + $this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
|
|
| 1216 | + $this->appendDebug('parameters=' . $this->varDump($parameters));
|
|
| 1217 | 1217 | |
| 1218 | - if ($direction != 'input' && $direction != 'output') {
|
|
| 1219 | - $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
|
|
| 1220 | - $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
|
|
| 1221 | - return false; |
|
| 1222 | - } |
|
| 1223 | - if (!$opData = $this->getOperationData($operation)) {
|
|
| 1224 | - $this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
|
|
| 1225 | - $this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
|
|
| 1226 | - return false; |
|
| 1227 | - } |
|
| 1228 | - $this->debug('opData:');
|
|
| 1229 | - $this->appendDebug($this->varDump($opData)); |
|
| 1218 | + if ($direction != 'input' && $direction != 'output') {
|
|
| 1219 | + $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
|
|
| 1220 | + $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
|
|
| 1221 | + return false; |
|
| 1222 | + } |
|
| 1223 | + if (!$opData = $this->getOperationData($operation)) {
|
|
| 1224 | + $this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
|
|
| 1225 | + $this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
|
|
| 1226 | + return false; |
|
| 1227 | + } |
|
| 1228 | + $this->debug('opData:');
|
|
| 1229 | + $this->appendDebug($this->varDump($opData)); |
|
| 1230 | 1230 | |
| 1231 | - // Get encoding style for output and set to current |
|
| 1232 | - $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; |
|
| 1233 | - if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
|
|
| 1234 | - $encodingStyle = $opData['output']['encodingStyle']; |
|
| 1235 | - $enc_style = $encodingStyle; |
|
| 1236 | - } |
|
| 1231 | + // Get encoding style for output and set to current |
|
| 1232 | + $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; |
|
| 1233 | + if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
|
|
| 1234 | + $encodingStyle = $opData['output']['encodingStyle']; |
|
| 1235 | + $enc_style = $encodingStyle; |
|
| 1236 | + } |
|
| 1237 | 1237 | |
| 1238 | - // set input params |
|
| 1239 | - $xml = ''; |
|
| 1240 | - if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
|
|
| 1238 | + // set input params |
|
| 1239 | + $xml = ''; |
|
| 1240 | + if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
|
|
| 1241 | 1241 | |
| 1242 | - $use = $opData[$direction]['use']; |
|
| 1243 | - $this->debug("use=$use");
|
|
| 1244 | - $this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)');
|
|
| 1245 | - if (is_array($parameters)) {
|
|
| 1246 | - $parametersArrayType = $this->isArraySimpleOrStruct($parameters); |
|
| 1247 | - $this->debug('have ' . $parametersArrayType . ' parameters');
|
|
| 1248 | - foreach($opData[$direction]['parts'] as $name => $type) {
|
|
| 1249 | - $this->debug('serializing part "'.$name.'" of type "'.$type.'"');
|
|
| 1250 | - // Track encoding style |
|
| 1251 | - if(isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
|
|
| 1252 | - $encodingStyle = $opData[$direction]['encodingStyle']; |
|
| 1253 | - $enc_style = $encodingStyle; |
|
| 1254 | - } else {
|
|
| 1255 | - $enc_style = false; |
|
| 1256 | - } |
|
| 1257 | - // NOTE: add error handling here |
|
| 1258 | - // if serializeType returns false, then catch global error and fault |
|
| 1259 | - if ($parametersArrayType == 'arraySimple') {
|
|
| 1260 | - $p = array_shift($parameters); |
|
| 1261 | - $this->debug('calling serializeType w/indexed param');
|
|
| 1262 | - $xml .= $this->serializeType($name, $type, $p, $use, $enc_style); |
|
| 1263 | - } elseif (isset($parameters[$name])) {
|
|
| 1264 | - $this->debug('calling serializeType w/named param');
|
|
| 1265 | - $xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style); |
|
| 1266 | - } else {
|
|
| 1267 | - // TODO: only send nillable |
|
| 1268 | - $this->debug('calling serializeType w/null param');
|
|
| 1269 | - $xml .= $this->serializeType($name, $type, null, $use, $enc_style); |
|
| 1270 | - } |
|
| 1271 | - } |
|
| 1272 | - } else {
|
|
| 1273 | - $this->debug('no parameters passed.');
|
|
| 1274 | - } |
|
| 1275 | - } |
|
| 1276 | - $this->debug("serializeParameters returning: $xml");
|
|
| 1277 | - return $xml; |
|
| 1278 | - } |
|
| 1242 | + $use = $opData[$direction]['use']; |
|
| 1243 | + $this->debug("use=$use");
|
|
| 1244 | + $this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)');
|
|
| 1245 | + if (is_array($parameters)) {
|
|
| 1246 | + $parametersArrayType = $this->isArraySimpleOrStruct($parameters); |
|
| 1247 | + $this->debug('have ' . $parametersArrayType . ' parameters');
|
|
| 1248 | + foreach($opData[$direction]['parts'] as $name => $type) {
|
|
| 1249 | + $this->debug('serializing part "'.$name.'" of type "'.$type.'"');
|
|
| 1250 | + // Track encoding style |
|
| 1251 | + if(isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
|
|
| 1252 | + $encodingStyle = $opData[$direction]['encodingStyle']; |
|
| 1253 | + $enc_style = $encodingStyle; |
|
| 1254 | + } else {
|
|
| 1255 | + $enc_style = false; |
|
| 1256 | + } |
|
| 1257 | + // NOTE: add error handling here |
|
| 1258 | + // if serializeType returns false, then catch global error and fault |
|
| 1259 | + if ($parametersArrayType == 'arraySimple') {
|
|
| 1260 | + $p = array_shift($parameters); |
|
| 1261 | + $this->debug('calling serializeType w/indexed param');
|
|
| 1262 | + $xml .= $this->serializeType($name, $type, $p, $use, $enc_style); |
|
| 1263 | + } elseif (isset($parameters[$name])) {
|
|
| 1264 | + $this->debug('calling serializeType w/named param');
|
|
| 1265 | + $xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style); |
|
| 1266 | + } else {
|
|
| 1267 | + // TODO: only send nillable |
|
| 1268 | + $this->debug('calling serializeType w/null param');
|
|
| 1269 | + $xml .= $this->serializeType($name, $type, null, $use, $enc_style); |
|
| 1270 | + } |
|
| 1271 | + } |
|
| 1272 | + } else {
|
|
| 1273 | + $this->debug('no parameters passed.');
|
|
| 1274 | + } |
|
| 1275 | + } |
|
| 1276 | + $this->debug("serializeParameters returning: $xml");
|
|
| 1277 | + return $xml; |
|
| 1278 | + } |
|
| 1279 | 1279 | |
| 1280 | - /** |
|
| 1281 | - * serializes a PHP value according a given type definition |
|
| 1282 | - * |
|
| 1283 | - * @param string $name name of value (part or element) |
|
| 1284 | - * @param string $type XML schema type of value (type or element) |
|
| 1285 | - * @param mixed $value a native PHP value (parameter value) |
|
| 1286 | - * @param string $use use for part (encoded|literal) |
|
| 1287 | - * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style) |
|
| 1288 | - * @param boolean $unqualified a kludge for what should be XML namespace form handling |
|
| 1289 | - * @return string value serialized as an XML string |
|
| 1290 | - * @access private |
|
| 1291 | - */ |
|
| 1292 | - function serializeType($name, $type, $value, $use='encoded', $encodingStyle=false, $unqualified=false) |
|
| 1293 | - {
|
|
| 1294 | - $this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified"));
|
|
| 1295 | - $this->appendDebug("value=" . $this->varDump($value));
|
|
| 1296 | - if($use == 'encoded' && $encodingStyle) {
|
|
| 1297 | - $encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"'; |
|
| 1298 | - } |
|
| 1280 | + /** |
|
| 1281 | + * serializes a PHP value according a given type definition |
|
| 1282 | + * |
|
| 1283 | + * @param string $name name of value (part or element) |
|
| 1284 | + * @param string $type XML schema type of value (type or element) |
|
| 1285 | + * @param mixed $value a native PHP value (parameter value) |
|
| 1286 | + * @param string $use use for part (encoded|literal) |
|
| 1287 | + * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style) |
|
| 1288 | + * @param boolean $unqualified a kludge for what should be XML namespace form handling |
|
| 1289 | + * @return string value serialized as an XML string |
|
| 1290 | + * @access private |
|
| 1291 | + */ |
|
| 1292 | + function serializeType($name, $type, $value, $use='encoded', $encodingStyle=false, $unqualified=false) |
|
| 1293 | + {
|
|
| 1294 | + $this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified"));
|
|
| 1295 | + $this->appendDebug("value=" . $this->varDump($value));
|
|
| 1296 | + if($use == 'encoded' && $encodingStyle) {
|
|
| 1297 | + $encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"'; |
|
| 1298 | + } |
|
| 1299 | 1299 | |
| 1300 | - // if a soapval has been supplied, let its type override the WSDL |
|
| 1301 | - if (is_object($value) && get_class($value) == 'soapval') {
|
|
| 1302 | - if ($value->type_ns) {
|
|
| 1303 | - $type = $value->type_ns . ':' . $value->type; |
|
| 1304 | - $forceType = true; |
|
| 1305 | - $this->debug("in serializeType: soapval overrides type to $type");
|
|
| 1306 | - } elseif ($value->type) {
|
|
| 1307 | - $type = $value->type; |
|
| 1308 | - $forceType = true; |
|
| 1309 | - $this->debug("in serializeType: soapval overrides type to $type");
|
|
| 1310 | - } else {
|
|
| 1311 | - $forceType = false; |
|
| 1312 | - $this->debug("in serializeType: soapval does not override type");
|
|
| 1313 | - } |
|
| 1314 | - $attrs = $value->attributes; |
|
| 1315 | - $value = $value->value; |
|
| 1316 | - $this->debug("in serializeType: soapval overrides value to $value");
|
|
| 1317 | - if ($attrs) {
|
|
| 1318 | - if (!is_array($value)) {
|
|
| 1319 | - $value['!'] = $value; |
|
| 1320 | - } |
|
| 1321 | - foreach ($attrs as $n => $v) {
|
|
| 1322 | - $value['!' . $n] = $v; |
|
| 1323 | - } |
|
| 1324 | - $this->debug("in serializeType: soapval provides attributes");
|
|
| 1325 | - } |
|
| 1300 | + // if a soapval has been supplied, let its type override the WSDL |
|
| 1301 | + if (is_object($value) && get_class($value) == 'soapval') {
|
|
| 1302 | + if ($value->type_ns) {
|
|
| 1303 | + $type = $value->type_ns . ':' . $value->type; |
|
| 1304 | + $forceType = true; |
|
| 1305 | + $this->debug("in serializeType: soapval overrides type to $type");
|
|
| 1306 | + } elseif ($value->type) {
|
|
| 1307 | + $type = $value->type; |
|
| 1308 | + $forceType = true; |
|
| 1309 | + $this->debug("in serializeType: soapval overrides type to $type");
|
|
| 1310 | + } else {
|
|
| 1311 | + $forceType = false; |
|
| 1312 | + $this->debug("in serializeType: soapval does not override type");
|
|
| 1313 | + } |
|
| 1314 | + $attrs = $value->attributes; |
|
| 1315 | + $value = $value->value; |
|
| 1316 | + $this->debug("in serializeType: soapval overrides value to $value");
|
|
| 1317 | + if ($attrs) {
|
|
| 1318 | + if (!is_array($value)) {
|
|
| 1319 | + $value['!'] = $value; |
|
| 1320 | + } |
|
| 1321 | + foreach ($attrs as $n => $v) {
|
|
| 1322 | + $value['!' . $n] = $v; |
|
| 1323 | + } |
|
| 1324 | + $this->debug("in serializeType: soapval provides attributes");
|
|
| 1325 | + } |
|
| 1326 | 1326 | } else {
|
| 1327 | - $forceType = false; |
|
| 1327 | + $forceType = false; |
|
| 1328 | 1328 | } |
| 1329 | 1329 | |
| 1330 | - $xml = ''; |
|
| 1331 | - if (strpos($type, ':')) {
|
|
| 1332 | - $uqType = substr($type, strrpos($type, ':') + 1); |
|
| 1333 | - $ns = substr($type, 0, strrpos($type, ':')); |
|
| 1334 | - $this->debug("in serializeType: got a prefixed type: $uqType, $ns");
|
|
| 1335 | - if ($this->getNamespaceFromPrefix($ns)) {
|
|
| 1336 | - $ns = $this->getNamespaceFromPrefix($ns); |
|
| 1337 | - $this->debug("in serializeType: expanded prefixed type: $uqType, $ns");
|
|
| 1338 | - } |
|
| 1330 | + $xml = ''; |
|
| 1331 | + if (strpos($type, ':')) {
|
|
| 1332 | + $uqType = substr($type, strrpos($type, ':') + 1); |
|
| 1333 | + $ns = substr($type, 0, strrpos($type, ':')); |
|
| 1334 | + $this->debug("in serializeType: got a prefixed type: $uqType, $ns");
|
|
| 1335 | + if ($this->getNamespaceFromPrefix($ns)) {
|
|
| 1336 | + $ns = $this->getNamespaceFromPrefix($ns); |
|
| 1337 | + $this->debug("in serializeType: expanded prefixed type: $uqType, $ns");
|
|
| 1338 | + } |
|
| 1339 | 1339 | |
| 1340 | - if($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/'){
|
|
| 1341 | - $this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
|
|
| 1342 | - if ($unqualified && $use == 'literal') {
|
|
| 1343 | - $elementNS = " xmlns=\"\""; |
|
| 1344 | - } else {
|
|
| 1345 | - $elementNS = ''; |
|
| 1346 | - } |
|
| 1347 | - if (is_null($value)) {
|
|
| 1348 | - if ($use == 'literal') {
|
|
| 1349 | - // TODO: depends on minOccurs |
|
| 1350 | - $xml = "<$name$elementNS/>"; |
|
| 1351 | - } else {
|
|
| 1352 | - // TODO: depends on nillable, which should be checked before calling this method |
|
| 1353 | - $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>"; |
|
| 1354 | - } |
|
| 1355 | - $this->debug("in serializeType: returning: $xml");
|
|
| 1356 | - return $xml; |
|
| 1357 | - } |
|
| 1358 | - if ($uqType == 'Array') {
|
|
| 1359 | - // JBoss/Axis does this sometimes |
|
| 1360 | - return $this->serialize_val($value, $name, false, false, false, false, $use); |
|
| 1361 | - } |
|
| 1362 | - if ($uqType == 'boolean') {
|
|
| 1363 | - if ((is_string($value) && $value == 'false') || (! $value)) {
|
|
| 1364 | - $value = 'false'; |
|
| 1365 | - } else {
|
|
| 1366 | - $value = 'true'; |
|
| 1367 | - } |
|
| 1368 | - } |
|
| 1369 | - if ($uqType == 'string' && gettype($value) == 'string') {
|
|
| 1370 | - $value = $this->expandEntities($value); |
|
| 1371 | - } |
|
| 1372 | - if (($uqType == 'long' || $uqType == 'unsignedLong') && gettype($value) == 'double') {
|
|
| 1373 | - $value = sprintf("%.0lf", $value);
|
|
| 1374 | - } |
|
| 1375 | - // it's a scalar |
|
| 1376 | - // TODO: what about null/nil values? |
|
| 1377 | - // check type isn't a custom type extending xmlschema namespace |
|
| 1378 | - if (!$this->getTypeDef($uqType, $ns)) {
|
|
| 1379 | - if ($use == 'literal') {
|
|
| 1380 | - if ($forceType) {
|
|
| 1381 | - $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>"; |
|
| 1382 | - } else {
|
|
| 1383 | - $xml = "<$name$elementNS>$value</$name>"; |
|
| 1384 | - } |
|
| 1385 | - } else {
|
|
| 1386 | - $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>"; |
|
| 1387 | - } |
|
| 1388 | - $this->debug("in serializeType: returning: $xml");
|
|
| 1389 | - return $xml; |
|
| 1390 | - } |
|
| 1391 | - $this->debug('custom type extends XML Schema or SOAP Encoding namespace (yuck)');
|
|
| 1392 | - } else if ($ns == 'http://xml.apache.org/xml-soap') {
|
|
| 1393 | - $this->debug('in serializeType: appears to be Apache SOAP type');
|
|
| 1394 | - if ($uqType == 'Map') {
|
|
| 1395 | - $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
|
|
| 1396 | - if (! $tt_prefix) {
|
|
| 1397 | - $this->debug('in serializeType: Add namespace for Apache SOAP type');
|
|
| 1398 | - $tt_prefix = 'ns' . rand(1000, 9999); |
|
| 1399 | - $this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap'; |
|
| 1400 | - // force this to be added to usedNamespaces |
|
| 1401 | - $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
|
|
| 1402 | - } |
|
| 1403 | - $contents = ''; |
|
| 1404 | - foreach($value as $k => $v) {
|
|
| 1405 | - $this->debug("serializing map element: key $k, value $v");
|
|
| 1406 | - $contents .= '<item>'; |
|
| 1407 | - $contents .= $this->serialize_val($k,'key',false,false,false,false,$use); |
|
| 1408 | - $contents .= $this->serialize_val($v,'value',false,false,false,false,$use); |
|
| 1409 | - $contents .= '</item>'; |
|
| 1410 | - } |
|
| 1411 | - if ($use == 'literal') {
|
|
| 1412 | - if ($forceType) {
|
|
| 1413 | - $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\">$contents</$name>"; |
|
| 1414 | - } else {
|
|
| 1415 | - $xml = "<$name>$contents</$name>"; |
|
| 1416 | - } |
|
| 1417 | - } else {
|
|
| 1418 | - $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\"$encodingStyle>$contents</$name>"; |
|
| 1419 | - } |
|
| 1420 | - $this->debug("in serializeType: returning: $xml");
|
|
| 1421 | - return $xml; |
|
| 1422 | - } |
|
| 1423 | - $this->debug('in serializeType: Apache SOAP type, but only support Map');
|
|
| 1424 | - } |
|
| 1425 | - } else {
|
|
| 1426 | - // TODO: should the type be compared to types in XSD, and the namespace |
|
| 1427 | - // set to XSD if the type matches? |
|
| 1428 | - $this->debug("in serializeType: No namespace for type $type");
|
|
| 1429 | - $ns = ''; |
|
| 1430 | - $uqType = $type; |
|
| 1431 | - } |
|
| 1432 | - if(!$typeDef = $this->getTypeDef($uqType, $ns)){
|
|
| 1433 | - $this->setError("$type ($uqType) is not a supported type.");
|
|
| 1434 | - $this->debug("in serializeType: $type ($uqType) is not a supported type.");
|
|
| 1435 | - return false; |
|
| 1436 | - } else {
|
|
| 1437 | - $this->debug("in serializeType: found typeDef");
|
|
| 1438 | - $this->appendDebug('typeDef=' . $this->varDump($typeDef));
|
|
| 1439 | - if (substr($uqType, -1) == '^') {
|
|
| 1440 | - $uqType = substr($uqType, 0, -1); |
|
| 1441 | - } |
|
| 1442 | - } |
|
| 1443 | - if (!isset($typeDef['phpType'])) {
|
|
| 1444 | - $this->setError("$type ($uqType) has no phpType.");
|
|
| 1445 | - $this->debug("in serializeType: $type ($uqType) has no phpType.");
|
|
| 1446 | - return false; |
|
| 1447 | - } |
|
| 1448 | - $phpType = $typeDef['phpType']; |
|
| 1449 | - $this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') );
|
|
| 1450 | - // if php type == struct, map value to the <all> element names |
|
| 1451 | - if ($phpType == 'struct') {
|
|
| 1452 | - if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
|
|
| 1453 | - $elementName = $uqType; |
|
| 1454 | - if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
|
|
| 1455 | - $elementNS = " xmlns=\"$ns\""; |
|
| 1456 | - } else {
|
|
| 1457 | - $elementNS = " xmlns=\"\""; |
|
| 1458 | - } |
|
| 1459 | - } else {
|
|
| 1460 | - $elementName = $name; |
|
| 1461 | - if ($unqualified) {
|
|
| 1462 | - $elementNS = " xmlns=\"\""; |
|
| 1463 | - } else {
|
|
| 1464 | - $elementNS = ''; |
|
| 1465 | - } |
|
| 1466 | - } |
|
| 1467 | - if (is_null($value)) {
|
|
| 1468 | - if ($use == 'literal') {
|
|
| 1469 | - // TODO: depends on minOccurs and nillable |
|
| 1470 | - $xml = "<$elementName$elementNS/>"; |
|
| 1471 | - } else {
|
|
| 1472 | - $xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>"; |
|
| 1473 | - } |
|
| 1474 | - $this->debug("in serializeType: returning: $xml");
|
|
| 1475 | - return $xml; |
|
| 1476 | - } |
|
| 1477 | - if (is_object($value)) {
|
|
| 1478 | - $value = get_object_vars($value); |
|
| 1479 | - } |
|
| 1480 | - if (is_array($value)) {
|
|
| 1481 | - $elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType); |
|
| 1482 | - if ($use == 'literal') {
|
|
| 1483 | - if ($forceType) {
|
|
| 1484 | - $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">"; |
|
| 1485 | - } else {
|
|
| 1486 | - $xml = "<$elementName$elementNS$elementAttrs>"; |
|
| 1487 | - } |
|
| 1488 | - } else {
|
|
| 1489 | - $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>"; |
|
| 1490 | - } |
|
| 1340 | + if($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/'){
|
|
| 1341 | + $this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
|
|
| 1342 | + if ($unqualified && $use == 'literal') {
|
|
| 1343 | + $elementNS = " xmlns=\"\""; |
|
| 1344 | + } else {
|
|
| 1345 | + $elementNS = ''; |
|
| 1346 | + } |
|
| 1347 | + if (is_null($value)) {
|
|
| 1348 | + if ($use == 'literal') {
|
|
| 1349 | + // TODO: depends on minOccurs |
|
| 1350 | + $xml = "<$name$elementNS/>"; |
|
| 1351 | + } else {
|
|
| 1352 | + // TODO: depends on nillable, which should be checked before calling this method |
|
| 1353 | + $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>"; |
|
| 1354 | + } |
|
| 1355 | + $this->debug("in serializeType: returning: $xml");
|
|
| 1356 | + return $xml; |
|
| 1357 | + } |
|
| 1358 | + if ($uqType == 'Array') {
|
|
| 1359 | + // JBoss/Axis does this sometimes |
|
| 1360 | + return $this->serialize_val($value, $name, false, false, false, false, $use); |
|
| 1361 | + } |
|
| 1362 | + if ($uqType == 'boolean') {
|
|
| 1363 | + if ((is_string($value) && $value == 'false') || (! $value)) {
|
|
| 1364 | + $value = 'false'; |
|
| 1365 | + } else {
|
|
| 1366 | + $value = 'true'; |
|
| 1367 | + } |
|
| 1368 | + } |
|
| 1369 | + if ($uqType == 'string' && gettype($value) == 'string') {
|
|
| 1370 | + $value = $this->expandEntities($value); |
|
| 1371 | + } |
|
| 1372 | + if (($uqType == 'long' || $uqType == 'unsignedLong') && gettype($value) == 'double') {
|
|
| 1373 | + $value = sprintf("%.0lf", $value);
|
|
| 1374 | + } |
|
| 1375 | + // it's a scalar |
|
| 1376 | + // TODO: what about null/nil values? |
|
| 1377 | + // check type isn't a custom type extending xmlschema namespace |
|
| 1378 | + if (!$this->getTypeDef($uqType, $ns)) {
|
|
| 1379 | + if ($use == 'literal') {
|
|
| 1380 | + if ($forceType) {
|
|
| 1381 | + $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>"; |
|
| 1382 | + } else {
|
|
| 1383 | + $xml = "<$name$elementNS>$value</$name>"; |
|
| 1384 | + } |
|
| 1385 | + } else {
|
|
| 1386 | + $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>"; |
|
| 1387 | + } |
|
| 1388 | + $this->debug("in serializeType: returning: $xml");
|
|
| 1389 | + return $xml; |
|
| 1390 | + } |
|
| 1391 | + $this->debug('custom type extends XML Schema or SOAP Encoding namespace (yuck)');
|
|
| 1392 | + } else if ($ns == 'http://xml.apache.org/xml-soap') {
|
|
| 1393 | + $this->debug('in serializeType: appears to be Apache SOAP type');
|
|
| 1394 | + if ($uqType == 'Map') {
|
|
| 1395 | + $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
|
|
| 1396 | + if (! $tt_prefix) {
|
|
| 1397 | + $this->debug('in serializeType: Add namespace for Apache SOAP type');
|
|
| 1398 | + $tt_prefix = 'ns' . rand(1000, 9999); |
|
| 1399 | + $this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap'; |
|
| 1400 | + // force this to be added to usedNamespaces |
|
| 1401 | + $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
|
|
| 1402 | + } |
|
| 1403 | + $contents = ''; |
|
| 1404 | + foreach($value as $k => $v) {
|
|
| 1405 | + $this->debug("serializing map element: key $k, value $v");
|
|
| 1406 | + $contents .= '<item>'; |
|
| 1407 | + $contents .= $this->serialize_val($k,'key',false,false,false,false,$use); |
|
| 1408 | + $contents .= $this->serialize_val($v,'value',false,false,false,false,$use); |
|
| 1409 | + $contents .= '</item>'; |
|
| 1410 | + } |
|
| 1411 | + if ($use == 'literal') {
|
|
| 1412 | + if ($forceType) {
|
|
| 1413 | + $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\">$contents</$name>"; |
|
| 1414 | + } else {
|
|
| 1415 | + $xml = "<$name>$contents</$name>"; |
|
| 1416 | + } |
|
| 1417 | + } else {
|
|
| 1418 | + $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\"$encodingStyle>$contents</$name>"; |
|
| 1419 | + } |
|
| 1420 | + $this->debug("in serializeType: returning: $xml");
|
|
| 1421 | + return $xml; |
|
| 1422 | + } |
|
| 1423 | + $this->debug('in serializeType: Apache SOAP type, but only support Map');
|
|
| 1424 | + } |
|
| 1425 | + } else {
|
|
| 1426 | + // TODO: should the type be compared to types in XSD, and the namespace |
|
| 1427 | + // set to XSD if the type matches? |
|
| 1428 | + $this->debug("in serializeType: No namespace for type $type");
|
|
| 1429 | + $ns = ''; |
|
| 1430 | + $uqType = $type; |
|
| 1431 | + } |
|
| 1432 | + if(!$typeDef = $this->getTypeDef($uqType, $ns)){
|
|
| 1433 | + $this->setError("$type ($uqType) is not a supported type.");
|
|
| 1434 | + $this->debug("in serializeType: $type ($uqType) is not a supported type.");
|
|
| 1435 | + return false; |
|
| 1436 | + } else {
|
|
| 1437 | + $this->debug("in serializeType: found typeDef");
|
|
| 1438 | + $this->appendDebug('typeDef=' . $this->varDump($typeDef));
|
|
| 1439 | + if (substr($uqType, -1) == '^') {
|
|
| 1440 | + $uqType = substr($uqType, 0, -1); |
|
| 1441 | + } |
|
| 1442 | + } |
|
| 1443 | + if (!isset($typeDef['phpType'])) {
|
|
| 1444 | + $this->setError("$type ($uqType) has no phpType.");
|
|
| 1445 | + $this->debug("in serializeType: $type ($uqType) has no phpType.");
|
|
| 1446 | + return false; |
|
| 1447 | + } |
|
| 1448 | + $phpType = $typeDef['phpType']; |
|
| 1449 | + $this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') );
|
|
| 1450 | + // if php type == struct, map value to the <all> element names |
|
| 1451 | + if ($phpType == 'struct') {
|
|
| 1452 | + if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
|
|
| 1453 | + $elementName = $uqType; |
|
| 1454 | + if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
|
|
| 1455 | + $elementNS = " xmlns=\"$ns\""; |
|
| 1456 | + } else {
|
|
| 1457 | + $elementNS = " xmlns=\"\""; |
|
| 1458 | + } |
|
| 1459 | + } else {
|
|
| 1460 | + $elementName = $name; |
|
| 1461 | + if ($unqualified) {
|
|
| 1462 | + $elementNS = " xmlns=\"\""; |
|
| 1463 | + } else {
|
|
| 1464 | + $elementNS = ''; |
|
| 1465 | + } |
|
| 1466 | + } |
|
| 1467 | + if (is_null($value)) {
|
|
| 1468 | + if ($use == 'literal') {
|
|
| 1469 | + // TODO: depends on minOccurs and nillable |
|
| 1470 | + $xml = "<$elementName$elementNS/>"; |
|
| 1471 | + } else {
|
|
| 1472 | + $xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>"; |
|
| 1473 | + } |
|
| 1474 | + $this->debug("in serializeType: returning: $xml");
|
|
| 1475 | + return $xml; |
|
| 1476 | + } |
|
| 1477 | + if (is_object($value)) {
|
|
| 1478 | + $value = get_object_vars($value); |
|
| 1479 | + } |
|
| 1480 | + if (is_array($value)) {
|
|
| 1481 | + $elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType); |
|
| 1482 | + if ($use == 'literal') {
|
|
| 1483 | + if ($forceType) {
|
|
| 1484 | + $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">"; |
|
| 1485 | + } else {
|
|
| 1486 | + $xml = "<$elementName$elementNS$elementAttrs>"; |
|
| 1487 | + } |
|
| 1488 | + } else {
|
|
| 1489 | + $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>"; |
|
| 1490 | + } |
|
| 1491 | 1491 | |
| 1492 | - if (isset($typeDef['simpleContent']) && $typeDef['simpleContent'] == 'true') {
|
|
| 1493 | - if (isset($value['!'])) {
|
|
| 1494 | - $xml .= $value['!']; |
|
| 1495 | - $this->debug("in serializeType: serialized simpleContent for type $type");
|
|
| 1496 | - } else {
|
|
| 1497 | - $this->debug("in serializeType: no simpleContent to serialize for type $type");
|
|
| 1498 | - } |
|
| 1499 | - } else {
|
|
| 1500 | - // complexContent |
|
| 1501 | - $xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle); |
|
| 1502 | - } |
|
| 1503 | - $xml .= "</$elementName>"; |
|
| 1504 | - } else {
|
|
| 1505 | - $this->debug("in serializeType: phpType is struct, but value is not an array");
|
|
| 1506 | - $this->setError("phpType is struct, but value is not an array: see debug output for details");
|
|
| 1507 | - $xml = ''; |
|
| 1508 | - } |
|
| 1509 | - } elseif ($phpType == 'array') {
|
|
| 1510 | - if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
|
|
| 1511 | - $elementNS = " xmlns=\"$ns\""; |
|
| 1512 | - } else {
|
|
| 1513 | - if ($unqualified) {
|
|
| 1514 | - $elementNS = " xmlns=\"\""; |
|
| 1515 | - } else {
|
|
| 1516 | - $elementNS = ''; |
|
| 1517 | - } |
|
| 1518 | - } |
|
| 1519 | - if (is_null($value)) {
|
|
| 1520 | - if ($use == 'literal') {
|
|
| 1521 | - // TODO: depends on minOccurs |
|
| 1522 | - $xml = "<$name$elementNS/>"; |
|
| 1523 | - } else {
|
|
| 1524 | - $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . |
|
| 1525 | - $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
|
|
| 1526 | - ":Array\" " . |
|
| 1527 | - $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
|
|
| 1528 | - ':arrayType="' . |
|
| 1529 | - $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) . |
|
| 1530 | - ':' . |
|
| 1531 | - $this->getLocalPart($typeDef['arrayType'])."[0]\"/>"; |
|
| 1532 | - } |
|
| 1533 | - $this->debug("in serializeType: returning: $xml");
|
|
| 1534 | - return $xml; |
|
| 1535 | - } |
|
| 1536 | - if (isset($typeDef['multidimensional'])) {
|
|
| 1537 | - $nv = array(); |
|
| 1538 | - foreach($value as $v) {
|
|
| 1539 | - $cols = ',' . sizeof($v); |
|
| 1540 | - $nv = array_merge($nv, $v); |
|
| 1541 | - } |
|
| 1542 | - $value = $nv; |
|
| 1543 | - } else {
|
|
| 1544 | - $cols = ''; |
|
| 1545 | - } |
|
| 1546 | - if (is_array($value) && sizeof($value) >= 1) {
|
|
| 1547 | - $rows = sizeof($value); |
|
| 1548 | - $contents = ''; |
|
| 1549 | - foreach($value as $k => $v) {
|
|
| 1550 | - //$this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
|
|
| 1551 | - //if (strpos($typeDef['arrayType'], ':') ) {
|
|
| 1552 | - if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) {
|
|
| 1553 | - $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use);
|
|
| 1554 | - } else {
|
|
| 1555 | - $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use); |
|
| 1556 | - } |
|
| 1557 | - } |
|
| 1558 | - } else {
|
|
| 1559 | - $rows = 0; |
|
| 1560 | - $contents = null; |
|
| 1561 | - } |
|
| 1562 | - // TODO: for now, an empty value will be serialized as a zero element |
|
| 1563 | - // array. Revisit this when coding the handling of null/nil values. |
|
| 1564 | - if ($use == 'literal') {
|
|
| 1565 | - $xml = "<$name$elementNS>" |
|
| 1566 | - .$contents |
|
| 1567 | - ."</$name>"; |
|
| 1568 | - } else {
|
|
| 1569 | - $xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').':Array" '.
|
|
| 1570 | - $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/')
|
|
| 1571 | - .':arrayType="' |
|
| 1572 | - .$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) |
|
| 1573 | - .":".$this->getLocalPart($typeDef['arrayType'])."[$rows$cols]\">" |
|
| 1574 | - .$contents |
|
| 1575 | - ."</$name>"; |
|
| 1576 | - } |
|
| 1577 | - } elseif ($phpType == 'scalar') {
|
|
| 1578 | - if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
|
|
| 1579 | - $elementNS = " xmlns=\"$ns\""; |
|
| 1580 | - } else {
|
|
| 1581 | - if ($unqualified) {
|
|
| 1582 | - $elementNS = " xmlns=\"\""; |
|
| 1583 | - } else {
|
|
| 1584 | - $elementNS = ''; |
|
| 1585 | - } |
|
| 1586 | - } |
|
| 1587 | - if ($use == 'literal') {
|
|
| 1588 | - if ($forceType) {
|
|
| 1589 | - $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>"; |
|
| 1590 | - } else {
|
|
| 1591 | - $xml = "<$name$elementNS>$value</$name>"; |
|
| 1592 | - } |
|
| 1593 | - } else {
|
|
| 1594 | - $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>"; |
|
| 1595 | - } |
|
| 1596 | - } |
|
| 1597 | - $this->debug("in serializeType: returning: $xml");
|
|
| 1598 | - return $xml; |
|
| 1599 | - } |
|
| 1492 | + if (isset($typeDef['simpleContent']) && $typeDef['simpleContent'] == 'true') {
|
|
| 1493 | + if (isset($value['!'])) {
|
|
| 1494 | + $xml .= $value['!']; |
|
| 1495 | + $this->debug("in serializeType: serialized simpleContent for type $type");
|
|
| 1496 | + } else {
|
|
| 1497 | + $this->debug("in serializeType: no simpleContent to serialize for type $type");
|
|
| 1498 | + } |
|
| 1499 | + } else {
|
|
| 1500 | + // complexContent |
|
| 1501 | + $xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle); |
|
| 1502 | + } |
|
| 1503 | + $xml .= "</$elementName>"; |
|
| 1504 | + } else {
|
|
| 1505 | + $this->debug("in serializeType: phpType is struct, but value is not an array");
|
|
| 1506 | + $this->setError("phpType is struct, but value is not an array: see debug output for details");
|
|
| 1507 | + $xml = ''; |
|
| 1508 | + } |
|
| 1509 | + } elseif ($phpType == 'array') {
|
|
| 1510 | + if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
|
|
| 1511 | + $elementNS = " xmlns=\"$ns\""; |
|
| 1512 | + } else {
|
|
| 1513 | + if ($unqualified) {
|
|
| 1514 | + $elementNS = " xmlns=\"\""; |
|
| 1515 | + } else {
|
|
| 1516 | + $elementNS = ''; |
|
| 1517 | + } |
|
| 1518 | + } |
|
| 1519 | + if (is_null($value)) {
|
|
| 1520 | + if ($use == 'literal') {
|
|
| 1521 | + // TODO: depends on minOccurs |
|
| 1522 | + $xml = "<$name$elementNS/>"; |
|
| 1523 | + } else {
|
|
| 1524 | + $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . |
|
| 1525 | + $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
|
|
| 1526 | + ":Array\" " . |
|
| 1527 | + $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
|
|
| 1528 | + ':arrayType="' . |
|
| 1529 | + $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) . |
|
| 1530 | + ':' . |
|
| 1531 | + $this->getLocalPart($typeDef['arrayType'])."[0]\"/>"; |
|
| 1532 | + } |
|
| 1533 | + $this->debug("in serializeType: returning: $xml");
|
|
| 1534 | + return $xml; |
|
| 1535 | + } |
|
| 1536 | + if (isset($typeDef['multidimensional'])) {
|
|
| 1537 | + $nv = array(); |
|
| 1538 | + foreach($value as $v) {
|
|
| 1539 | + $cols = ',' . sizeof($v); |
|
| 1540 | + $nv = array_merge($nv, $v); |
|
| 1541 | + } |
|
| 1542 | + $value = $nv; |
|
| 1543 | + } else {
|
|
| 1544 | + $cols = ''; |
|
| 1545 | + } |
|
| 1546 | + if (is_array($value) && sizeof($value) >= 1) {
|
|
| 1547 | + $rows = sizeof($value); |
|
| 1548 | + $contents = ''; |
|
| 1549 | + foreach($value as $k => $v) {
|
|
| 1550 | + //$this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
|
|
| 1551 | + //if (strpos($typeDef['arrayType'], ':') ) {
|
|
| 1552 | + if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) {
|
|
| 1553 | + $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use);
|
|
| 1554 | + } else {
|
|
| 1555 | + $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use); |
|
| 1556 | + } |
|
| 1557 | + } |
|
| 1558 | + } else {
|
|
| 1559 | + $rows = 0; |
|
| 1560 | + $contents = null; |
|
| 1561 | + } |
|
| 1562 | + // TODO: for now, an empty value will be serialized as a zero element |
|
| 1563 | + // array. Revisit this when coding the handling of null/nil values. |
|
| 1564 | + if ($use == 'literal') {
|
|
| 1565 | + $xml = "<$name$elementNS>" |
|
| 1566 | + .$contents |
|
| 1567 | + ."</$name>"; |
|
| 1568 | + } else {
|
|
| 1569 | + $xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').':Array" '.
|
|
| 1570 | + $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/')
|
|
| 1571 | + .':arrayType="' |
|
| 1572 | + .$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) |
|
| 1573 | + .":".$this->getLocalPart($typeDef['arrayType'])."[$rows$cols]\">" |
|
| 1574 | + .$contents |
|
| 1575 | + ."</$name>"; |
|
| 1576 | + } |
|
| 1577 | + } elseif ($phpType == 'scalar') {
|
|
| 1578 | + if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
|
|
| 1579 | + $elementNS = " xmlns=\"$ns\""; |
|
| 1580 | + } else {
|
|
| 1581 | + if ($unqualified) {
|
|
| 1582 | + $elementNS = " xmlns=\"\""; |
|
| 1583 | + } else {
|
|
| 1584 | + $elementNS = ''; |
|
| 1585 | + } |
|
| 1586 | + } |
|
| 1587 | + if ($use == 'literal') {
|
|
| 1588 | + if ($forceType) {
|
|
| 1589 | + $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>"; |
|
| 1590 | + } else {
|
|
| 1591 | + $xml = "<$name$elementNS>$value</$name>"; |
|
| 1592 | + } |
|
| 1593 | + } else {
|
|
| 1594 | + $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>"; |
|
| 1595 | + } |
|
| 1596 | + } |
|
| 1597 | + $this->debug("in serializeType: returning: $xml");
|
|
| 1598 | + return $xml; |
|
| 1599 | + } |
|
| 1600 | 1600 | |
| 1601 | - /** |
|
| 1602 | - * serializes the attributes for a complexType |
|
| 1603 | - * |
|
| 1604 | - * @param array $typeDef our internal representation of an XML schema type (or element) |
|
| 1605 | - * @param mixed $value a native PHP value (parameter value) |
|
| 1606 | - * @param string $ns the namespace of the type |
|
| 1607 | - * @param string $uqType the local part of the type |
|
| 1608 | - * @return string value serialized as an XML string |
|
| 1609 | - * @access private |
|
| 1610 | - */ |
|
| 1611 | - function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) {
|
|
| 1612 | - $this->debug("serializeComplexTypeAttributes for XML Schema type $ns:$uqType");
|
|
| 1613 | - $xml = ''; |
|
| 1614 | - if (isset($typeDef['extensionBase'])) {
|
|
| 1615 | - $nsx = $this->getPrefix($typeDef['extensionBase']); |
|
| 1616 | - $uqTypex = $this->getLocalPart($typeDef['extensionBase']); |
|
| 1617 | - if ($this->getNamespaceFromPrefix($nsx)) {
|
|
| 1618 | - $nsx = $this->getNamespaceFromPrefix($nsx); |
|
| 1619 | - } |
|
| 1620 | - if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
|
|
| 1621 | - $this->debug("serialize attributes for extension base $nsx:$uqTypex");
|
|
| 1622 | - $xml .= $this->serializeComplexTypeAttributes($typeDefx, $value, $nsx, $uqTypex); |
|
| 1623 | - } else {
|
|
| 1624 | - $this->debug("extension base $nsx:$uqTypex is not a supported type");
|
|
| 1625 | - } |
|
| 1626 | - } |
|
| 1627 | - if (isset($typeDef['attrs']) && is_array($typeDef['attrs'])) {
|
|
| 1628 | - $this->debug("serialize attributes for XML Schema type $ns:$uqType");
|
|
| 1629 | - if (is_array($value)) {
|
|
| 1630 | - $xvalue = $value; |
|
| 1631 | - } elseif (is_object($value)) {
|
|
| 1632 | - $xvalue = get_object_vars($value); |
|
| 1633 | - } else {
|
|
| 1634 | - $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
|
|
| 1635 | - $xvalue = array(); |
|
| 1636 | - } |
|
| 1637 | - foreach ($typeDef['attrs'] as $aName => $attrs) {
|
|
| 1638 | - if (isset($xvalue['!' . $aName])) {
|
|
| 1639 | - $xname = '!' . $aName; |
|
| 1640 | - $this->debug("value provided for attribute $aName with key $xname");
|
|
| 1641 | - } elseif (isset($xvalue[$aName])) {
|
|
| 1642 | - $xname = $aName; |
|
| 1643 | - $this->debug("value provided for attribute $aName with key $xname");
|
|
| 1644 | - } elseif (isset($attrs['default'])) {
|
|
| 1645 | - $xname = '!' . $aName; |
|
| 1646 | - $xvalue[$xname] = $attrs['default']; |
|
| 1647 | - $this->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName);
|
|
| 1648 | - } else {
|
|
| 1649 | - $xname = ''; |
|
| 1650 | - $this->debug("no value provided for attribute $aName");
|
|
| 1651 | - } |
|
| 1652 | - if ($xname) {
|
|
| 1653 | - $xml .= " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\""; |
|
| 1654 | - } |
|
| 1655 | - } |
|
| 1656 | - } else {
|
|
| 1657 | - $this->debug("no attributes to serialize for XML Schema type $ns:$uqType");
|
|
| 1658 | - } |
|
| 1659 | - return $xml; |
|
| 1660 | - } |
|
| 1601 | + /** |
|
| 1602 | + * serializes the attributes for a complexType |
|
| 1603 | + * |
|
| 1604 | + * @param array $typeDef our internal representation of an XML schema type (or element) |
|
| 1605 | + * @param mixed $value a native PHP value (parameter value) |
|
| 1606 | + * @param string $ns the namespace of the type |
|
| 1607 | + * @param string $uqType the local part of the type |
|
| 1608 | + * @return string value serialized as an XML string |
|
| 1609 | + * @access private |
|
| 1610 | + */ |
|
| 1611 | + function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) {
|
|
| 1612 | + $this->debug("serializeComplexTypeAttributes for XML Schema type $ns:$uqType");
|
|
| 1613 | + $xml = ''; |
|
| 1614 | + if (isset($typeDef['extensionBase'])) {
|
|
| 1615 | + $nsx = $this->getPrefix($typeDef['extensionBase']); |
|
| 1616 | + $uqTypex = $this->getLocalPart($typeDef['extensionBase']); |
|
| 1617 | + if ($this->getNamespaceFromPrefix($nsx)) {
|
|
| 1618 | + $nsx = $this->getNamespaceFromPrefix($nsx); |
|
| 1619 | + } |
|
| 1620 | + if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
|
|
| 1621 | + $this->debug("serialize attributes for extension base $nsx:$uqTypex");
|
|
| 1622 | + $xml .= $this->serializeComplexTypeAttributes($typeDefx, $value, $nsx, $uqTypex); |
|
| 1623 | + } else {
|
|
| 1624 | + $this->debug("extension base $nsx:$uqTypex is not a supported type");
|
|
| 1625 | + } |
|
| 1626 | + } |
|
| 1627 | + if (isset($typeDef['attrs']) && is_array($typeDef['attrs'])) {
|
|
| 1628 | + $this->debug("serialize attributes for XML Schema type $ns:$uqType");
|
|
| 1629 | + if (is_array($value)) {
|
|
| 1630 | + $xvalue = $value; |
|
| 1631 | + } elseif (is_object($value)) {
|
|
| 1632 | + $xvalue = get_object_vars($value); |
|
| 1633 | + } else {
|
|
| 1634 | + $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
|
|
| 1635 | + $xvalue = array(); |
|
| 1636 | + } |
|
| 1637 | + foreach ($typeDef['attrs'] as $aName => $attrs) {
|
|
| 1638 | + if (isset($xvalue['!' . $aName])) {
|
|
| 1639 | + $xname = '!' . $aName; |
|
| 1640 | + $this->debug("value provided for attribute $aName with key $xname");
|
|
| 1641 | + } elseif (isset($xvalue[$aName])) {
|
|
| 1642 | + $xname = $aName; |
|
| 1643 | + $this->debug("value provided for attribute $aName with key $xname");
|
|
| 1644 | + } elseif (isset($attrs['default'])) {
|
|
| 1645 | + $xname = '!' . $aName; |
|
| 1646 | + $xvalue[$xname] = $attrs['default']; |
|
| 1647 | + $this->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName);
|
|
| 1648 | + } else {
|
|
| 1649 | + $xname = ''; |
|
| 1650 | + $this->debug("no value provided for attribute $aName");
|
|
| 1651 | + } |
|
| 1652 | + if ($xname) {
|
|
| 1653 | + $xml .= " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\""; |
|
| 1654 | + } |
|
| 1655 | + } |
|
| 1656 | + } else {
|
|
| 1657 | + $this->debug("no attributes to serialize for XML Schema type $ns:$uqType");
|
|
| 1658 | + } |
|
| 1659 | + return $xml; |
|
| 1660 | + } |
|
| 1661 | 1661 | |
| 1662 | - /** |
|
| 1663 | - * serializes the elements for a complexType |
|
| 1664 | - * |
|
| 1665 | - * @param array $typeDef our internal representation of an XML schema type (or element) |
|
| 1666 | - * @param mixed $value a native PHP value (parameter value) |
|
| 1667 | - * @param string $ns the namespace of the type |
|
| 1668 | - * @param string $uqType the local part of the type |
|
| 1669 | - * @param string $use use for part (encoded|literal) |
|
| 1670 | - * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style) |
|
| 1671 | - * @return string value serialized as an XML string |
|
| 1672 | - * @access private |
|
| 1673 | - */ |
|
| 1674 | - function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='encoded', $encodingStyle=false) {
|
|
| 1675 | - $this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType");
|
|
| 1676 | - $xml = ''; |
|
| 1677 | - if (isset($typeDef['extensionBase'])) {
|
|
| 1678 | - $nsx = $this->getPrefix($typeDef['extensionBase']); |
|
| 1679 | - $uqTypex = $this->getLocalPart($typeDef['extensionBase']); |
|
| 1680 | - if ($this->getNamespaceFromPrefix($nsx)) {
|
|
| 1681 | - $nsx = $this->getNamespaceFromPrefix($nsx); |
|
| 1682 | - } |
|
| 1683 | - if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
|
|
| 1684 | - $this->debug("serialize elements for extension base $nsx:$uqTypex");
|
|
| 1685 | - $xml .= $this->serializeComplexTypeElements($typeDefx, $value, $nsx, $uqTypex, $use, $encodingStyle); |
|
| 1686 | - } else {
|
|
| 1687 | - $this->debug("extension base $nsx:$uqTypex is not a supported type");
|
|
| 1688 | - } |
|
| 1689 | - } |
|
| 1690 | - if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
|
|
| 1691 | - $this->debug("in serializeComplexTypeElements, serialize elements for XML Schema type $ns:$uqType");
|
|
| 1692 | - if (is_array($value)) {
|
|
| 1693 | - $xvalue = $value; |
|
| 1694 | - } elseif (is_object($value)) {
|
|
| 1695 | - $xvalue = get_object_vars($value); |
|
| 1696 | - } else {
|
|
| 1697 | - $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
|
|
| 1698 | - $xvalue = array(); |
|
| 1699 | - } |
|
| 1700 | - // toggle whether all elements are present - ideally should validate against schema |
|
| 1701 | - if (count($typeDef['elements']) != count($xvalue)){
|
|
| 1702 | - $optionals = true; |
|
| 1703 | - } |
|
| 1704 | - foreach ($typeDef['elements'] as $eName => $attrs) {
|
|
| 1705 | - if (!isset($xvalue[$eName])) {
|
|
| 1706 | - if (isset($attrs['default'])) {
|
|
| 1707 | - $xvalue[$eName] = $attrs['default']; |
|
| 1708 | - $this->debug('use default value of ' . $xvalue[$eName] . ' for element ' . $eName);
|
|
| 1709 | - } |
|
| 1710 | - } |
|
| 1711 | - // if user took advantage of a minOccurs=0, then only serialize named parameters |
|
| 1712 | - if (isset($optionals) |
|
| 1713 | - && (!isset($xvalue[$eName])) |
|
| 1714 | - && ( (!isset($attrs['nillable'])) || $attrs['nillable'] != 'true') |
|
| 1715 | - ){
|
|
| 1716 | - if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') {
|
|
| 1717 | - $this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minOccurs']);
|
|
| 1718 | - } |
|
| 1719 | - // do nothing |
|
| 1720 | - $this->debug("no value provided for complexType element $eName and element is not nillable, so serialize nothing");
|
|
| 1721 | - } else {
|
|
| 1722 | - // get value |
|
| 1723 | - if (isset($xvalue[$eName])) {
|
|
| 1724 | - $v = $xvalue[$eName]; |
|
| 1725 | - } else {
|
|
| 1726 | - $v = null; |
|
| 1727 | - } |
|
| 1728 | - if (isset($attrs['form'])) {
|
|
| 1729 | - $unqualified = ($attrs['form'] == 'unqualified'); |
|
| 1730 | - } else {
|
|
| 1731 | - $unqualified = false; |
|
| 1732 | - } |
|
| 1733 | - if (isset($attrs['maxOccurs']) && ($attrs['maxOccurs'] == 'unbounded' || $attrs['maxOccurs'] > 1) && isset($v) && is_array($v) && $this->isArraySimpleOrStruct($v) == 'arraySimple') {
|
|
| 1734 | - $vv = $v; |
|
| 1735 | - foreach ($vv as $k => $v) {
|
|
| 1736 | - if (isset($attrs['type']) || isset($attrs['ref'])) {
|
|
| 1737 | - // serialize schema-defined type |
|
| 1738 | - $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); |
|
| 1739 | - } else {
|
|
| 1740 | - // serialize generic type (can this ever really happen?) |
|
| 1741 | - $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
|
|
| 1742 | - $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use); |
|
| 1743 | - } |
|
| 1744 | - } |
|
| 1745 | - } else {
|
|
| 1746 | - if (is_null($v) && isset($attrs['minOccurs']) && $attrs['minOccurs'] == '0') {
|
|
| 1747 | - // do nothing |
|
| 1748 | - } elseif (is_null($v) && isset($attrs['nillable']) && $attrs['nillable'] == 'true') {
|
|
| 1749 | - // TODO: serialize a nil correctly, but for now serialize schema-defined type |
|
| 1750 | - $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); |
|
| 1751 | - } elseif (isset($attrs['type']) || isset($attrs['ref'])) {
|
|
| 1752 | - // serialize schema-defined type |
|
| 1753 | - $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); |
|
| 1754 | - } else {
|
|
| 1755 | - // serialize generic type (can this ever really happen?) |
|
| 1756 | - $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
|
|
| 1757 | - $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use); |
|
| 1758 | - } |
|
| 1759 | - } |
|
| 1760 | - } |
|
| 1761 | - } |
|
| 1762 | - } else {
|
|
| 1763 | - $this->debug("no elements to serialize for XML Schema type $ns:$uqType");
|
|
| 1764 | - } |
|
| 1765 | - return $xml; |
|
| 1766 | - } |
|
| 1662 | + /** |
|
| 1663 | + * serializes the elements for a complexType |
|
| 1664 | + * |
|
| 1665 | + * @param array $typeDef our internal representation of an XML schema type (or element) |
|
| 1666 | + * @param mixed $value a native PHP value (parameter value) |
|
| 1667 | + * @param string $ns the namespace of the type |
|
| 1668 | + * @param string $uqType the local part of the type |
|
| 1669 | + * @param string $use use for part (encoded|literal) |
|
| 1670 | + * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style) |
|
| 1671 | + * @return string value serialized as an XML string |
|
| 1672 | + * @access private |
|
| 1673 | + */ |
|
| 1674 | + function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='encoded', $encodingStyle=false) {
|
|
| 1675 | + $this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType");
|
|
| 1676 | + $xml = ''; |
|
| 1677 | + if (isset($typeDef['extensionBase'])) {
|
|
| 1678 | + $nsx = $this->getPrefix($typeDef['extensionBase']); |
|
| 1679 | + $uqTypex = $this->getLocalPart($typeDef['extensionBase']); |
|
| 1680 | + if ($this->getNamespaceFromPrefix($nsx)) {
|
|
| 1681 | + $nsx = $this->getNamespaceFromPrefix($nsx); |
|
| 1682 | + } |
|
| 1683 | + if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
|
|
| 1684 | + $this->debug("serialize elements for extension base $nsx:$uqTypex");
|
|
| 1685 | + $xml .= $this->serializeComplexTypeElements($typeDefx, $value, $nsx, $uqTypex, $use, $encodingStyle); |
|
| 1686 | + } else {
|
|
| 1687 | + $this->debug("extension base $nsx:$uqTypex is not a supported type");
|
|
| 1688 | + } |
|
| 1689 | + } |
|
| 1690 | + if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
|
|
| 1691 | + $this->debug("in serializeComplexTypeElements, serialize elements for XML Schema type $ns:$uqType");
|
|
| 1692 | + if (is_array($value)) {
|
|
| 1693 | + $xvalue = $value; |
|
| 1694 | + } elseif (is_object($value)) {
|
|
| 1695 | + $xvalue = get_object_vars($value); |
|
| 1696 | + } else {
|
|
| 1697 | + $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
|
|
| 1698 | + $xvalue = array(); |
|
| 1699 | + } |
|
| 1700 | + // toggle whether all elements are present - ideally should validate against schema |
|
| 1701 | + if (count($typeDef['elements']) != count($xvalue)){
|
|
| 1702 | + $optionals = true; |
|
| 1703 | + } |
|
| 1704 | + foreach ($typeDef['elements'] as $eName => $attrs) {
|
|
| 1705 | + if (!isset($xvalue[$eName])) {
|
|
| 1706 | + if (isset($attrs['default'])) {
|
|
| 1707 | + $xvalue[$eName] = $attrs['default']; |
|
| 1708 | + $this->debug('use default value of ' . $xvalue[$eName] . ' for element ' . $eName);
|
|
| 1709 | + } |
|
| 1710 | + } |
|
| 1711 | + // if user took advantage of a minOccurs=0, then only serialize named parameters |
|
| 1712 | + if (isset($optionals) |
|
| 1713 | + && (!isset($xvalue[$eName])) |
|
| 1714 | + && ( (!isset($attrs['nillable'])) || $attrs['nillable'] != 'true') |
|
| 1715 | + ){
|
|
| 1716 | + if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') {
|
|
| 1717 | + $this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minOccurs']);
|
|
| 1718 | + } |
|
| 1719 | + // do nothing |
|
| 1720 | + $this->debug("no value provided for complexType element $eName and element is not nillable, so serialize nothing");
|
|
| 1721 | + } else {
|
|
| 1722 | + // get value |
|
| 1723 | + if (isset($xvalue[$eName])) {
|
|
| 1724 | + $v = $xvalue[$eName]; |
|
| 1725 | + } else {
|
|
| 1726 | + $v = null; |
|
| 1727 | + } |
|
| 1728 | + if (isset($attrs['form'])) {
|
|
| 1729 | + $unqualified = ($attrs['form'] == 'unqualified'); |
|
| 1730 | + } else {
|
|
| 1731 | + $unqualified = false; |
|
| 1732 | + } |
|
| 1733 | + if (isset($attrs['maxOccurs']) && ($attrs['maxOccurs'] == 'unbounded' || $attrs['maxOccurs'] > 1) && isset($v) && is_array($v) && $this->isArraySimpleOrStruct($v) == 'arraySimple') {
|
|
| 1734 | + $vv = $v; |
|
| 1735 | + foreach ($vv as $k => $v) {
|
|
| 1736 | + if (isset($attrs['type']) || isset($attrs['ref'])) {
|
|
| 1737 | + // serialize schema-defined type |
|
| 1738 | + $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); |
|
| 1739 | + } else {
|
|
| 1740 | + // serialize generic type (can this ever really happen?) |
|
| 1741 | + $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
|
|
| 1742 | + $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use); |
|
| 1743 | + } |
|
| 1744 | + } |
|
| 1745 | + } else {
|
|
| 1746 | + if (is_null($v) && isset($attrs['minOccurs']) && $attrs['minOccurs'] == '0') {
|
|
| 1747 | + // do nothing |
|
| 1748 | + } elseif (is_null($v) && isset($attrs['nillable']) && $attrs['nillable'] == 'true') {
|
|
| 1749 | + // TODO: serialize a nil correctly, but for now serialize schema-defined type |
|
| 1750 | + $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); |
|
| 1751 | + } elseif (isset($attrs['type']) || isset($attrs['ref'])) {
|
|
| 1752 | + // serialize schema-defined type |
|
| 1753 | + $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); |
|
| 1754 | + } else {
|
|
| 1755 | + // serialize generic type (can this ever really happen?) |
|
| 1756 | + $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
|
|
| 1757 | + $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use); |
|
| 1758 | + } |
|
| 1759 | + } |
|
| 1760 | + } |
|
| 1761 | + } |
|
| 1762 | + } else {
|
|
| 1763 | + $this->debug("no elements to serialize for XML Schema type $ns:$uqType");
|
|
| 1764 | + } |
|
| 1765 | + return $xml; |
|
| 1766 | + } |
|
| 1767 | 1767 | |
| 1768 | - /** |
|
| 1769 | - * adds an XML Schema complex type to the WSDL types |
|
| 1770 | - * |
|
| 1771 | - * @param string $name |
|
| 1772 | - * @param string $typeClass (complexType|simpleType|attribute) |
|
| 1773 | - * @param string $phpType currently supported are array and struct (php assoc array) |
|
| 1774 | - * @param string $compositor (all|sequence|choice) |
|
| 1775 | - * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 1776 | - * @param array $elements e.g. array ( name => array(name=>'',type=>'') ) |
|
| 1777 | - * @param array $attrs e.g. array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]'))
|
|
| 1778 | - * @param string $arrayType as namespace:name (xsd:string) |
|
| 1779 | - * @see nusoap_xmlschema |
|
| 1780 | - * @access public |
|
| 1781 | - */ |
|
| 1782 | - function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType='') {
|
|
| 1783 | - if (count($elements) > 0) {
|
|
| 1784 | - $eElements = array(); |
|
| 1785 | - foreach($elements as $n => $e){
|
|
| 1786 | - // expand each element |
|
| 1787 | - $ee = array(); |
|
| 1788 | - foreach ($e as $k => $v) {
|
|
| 1789 | - $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 1790 | - $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 1791 | - $ee[$k] = $v; |
|
| 1792 | - } |
|
| 1793 | - $eElements[$n] = $ee; |
|
| 1794 | - } |
|
| 1795 | - $elements = $eElements; |
|
| 1796 | - } |
|
| 1768 | + /** |
|
| 1769 | + * adds an XML Schema complex type to the WSDL types |
|
| 1770 | + * |
|
| 1771 | + * @param string $name |
|
| 1772 | + * @param string $typeClass (complexType|simpleType|attribute) |
|
| 1773 | + * @param string $phpType currently supported are array and struct (php assoc array) |
|
| 1774 | + * @param string $compositor (all|sequence|choice) |
|
| 1775 | + * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 1776 | + * @param array $elements e.g. array ( name => array(name=>'',type=>'') ) |
|
| 1777 | + * @param array $attrs e.g. array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]'))
|
|
| 1778 | + * @param string $arrayType as namespace:name (xsd:string) |
|
| 1779 | + * @see nusoap_xmlschema |
|
| 1780 | + * @access public |
|
| 1781 | + */ |
|
| 1782 | + function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType='') {
|
|
| 1783 | + if (count($elements) > 0) {
|
|
| 1784 | + $eElements = array(); |
|
| 1785 | + foreach($elements as $n => $e){
|
|
| 1786 | + // expand each element |
|
| 1787 | + $ee = array(); |
|
| 1788 | + foreach ($e as $k => $v) {
|
|
| 1789 | + $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 1790 | + $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 1791 | + $ee[$k] = $v; |
|
| 1792 | + } |
|
| 1793 | + $eElements[$n] = $ee; |
|
| 1794 | + } |
|
| 1795 | + $elements = $eElements; |
|
| 1796 | + } |
|
| 1797 | 1797 | |
| 1798 | - if (count($attrs) > 0) {
|
|
| 1799 | - foreach($attrs as $n => $a){
|
|
| 1800 | - // expand each attribute |
|
| 1801 | - foreach ($a as $k => $v) {
|
|
| 1802 | - $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 1803 | - $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 1804 | - $aa[$k] = $v; |
|
| 1805 | - } |
|
| 1806 | - $eAttrs[$n] = $aa; |
|
| 1807 | - } |
|
| 1808 | - $attrs = $eAttrs; |
|
| 1809 | - } |
|
| 1798 | + if (count($attrs) > 0) {
|
|
| 1799 | + foreach($attrs as $n => $a){
|
|
| 1800 | + // expand each attribute |
|
| 1801 | + foreach ($a as $k => $v) {
|
|
| 1802 | + $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 1803 | + $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 1804 | + $aa[$k] = $v; |
|
| 1805 | + } |
|
| 1806 | + $eAttrs[$n] = $aa; |
|
| 1807 | + } |
|
| 1808 | + $attrs = $eAttrs; |
|
| 1809 | + } |
|
| 1810 | 1810 | |
| 1811 | - $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase; |
|
| 1812 | - $arrayType = strpos($arrayType,':') ? $this->expandQname($arrayType) : $arrayType; |
|
| 1811 | + $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase; |
|
| 1812 | + $arrayType = strpos($arrayType,':') ? $this->expandQname($arrayType) : $arrayType; |
|
| 1813 | 1813 | |
| 1814 | - $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns']; |
|
| 1815 | - $this->schemas[$typens][0]->addComplexType($name,$typeClass,$phpType,$compositor,$restrictionBase,$elements,$attrs,$arrayType); |
|
| 1816 | - } |
|
| 1814 | + $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns']; |
|
| 1815 | + $this->schemas[$typens][0]->addComplexType($name,$typeClass,$phpType,$compositor,$restrictionBase,$elements,$attrs,$arrayType); |
|
| 1816 | + } |
|
| 1817 | 1817 | |
| 1818 | - /** |
|
| 1819 | - * adds an XML Schema simple type to the WSDL types |
|
| 1820 | - * |
|
| 1821 | - * @param string $name |
|
| 1822 | - * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 1823 | - * @param string $typeClass (should always be simpleType) |
|
| 1824 | - * @param string $phpType (should always be scalar) |
|
| 1825 | - * @param array $enumeration array of values |
|
| 1826 | - * @see nusoap_xmlschema |
|
| 1827 | - * @access public |
|
| 1828 | - */ |
|
| 1829 | - function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
|
|
| 1830 | - $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase; |
|
| 1818 | + /** |
|
| 1819 | + * adds an XML Schema simple type to the WSDL types |
|
| 1820 | + * |
|
| 1821 | + * @param string $name |
|
| 1822 | + * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 1823 | + * @param string $typeClass (should always be simpleType) |
|
| 1824 | + * @param string $phpType (should always be scalar) |
|
| 1825 | + * @param array $enumeration array of values |
|
| 1826 | + * @see nusoap_xmlschema |
|
| 1827 | + * @access public |
|
| 1828 | + */ |
|
| 1829 | + function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
|
|
| 1830 | + $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase; |
|
| 1831 | 1831 | |
| 1832 | - $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns']; |
|
| 1833 | - $this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumeration); |
|
| 1834 | - } |
|
| 1832 | + $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns']; |
|
| 1833 | + $this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumeration); |
|
| 1834 | + } |
|
| 1835 | 1835 | |
| 1836 | - /** |
|
| 1837 | - * adds an element to the WSDL types |
|
| 1838 | - * |
|
| 1839 | - * @param array $attrs attributes that must include name and type |
|
| 1840 | - * @see nusoap_xmlschema |
|
| 1841 | - * @access public |
|
| 1842 | - */ |
|
| 1843 | - function addElement($attrs) {
|
|
| 1844 | - $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns']; |
|
| 1845 | - $this->schemas[$typens][0]->addElement($attrs); |
|
| 1846 | - } |
|
| 1836 | + /** |
|
| 1837 | + * adds an element to the WSDL types |
|
| 1838 | + * |
|
| 1839 | + * @param array $attrs attributes that must include name and type |
|
| 1840 | + * @see nusoap_xmlschema |
|
| 1841 | + * @access public |
|
| 1842 | + */ |
|
| 1843 | + function addElement($attrs) {
|
|
| 1844 | + $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns']; |
|
| 1845 | + $this->schemas[$typens][0]->addElement($attrs); |
|
| 1846 | + } |
|
| 1847 | 1847 | |
| 1848 | - /** |
|
| 1849 | - * register an operation with the server |
|
| 1850 | - * |
|
| 1851 | - * @param string $name operation (method) name |
|
| 1852 | - * @param array $in assoc array of input values: key = param name, value = param type |
|
| 1853 | - * @param array $out assoc array of output values: key = param name, value = param type |
|
| 1854 | - * @param string $namespace optional The namespace for the operation |
|
| 1855 | - * @param string $soapaction optional The soapaction for the operation |
|
| 1856 | - * @param string $style (rpc|document) optional The style for the operation Note: when 'document' is specified, parameter and return wrappers are created for you automatically |
|
| 1857 | - * @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now) |
|
| 1858 | - * @param string $documentation optional The description to include in the WSDL |
|
| 1859 | - * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
|
| 1860 | - * @access public |
|
| 1861 | - */ |
|
| 1862 | - function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = ''){
|
|
| 1863 | - if ($use == 'encoded' && $encodingStyle == '') {
|
|
| 1864 | - $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; |
|
| 1865 | - } |
|
| 1848 | + /** |
|
| 1849 | + * register an operation with the server |
|
| 1850 | + * |
|
| 1851 | + * @param string $name operation (method) name |
|
| 1852 | + * @param array $in assoc array of input values: key = param name, value = param type |
|
| 1853 | + * @param array $out assoc array of output values: key = param name, value = param type |
|
| 1854 | + * @param string $namespace optional The namespace for the operation |
|
| 1855 | + * @param string $soapaction optional The soapaction for the operation |
|
| 1856 | + * @param string $style (rpc|document) optional The style for the operation Note: when 'document' is specified, parameter and return wrappers are created for you automatically |
|
| 1857 | + * @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now) |
|
| 1858 | + * @param string $documentation optional The description to include in the WSDL |
|
| 1859 | + * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
|
| 1860 | + * @access public |
|
| 1861 | + */ |
|
| 1862 | + function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = ''){
|
|
| 1863 | + if ($use == 'encoded' && $encodingStyle == '') {
|
|
| 1864 | + $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; |
|
| 1865 | + } |
|
| 1866 | 1866 | |
| 1867 | - if ($style == 'document') {
|
|
| 1868 | - $elements = array(); |
|
| 1869 | - foreach ($in as $n => $t) {
|
|
| 1870 | - $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
|
|
| 1871 | - } |
|
| 1872 | - $this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements); |
|
| 1873 | - $this->addElement(array('name' => $name, 'type' => $name . 'RequestType'));
|
|
| 1874 | - $in = array('parameters' => 'tns:' . $name . '^');
|
|
| 1867 | + if ($style == 'document') {
|
|
| 1868 | + $elements = array(); |
|
| 1869 | + foreach ($in as $n => $t) {
|
|
| 1870 | + $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
|
|
| 1871 | + } |
|
| 1872 | + $this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements); |
|
| 1873 | + $this->addElement(array('name' => $name, 'type' => $name . 'RequestType'));
|
|
| 1874 | + $in = array('parameters' => 'tns:' . $name . '^');
|
|
| 1875 | 1875 | |
| 1876 | - $elements = array(); |
|
| 1877 | - foreach ($out as $n => $t) {
|
|
| 1878 | - $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
|
|
| 1879 | - } |
|
| 1880 | - $this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements); |
|
| 1881 | - $this->addElement(array('name' => $name . 'Response', 'type' => $name . 'ResponseType', 'form' => 'qualified'));
|
|
| 1882 | - $out = array('parameters' => 'tns:' . $name . 'Response' . '^');
|
|
| 1883 | - } |
|
| 1876 | + $elements = array(); |
|
| 1877 | + foreach ($out as $n => $t) {
|
|
| 1878 | + $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
|
|
| 1879 | + } |
|
| 1880 | + $this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements); |
|
| 1881 | + $this->addElement(array('name' => $name . 'Response', 'type' => $name . 'ResponseType', 'form' => 'qualified'));
|
|
| 1882 | + $out = array('parameters' => 'tns:' . $name . 'Response' . '^');
|
|
| 1883 | + } |
|
| 1884 | 1884 | |
| 1885 | - // get binding |
|
| 1886 | - $this->bindings[ $this->serviceName . 'Binding' ]['operations'][$name] = |
|
| 1887 | - array( |
|
| 1888 | - 'name' => $name, |
|
| 1889 | - 'binding' => $this->serviceName . 'Binding', |
|
| 1890 | - 'endpoint' => $this->endpoint, |
|
| 1891 | - 'soapAction' => $soapaction, |
|
| 1892 | - 'style' => $style, |
|
| 1893 | - 'input' => array( |
|
| 1894 | - 'use' => $use, |
|
| 1895 | - 'namespace' => $namespace, |
|
| 1896 | - 'encodingStyle' => $encodingStyle, |
|
| 1897 | - 'message' => $name . 'Request', |
|
| 1898 | - 'parts' => $in), |
|
| 1899 | - 'output' => array( |
|
| 1900 | - 'use' => $use, |
|
| 1901 | - 'namespace' => $namespace, |
|
| 1902 | - 'encodingStyle' => $encodingStyle, |
|
| 1903 | - 'message' => $name . 'Response', |
|
| 1904 | - 'parts' => $out), |
|
| 1905 | - 'namespace' => $namespace, |
|
| 1906 | - 'transport' => 'http://schemas.xmlsoap.org/soap/http', |
|
| 1907 | - 'documentation' => $documentation); |
|
| 1908 | - // add portTypes |
|
| 1909 | - // add messages |
|
| 1910 | - if($in) |
|
| 1911 | - {
|
|
| 1912 | - foreach($in as $pName => $pType) |
|
| 1913 | - {
|
|
| 1914 | - if(strpos($pType,':')) {
|
|
| 1915 | - $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType); |
|
| 1916 | - } |
|
| 1917 | - $this->messages[$name.'Request'][$pName] = $pType; |
|
| 1918 | - } |
|
| 1919 | - } else {
|
|
| 1885 | + // get binding |
|
| 1886 | + $this->bindings[ $this->serviceName . 'Binding' ]['operations'][$name] = |
|
| 1887 | + array( |
|
| 1888 | + 'name' => $name, |
|
| 1889 | + 'binding' => $this->serviceName . 'Binding', |
|
| 1890 | + 'endpoint' => $this->endpoint, |
|
| 1891 | + 'soapAction' => $soapaction, |
|
| 1892 | + 'style' => $style, |
|
| 1893 | + 'input' => array( |
|
| 1894 | + 'use' => $use, |
|
| 1895 | + 'namespace' => $namespace, |
|
| 1896 | + 'encodingStyle' => $encodingStyle, |
|
| 1897 | + 'message' => $name . 'Request', |
|
| 1898 | + 'parts' => $in), |
|
| 1899 | + 'output' => array( |
|
| 1900 | + 'use' => $use, |
|
| 1901 | + 'namespace' => $namespace, |
|
| 1902 | + 'encodingStyle' => $encodingStyle, |
|
| 1903 | + 'message' => $name . 'Response', |
|
| 1904 | + 'parts' => $out), |
|
| 1905 | + 'namespace' => $namespace, |
|
| 1906 | + 'transport' => 'http://schemas.xmlsoap.org/soap/http', |
|
| 1907 | + 'documentation' => $documentation); |
|
| 1908 | + // add portTypes |
|
| 1909 | + // add messages |
|
| 1910 | + if($in) |
|
| 1911 | + {
|
|
| 1912 | + foreach($in as $pName => $pType) |
|
| 1913 | + {
|
|
| 1914 | + if(strpos($pType,':')) {
|
|
| 1915 | + $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType); |
|
| 1916 | + } |
|
| 1917 | + $this->messages[$name.'Request'][$pName] = $pType; |
|
| 1918 | + } |
|
| 1919 | + } else {
|
|
| 1920 | 1920 | $this->messages[$name.'Request']= '0'; |
| 1921 | 1921 | } |
| 1922 | - if($out) |
|
| 1923 | - {
|
|
| 1924 | - foreach($out as $pName => $pType) |
|
| 1925 | - {
|
|
| 1926 | - if(strpos($pType,':')) {
|
|
| 1927 | - $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType); |
|
| 1928 | - } |
|
| 1929 | - $this->messages[$name.'Response'][$pName] = $pType; |
|
| 1930 | - } |
|
| 1931 | - } else {
|
|
| 1922 | + if($out) |
|
| 1923 | + {
|
|
| 1924 | + foreach($out as $pName => $pType) |
|
| 1925 | + {
|
|
| 1926 | + if(strpos($pType,':')) {
|
|
| 1927 | + $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType); |
|
| 1928 | + } |
|
| 1929 | + $this->messages[$name.'Response'][$pName] = $pType; |
|
| 1930 | + } |
|
| 1931 | + } else {
|
|
| 1932 | 1932 | $this->messages[$name.'Response']= '0'; |
| 1933 | 1933 | } |
| 1934 | - return true; |
|
| 1935 | - } |
|
| 1934 | + return true; |
|
| 1935 | + } |
|
| 1936 | 1936 | } |
| 1937 | 1937 | |
| 1938 | 1938 | ?> |
@@ -47,13 +47,13 @@ discard block |
||
| 47 | 47 | var $proxypassword = ''; |
| 48 | 48 | var $timeout = 0; |
| 49 | 49 | var $response_timeout = 30; |
| 50 | - var $curl_options = array(); // User-specified cURL options |
|
| 51 | - var $use_curl = false; // whether to always try to use cURL |
|
| 50 | + var $curl_options = array(); // User-specified cURL options |
|
| 51 | + var $use_curl = false; // whether to always try to use cURL |
|
| 52 | 52 | // for HTTP authentication |
| 53 | - var $username = ''; // Username for HTTP authentication |
|
| 54 | - var $password = ''; // Password for HTTP authentication |
|
| 55 | - var $authtype = ''; // Type of HTTP authentication |
|
| 56 | - var $certRequest = array(); // Certificate for HTTP SSL authentication |
|
| 53 | + var $username = ''; // Username for HTTP authentication |
|
| 54 | + var $password = ''; // Password for HTTP authentication |
|
| 55 | + var $authtype = ''; // Type of HTTP authentication |
|
| 56 | + var $certRequest = array(); // Certificate for HTTP SSL authentication |
|
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * constructor |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @param boolean $use_curl try to use cURL |
| 70 | 70 | * @access public |
| 71 | 71 | */ |
| 72 | - function wsdl($wsdl = '',$proxyhost=false,$proxyport=false,$proxyusername=false,$proxypassword=false,$timeout=0,$response_timeout=30,$curl_options=null,$use_curl=false){
|
|
| 72 | + function wsdl($wsdl = '', $proxyhost = false, $proxyport = false, $proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $curl_options = null, $use_curl = false) {
|
|
| 73 | 73 | parent::nusoap_base(); |
| 74 | 74 | $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
|
| 75 | 75 | $this->proxyhost = $proxyhost; |
@@ -105,19 +105,19 @@ discard block |
||
| 105 | 105 | // Schema imports |
| 106 | 106 | foreach ($this->schemas as $ns => $list) {
|
| 107 | 107 | foreach ($list as $xs) {
|
| 108 | - $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! |
|
| 108 | + $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! |
|
| 109 | 109 | foreach ($xs->imports as $ns2 => $list2) {
|
| 110 | 110 | for ($ii = 0; $ii < count($list2); $ii++) {
|
| 111 | - if (! $list2[$ii]['loaded']) {
|
|
| 111 | + if (!$list2[$ii]['loaded']) {
|
|
| 112 | 112 | $this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true; |
| 113 | 113 | $url = $list2[$ii]['location']; |
| 114 | 114 | if ($url != '') {
|
| 115 | 115 | $urlparts = parse_url($url); |
| 116 | 116 | if (!isset($urlparts['host'])) {
|
| 117 | - $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' .$wsdlparts['port'] : '') . |
|
| 118 | - substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path']; |
|
| 117 | + $url = $wsdlparts['scheme'].'://'.$wsdlparts['host'].(isset($wsdlparts['port']) ? ':'.$wsdlparts['port'] : ''). |
|
| 118 | + substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1).$urlparts['path']; |
|
| 119 | 119 | } |
| 120 | - if (! in_array($url, $imported_urls)) {
|
|
| 120 | + if (!in_array($url, $imported_urls)) {
|
|
| 121 | 121 | $this->parseWSDL($url); |
| 122 | 122 | $imported++; |
| 123 | 123 | $imported_urls[] = $url; |
@@ -131,19 +131,19 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | // WSDL imports |
| 134 | - $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! |
|
| 134 | + $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! |
|
| 135 | 135 | foreach ($this->import as $ns => $list) {
|
| 136 | 136 | for ($ii = 0; $ii < count($list); $ii++) {
|
| 137 | - if (! $list[$ii]['loaded']) {
|
|
| 137 | + if (!$list[$ii]['loaded']) {
|
|
| 138 | 138 | $this->import[$ns][$ii]['loaded'] = true; |
| 139 | 139 | $url = $list[$ii]['location']; |
| 140 | 140 | if ($url != '') {
|
| 141 | 141 | $urlparts = parse_url($url); |
| 142 | 142 | if (!isset($urlparts['host'])) {
|
| 143 | - $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') . |
|
| 144 | - substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path']; |
|
| 143 | + $url = $wsdlparts['scheme'].'://'.$wsdlparts['host'].(isset($wsdlparts['port']) ? ':'.$wsdlparts['port'] : ''). |
|
| 144 | + substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1).$urlparts['path']; |
|
| 145 | 145 | } |
| 146 | - if (! in_array($url, $imported_urls)) {
|
|
| 146 | + if (!in_array($url, $imported_urls)) {
|
|
| 147 | 147 | $this->parseWSDL($url); |
| 148 | 148 | $imported++; |
| 149 | 149 | $imported_urls[] = $url; |
@@ -156,30 +156,28 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | // add new data to operation data |
| 159 | - foreach($this->bindings as $binding => $bindingData) {
|
|
| 159 | + foreach ($this->bindings as $binding => $bindingData) {
|
|
| 160 | 160 | if (isset($bindingData['operations']) && is_array($bindingData['operations'])) {
|
| 161 | - foreach($bindingData['operations'] as $operation => $data) {
|
|
| 162 | - $this->debug('post-parse data gathering for ' . $operation);
|
|
| 161 | + foreach ($bindingData['operations'] as $operation => $data) {
|
|
| 162 | + $this->debug('post-parse data gathering for '.$operation);
|
|
| 163 | 163 | $this->bindings[$binding]['operations'][$operation]['input'] = |
| 164 | 164 | isset($this->bindings[$binding]['operations'][$operation]['input']) ? |
| 165 | - array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) : |
|
| 166 | - $this->portTypes[ $bindingData['portType'] ][$operation]['input']; |
|
| 165 | + array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[$bindingData['portType']][$operation]['input']) : $this->portTypes[$bindingData['portType']][$operation]['input']; |
|
| 167 | 166 | $this->bindings[$binding]['operations'][$operation]['output'] = |
| 168 | 167 | isset($this->bindings[$binding]['operations'][$operation]['output']) ? |
| 169 | - array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) : |
|
| 170 | - $this->portTypes[ $bindingData['portType'] ][$operation]['output']; |
|
| 171 | - if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ])){
|
|
| 172 | - $this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ]; |
|
| 168 | + array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[$bindingData['portType']][$operation]['output']) : $this->portTypes[$bindingData['portType']][$operation]['output']; |
|
| 169 | + if (isset($this->messages[$this->bindings[$binding]['operations'][$operation]['input']['message']])) {
|
|
| 170 | + $this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[$this->bindings[$binding]['operations'][$operation]['input']['message']]; |
|
| 173 | 171 | } |
| 174 | - if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ])){
|
|
| 175 | - $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ]; |
|
| 172 | + if (isset($this->messages[$this->bindings[$binding]['operations'][$operation]['output']['message']])) {
|
|
| 173 | + $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[$this->bindings[$binding]['operations'][$operation]['output']['message']]; |
|
| 176 | 174 | } |
| 177 | 175 | // Set operation style if necessary, but do not override one already provided |
| 178 | 176 | if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['style'])) {
|
| 179 | 177 | $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style']; |
| 180 | 178 | } |
| 181 | 179 | $this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : ''; |
| 182 | - $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[ $bindingData['portType'] ][$operation]['documentation']) ? $this->portTypes[ $bindingData['portType'] ][$operation]['documentation'] : ''; |
|
| 180 | + $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[$bindingData['portType']][$operation]['documentation']) ? $this->portTypes[$bindingData['portType']][$operation]['documentation'] : ''; |
|
| 183 | 181 | $this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) ? $bindingData['endpoint'] : ''; |
| 184 | 182 | } |
| 185 | 183 | } |
@@ -205,13 +203,13 @@ discard block |
||
| 205 | 203 | $wsdl_props = parse_url($wsdl); |
| 206 | 204 | |
| 207 | 205 | if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'http' || $wsdl_props['scheme'] == 'https')) {
|
| 208 | - $this->debug('getting WSDL http(s) URL ' . $wsdl);
|
|
| 206 | + $this->debug('getting WSDL http(s) URL '.$wsdl);
|
|
| 209 | 207 | // get wsdl |
| 210 | 208 | $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl); |
| 211 | 209 | $tr->request_method = 'GET'; |
| 212 | 210 | $tr->useSOAPAction = false; |
| 213 | - if($this->proxyhost && $this->proxyport){
|
|
| 214 | - $tr->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword); |
|
| 211 | + if ($this->proxyhost && $this->proxyport) {
|
|
| 212 | + $tr->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword); |
|
| 215 | 213 | } |
| 216 | 214 | if ($this->authtype != '') {
|
| 217 | 215 | $tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest); |
@@ -222,8 +220,8 @@ discard block |
||
| 222 | 220 | //$this->debug("WSDL response\n" . $tr->incoming_payload);
|
| 223 | 221 | $this->appendDebug($tr->getDebug()); |
| 224 | 222 | // catch errors |
| 225 | - if($err = $tr->getError() ){
|
|
| 226 | - $errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: '.$err; |
|
| 223 | + if ($err = $tr->getError()) {
|
|
| 224 | + $errstr = 'Getting '.$wsdl.' - HTTP ERROR: '.$err; |
|
| 227 | 225 | $this->debug($errstr); |
| 228 | 226 | $this->setError($errstr); |
| 229 | 227 | unset($tr); |
@@ -234,11 +232,11 @@ discard block |
||
| 234 | 232 | } else {
|
| 235 | 233 | // $wsdl is not http(s), so treat it as a file URL or plain file path |
| 236 | 234 | if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) {
|
| 237 | - $path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path']; |
|
| 235 | + $path = isset($wsdl_props['host']) ? ($wsdl_props['host'].':'.$wsdl_props['path']) : $wsdl_props['path']; |
|
| 238 | 236 | } else {
|
| 239 | 237 | $path = $wsdl; |
| 240 | 238 | } |
| 241 | - $this->debug('getting WSDL file ' . $path);
|
|
| 239 | + $this->debug('getting WSDL file '.$path);
|
|
| 242 | 240 | if ($fp = @fopen($path, 'r')) {
|
| 243 | 241 | $wsdl_string = ''; |
| 244 | 242 | while ($data = fread($fp, 32768)) {
|
@@ -274,7 +272,7 @@ discard block |
||
| 274 | 272 | xml_error_string(xml_get_error_code($this->parser)) |
| 275 | 273 | ); |
| 276 | 274 | $this->debug($errstr); |
| 277 | - $this->debug("XML payload:\n" . $wsdl_string);
|
|
| 275 | + $this->debug("XML payload:\n".$wsdl_string);
|
|
| 278 | 276 | $this->setError($errstr); |
| 279 | 277 | return false; |
| 280 | 278 | } |
@@ -282,7 +280,7 @@ discard block |
||
| 282 | 280 | xml_parser_free($this->parser); |
| 283 | 281 | $this->debug('Parsing WSDL done');
|
| 284 | 282 | // catch wsdl parse errors |
| 285 | - if($this->getError()){
|
|
| 283 | + if ($this->getError()) {
|
|
| 286 | 284 | return false; |
| 287 | 285 | } |
| 288 | 286 | return true; |
@@ -320,21 +318,21 @@ discard block |
||
| 320 | 318 | // process attributes |
| 321 | 319 | if (count($attrs) > 0) {
|
| 322 | 320 | // register namespace declarations |
| 323 | - foreach($attrs as $k => $v) {
|
|
| 324 | - if (preg_match('/^xmlns/',$k)) {
|
|
| 321 | + foreach ($attrs as $k => $v) {
|
|
| 322 | + if (preg_match('/^xmlns/', $k)) {
|
|
| 325 | 323 | if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
|
| 326 | 324 | $this->namespaces[$ns_prefix] = $v; |
| 327 | 325 | } else {
|
| 328 | - $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v; |
|
| 326 | + $this->namespaces['ns'.(count($this->namespaces) + 1)] = $v; |
|
| 329 | 327 | } |
| 330 | 328 | if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
|
| 331 | 329 | $this->XMLSchemaVersion = $v; |
| 332 | - $this->namespaces['xsi'] = $v . '-instance'; |
|
| 330 | + $this->namespaces['xsi'] = $v.'-instance'; |
|
| 333 | 331 | } |
| 334 | 332 | } |
| 335 | 333 | } |
| 336 | 334 | // expand each attribute prefix to its namespace |
| 337 | - foreach($attrs as $k => $v) {
|
|
| 335 | + foreach ($attrs as $k => $v) {
|
|
| 338 | 336 | $k = strpos($k, ':') ? $this->expandQname($k) : $k; |
| 339 | 337 | if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') {
|
| 340 | 338 | $v = strpos($v, ':') ? $this->expandQname($v) : $v; |
@@ -360,12 +358,12 @@ discard block |
||
| 360 | 358 | case 'message': |
| 361 | 359 | if ($name == 'part') {
|
| 362 | 360 | if (isset($attrs['type'])) {
|
| 363 | - $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs));
|
|
| 361 | + $this->debug("msg ".$this->currentMessage.": found part (with type) $attrs[name]: ".implode(',', $attrs));
|
|
| 364 | 362 | $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type']; |
| 365 | 363 | } |
| 366 | 364 | if (isset($attrs['element'])) {
|
| 367 | - $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs));
|
|
| 368 | - $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^'; |
|
| 365 | + $this->debug("msg ".$this->currentMessage.": found part (with element) $attrs[name]: ".implode(',', $attrs));
|
|
| 366 | + $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'].'^'; |
|
| 369 | 367 | } |
| 370 | 368 | } |
| 371 | 369 | break; |
@@ -434,15 +432,15 @@ discard block |
||
| 434 | 432 | switch ($name) {
|
| 435 | 433 | case 'port': |
| 436 | 434 | $this->currentPort = $attrs['name']; |
| 437 | - $this->debug('current port: ' . $this->currentPort);
|
|
| 435 | + $this->debug('current port: '.$this->currentPort);
|
|
| 438 | 436 | $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']); |
| 439 | 437 | |
| 440 | 438 | break; |
| 441 | 439 | case 'address': |
| 442 | 440 | $this->ports[$this->currentPort]['location'] = $attrs['location']; |
| 443 | 441 | $this->ports[$this->currentPort]['bindingType'] = $namespace; |
| 444 | - $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace; |
|
| 445 | - $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location']; |
|
| 442 | + $this->bindings[$this->ports[$this->currentPort]['binding']]['bindingType'] = $namespace; |
|
| 443 | + $this->bindings[$this->ports[$this->currentPort]['binding']]['endpoint'] = $attrs['location']; |
|
| 446 | 444 | break; |
| 447 | 445 | } |
| 448 | 446 | break; |
@@ -452,13 +450,13 @@ discard block |
||
| 452 | 450 | case 'import': |
| 453 | 451 | if (isset($attrs['location'])) {
|
| 454 | 452 | $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false);
|
| 455 | - $this->debug('parsing import ' . $attrs['namespace']. ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]).')');
|
|
| 453 | + $this->debug('parsing import '.$attrs['namespace'].' - '.$attrs['location'].' ('.count($this->import[$attrs['namespace']]).')');
|
|
| 456 | 454 | } else {
|
| 457 | 455 | $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
|
| 458 | - if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
|
|
| 459 | - $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace']; |
|
| 456 | + if (!$this->getPrefixFromNamespace($attrs['namespace'])) {
|
|
| 457 | + $this->namespaces['ns'.(count($this->namespaces) + 1)] = $attrs['namespace']; |
|
| 460 | 458 | } |
| 461 | - $this->debug('parsing import ' . $attrs['namespace']. ' - [no location] (' . count($this->import[$attrs['namespace']]).')');
|
|
| 459 | + $this->debug('parsing import '.$attrs['namespace'].' - [no location] ('.count($this->import[$attrs['namespace']]).')');
|
|
| 462 | 460 | } |
| 463 | 461 | break; |
| 464 | 462 | //wait for schema |
@@ -485,13 +483,13 @@ discard block |
||
| 485 | 483 | } |
| 486 | 484 | $this->status = 'binding'; |
| 487 | 485 | $this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']); |
| 488 | - $this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
|
|
| 486 | + $this->debug("current binding: $this->currentBinding of portType: ".$attrs['type']);
|
|
| 489 | 487 | } |
| 490 | 488 | break; |
| 491 | 489 | case 'service': |
| 492 | 490 | $this->serviceName = $attrs['name']; |
| 493 | 491 | $this->status = 'service'; |
| 494 | - $this->debug('current service: ' . $this->serviceName);
|
|
| 492 | + $this->debug('current service: '.$this->serviceName);
|
|
| 495 | 493 | break; |
| 496 | 494 | case 'definitions': |
| 497 | 495 | foreach ($attrs as $name => $value) {
|
@@ -509,7 +507,7 @@ discard block |
||
| 509 | 507 | * @param string $name element name |
| 510 | 508 | * @access private |
| 511 | 509 | */ |
| 512 | - function end_element($parser, $name){
|
|
| 510 | + function end_element($parser, $name) {
|
|
| 513 | 511 | // unset schema status |
| 514 | 512 | if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) {
|
| 515 | 513 | $this->status = ""; |
@@ -594,8 +592,8 @@ discard block |
||
| 594 | 592 | } |
| 595 | 593 | $this->debug("getOperations for port '$portName' bindingType $bindingType");
|
| 596 | 594 | // loop thru ports |
| 597 | - foreach($this->ports as $port => $portData) {
|
|
| 598 | - $this->debug("getOperations checking port $port bindingType " . $portData['bindingType']);
|
|
| 595 | + foreach ($this->ports as $port => $portData) {
|
|
| 596 | + $this->debug("getOperations checking port $port bindingType ".$portData['bindingType']);
|
|
| 599 | 597 | if ($portName == '' || $port == $portName) {
|
| 600 | 598 | // binding type of port matches parameter |
| 601 | 599 | if ($portData['bindingType'] == $bindingType) {
|
@@ -603,8 +601,8 @@ discard block |
||
| 603 | 601 | //$this->debug("port data: " . $this->varDump($portData));
|
| 604 | 602 | //$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ]));
|
| 605 | 603 | // merge bindings |
| 606 | - if (isset($this->bindings[ $portData['binding'] ]['operations'])) {
|
|
| 607 | - $ops = array_merge ($ops, $this->bindings[ $portData['binding'] ]['operations']); |
|
| 604 | + if (isset($this->bindings[$portData['binding']]['operations'])) {
|
|
| 605 | + $ops = array_merge($ops, $this->bindings[$portData['binding']]['operations']); |
|
| 608 | 606 | } |
| 609 | 607 | } |
| 610 | 608 | } |
@@ -631,15 +629,15 @@ discard block |
||
| 631 | 629 | $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; |
| 632 | 630 | } |
| 633 | 631 | // loop thru ports |
| 634 | - foreach($this->ports as $port => $portData) {
|
|
| 632 | + foreach ($this->ports as $port => $portData) {
|
|
| 635 | 633 | // binding type of port matches parameter |
| 636 | 634 | if ($portData['bindingType'] == $bindingType) {
|
| 637 | 635 | // get binding |
| 638 | 636 | //foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
|
| 639 | - foreach(array_keys($this->bindings[ $portData['binding'] ]['operations']) as $bOperation) {
|
|
| 637 | + foreach (array_keys($this->bindings[$portData['binding']]['operations']) as $bOperation) {
|
|
| 640 | 638 | // note that we could/should also check the namespace here |
| 641 | 639 | if ($operation == $bOperation) {
|
| 642 | - $opData = $this->bindings[ $portData['binding'] ]['operations'][$operation]; |
|
| 640 | + $opData = $this->bindings[$portData['binding']]['operations'][$operation]; |
|
| 643 | 641 | return $opData; |
| 644 | 642 | } |
| 645 | 643 | } |
@@ -662,11 +660,11 @@ discard block |
||
| 662 | 660 | $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; |
| 663 | 661 | } |
| 664 | 662 | // loop thru ports |
| 665 | - foreach($this->ports as $port => $portData) {
|
|
| 663 | + foreach ($this->ports as $port => $portData) {
|
|
| 666 | 664 | // binding type of port matches parameter |
| 667 | 665 | if ($portData['bindingType'] == $bindingType) {
|
| 668 | 666 | // loop through operations for the binding |
| 669 | - foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
|
|
| 667 | + foreach ($this->bindings[$portData['binding']]['operations'] as $bOperation => $opData) {
|
|
| 670 | 668 | if ($opData['soapAction'] == $soapAction) {
|
| 671 | 669 | return $opData; |
| 672 | 670 | } |
@@ -695,7 +693,7 @@ discard block |
||
| 695 | 693 | */ |
| 696 | 694 | function getTypeDef($type, $ns) {
|
| 697 | 695 | $this->debug("in getTypeDef: type=$type, ns=$ns");
|
| 698 | - if ((! $ns) && isset($this->namespaces['tns'])) {
|
|
| 696 | + if ((!$ns) && isset($this->namespaces['tns'])) {
|
|
| 699 | 697 | $ns = $this->namespaces['tns']; |
| 700 | 698 | $this->debug("in getTypeDef: type namespace forced to $ns");
|
| 701 | 699 | } |
@@ -753,7 +751,7 @@ discard block |
||
| 753 | 751 | * |
| 754 | 752 | * @access private |
| 755 | 753 | */ |
| 756 | - function webDescription(){
|
|
| 754 | + function webDescription() {
|
|
| 757 | 755 | global $HTTP_SERVER_VARS; |
| 758 | 756 | |
| 759 | 757 | if (isset($_SERVER)) {
|
@@ -847,19 +845,19 @@ discard block |
||
| 847 | 845 | <p>View the <a href="'.$PHP_SELF.'?wsdl">WSDL</a> for the service. |
| 848 | 846 | Click on an operation name to view it's details.</p> |
| 849 | 847 | <ul>'; |
| 850 | - foreach($this->getOperations() as $op => $data){
|
|
| 848 | + foreach ($this->getOperations() as $op => $data) {
|
|
| 851 | 849 | $b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>";
|
| 852 | 850 | // create hidden div |
| 853 | 851 | $b .= "<div id='$op' class='hidden'> |
| 854 | 852 | <a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>"; |
| 855 | - foreach($data as $donnie => $marie){ // loop through opdata
|
|
| 856 | - if($donnie == 'input' || $donnie == 'output'){ // show input/output data
|
|
| 853 | + foreach ($data as $donnie => $marie) { // loop through opdata
|
|
| 854 | + if ($donnie == 'input' || $donnie == 'output') { // show input/output data
|
|
| 857 | 855 | $b .= "<font color='white'>".ucfirst($donnie).':</font><br>'; |
| 858 | - foreach($marie as $captain => $tenille){ // loop through data
|
|
| 859 | - if($captain == 'parts'){ // loop thru parts
|
|
| 856 | + foreach ($marie as $captain => $tenille) { // loop through data
|
|
| 857 | + if ($captain == 'parts') { // loop thru parts
|
|
| 860 | 858 | $b .= " $captain:<br>"; |
| 861 | 859 | //if(is_array($tenille)){
|
| 862 | - foreach($tenille as $joanie => $chachi){
|
|
| 860 | + foreach ($tenille as $joanie => $chachi) {
|
|
| 863 | 861 | $b .= " $joanie: $chachi<br>"; |
| 864 | 862 | } |
| 865 | 863 | //} |
@@ -891,31 +889,31 @@ discard block |
||
| 891 | 889 | {
|
| 892 | 890 | $xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'; |
| 893 | 891 | $xml .= "\n<definitions"; |
| 894 | - foreach($this->namespaces as $k => $v) {
|
|
| 892 | + foreach ($this->namespaces as $k => $v) {
|
|
| 895 | 893 | $xml .= " xmlns:$k=\"$v\""; |
| 896 | 894 | } |
| 897 | 895 | // 10.9.02 - add poulter fix for wsdl and tns declarations |
| 898 | 896 | if (isset($this->namespaces['wsdl'])) {
|
| 899 | - $xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\""; |
|
| 897 | + $xml .= " xmlns=\"".$this->namespaces['wsdl']."\""; |
|
| 900 | 898 | } |
| 901 | 899 | if (isset($this->namespaces['tns'])) {
|
| 902 | - $xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\""; |
|
| 900 | + $xml .= " targetNamespace=\"".$this->namespaces['tns']."\""; |
|
| 903 | 901 | } |
| 904 | 902 | $xml .= '>'; |
| 905 | 903 | // imports |
| 906 | 904 | if (sizeof($this->import) > 0) {
|
| 907 | - foreach($this->import as $ns => $list) {
|
|
| 905 | + foreach ($this->import as $ns => $list) {
|
|
| 908 | 906 | foreach ($list as $ii) {
|
| 909 | 907 | if ($ii['location'] != '') {
|
| 910 | - $xml .= '<import location="' . $ii['location'] . '" namespace="' . $ns . '" />'; |
|
| 908 | + $xml .= '<import location="'.$ii['location'].'" namespace="'.$ns.'" />'; |
|
| 911 | 909 | } else {
|
| 912 | - $xml .= '<import namespace="' . $ns . '" />'; |
|
| 910 | + $xml .= '<import namespace="'.$ns.'" />'; |
|
| 913 | 911 | } |
| 914 | 912 | } |
| 915 | 913 | } |
| 916 | 914 | } |
| 917 | 915 | // types |
| 918 | - if (count($this->schemas)>=1) {
|
|
| 916 | + if (count($this->schemas) >= 1) {
|
|
| 919 | 917 | $xml .= "\n<types>\n"; |
| 920 | 918 | foreach ($this->schemas as $ns => $list) {
|
| 921 | 919 | foreach ($list as $xs) {
|
@@ -926,10 +924,10 @@ discard block |
||
| 926 | 924 | } |
| 927 | 925 | // messages |
| 928 | 926 | if (count($this->messages) >= 1) {
|
| 929 | - foreach($this->messages as $msgName => $msgParts) {
|
|
| 930 | - $xml .= "\n<message name=\"" . $msgName . '">'; |
|
| 931 | - if(is_array($msgParts)){
|
|
| 932 | - foreach($msgParts as $partName => $partType) {
|
|
| 927 | + foreach ($this->messages as $msgName => $msgParts) {
|
|
| 928 | + $xml .= "\n<message name=\"".$msgName.'">'; |
|
| 929 | + if (is_array($msgParts)) {
|
|
| 930 | + foreach ($msgParts as $partName => $partType) {
|
|
| 933 | 931 | // print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>'; |
| 934 | 932 | if (strpos($partType, ':')) {
|
| 935 | 933 | $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType)); |
@@ -937,7 +935,7 @@ discard block |
||
| 937 | 935 | // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>'; |
| 938 | 936 | $typePrefix = 'xsd'; |
| 939 | 937 | } else {
|
| 940 | - foreach($this->typemap as $ns => $types) {
|
|
| 938 | + foreach ($this->typemap as $ns => $types) {
|
|
| 941 | 939 | if (isset($types[$partType])) {
|
| 942 | 940 | $typePrefix = $this->getPrefixFromNamespace($ns); |
| 943 | 941 | } |
@@ -957,7 +955,7 @@ discard block |
||
| 957 | 955 | } else {
|
| 958 | 956 | $elementortype = 'type'; |
| 959 | 957 | } |
| 960 | - $xml .= "\n" . ' <part name="' . $partName . '" ' . $elementortype . '="' . $typePrefix . ':' . $localPart . '" />'; |
|
| 958 | + $xml .= "\n".' <part name="'.$partName.'" '.$elementortype.'="'.$typePrefix.':'.$localPart.'" />'; |
|
| 961 | 959 | } |
| 962 | 960 | } |
| 963 | 961 | $xml .= '</message>'; |
@@ -967,54 +965,54 @@ discard block |
||
| 967 | 965 | if (count($this->bindings) >= 1) {
|
| 968 | 966 | $binding_xml = ''; |
| 969 | 967 | $portType_xml = ''; |
| 970 | - foreach($this->bindings as $bindingName => $attrs) {
|
|
| 971 | - $binding_xml .= "\n<binding name=\"" . $bindingName . '" type="tns:' . $attrs['portType'] . '">'; |
|
| 972 | - $binding_xml .= "\n" . ' <soap:binding style="' . $attrs['style'] . '" transport="' . $attrs['transport'] . '"/>'; |
|
| 973 | - $portType_xml .= "\n<portType name=\"" . $attrs['portType'] . '">'; |
|
| 974 | - foreach($attrs['operations'] as $opName => $opParts) {
|
|
| 975 | - $binding_xml .= "\n" . ' <operation name="' . $opName . '">'; |
|
| 976 | - $binding_xml .= "\n" . ' <soap:operation soapAction="' . $opParts['soapAction'] . '" style="'. $opParts['style'] . '"/>'; |
|
| 968 | + foreach ($this->bindings as $bindingName => $attrs) {
|
|
| 969 | + $binding_xml .= "\n<binding name=\"".$bindingName.'" type="tns:'.$attrs['portType'].'">'; |
|
| 970 | + $binding_xml .= "\n".' <soap:binding style="'.$attrs['style'].'" transport="'.$attrs['transport'].'"/>'; |
|
| 971 | + $portType_xml .= "\n<portType name=\"".$attrs['portType'].'">'; |
|
| 972 | + foreach ($attrs['operations'] as $opName => $opParts) {
|
|
| 973 | + $binding_xml .= "\n".' <operation name="'.$opName.'">'; |
|
| 974 | + $binding_xml .= "\n".' <soap:operation soapAction="'.$opParts['soapAction'].'" style="'.$opParts['style'].'"/>'; |
|
| 977 | 975 | if (isset($opParts['input']['encodingStyle']) && $opParts['input']['encodingStyle'] != '') {
|
| 978 | - $enc_style = ' encodingStyle="' . $opParts['input']['encodingStyle'] . '"'; |
|
| 976 | + $enc_style = ' encodingStyle="'.$opParts['input']['encodingStyle'].'"'; |
|
| 979 | 977 | } else {
|
| 980 | 978 | $enc_style = ''; |
| 981 | 979 | } |
| 982 | - $binding_xml .= "\n" . ' <input><soap:body use="' . $opParts['input']['use'] . '" namespace="' . $opParts['input']['namespace'] . '"' . $enc_style . '/></input>'; |
|
| 980 | + $binding_xml .= "\n".' <input><soap:body use="'.$opParts['input']['use'].'" namespace="'.$opParts['input']['namespace'].'"'.$enc_style.'/></input>'; |
|
| 983 | 981 | if (isset($opParts['output']['encodingStyle']) && $opParts['output']['encodingStyle'] != '') {
|
| 984 | - $enc_style = ' encodingStyle="' . $opParts['output']['encodingStyle'] . '"'; |
|
| 982 | + $enc_style = ' encodingStyle="'.$opParts['output']['encodingStyle'].'"'; |
|
| 985 | 983 | } else {
|
| 986 | 984 | $enc_style = ''; |
| 987 | 985 | } |
| 988 | - $binding_xml .= "\n" . ' <output><soap:body use="' . $opParts['output']['use'] . '" namespace="' . $opParts['output']['namespace'] . '"' . $enc_style . '/></output>'; |
|
| 989 | - $binding_xml .= "\n" . ' </operation>'; |
|
| 990 | - $portType_xml .= "\n" . ' <operation name="' . $opParts['name'] . '"'; |
|
| 986 | + $binding_xml .= "\n".' <output><soap:body use="'.$opParts['output']['use'].'" namespace="'.$opParts['output']['namespace'].'"'.$enc_style.'/></output>'; |
|
| 987 | + $binding_xml .= "\n".' </operation>'; |
|
| 988 | + $portType_xml .= "\n".' <operation name="'.$opParts['name'].'"'; |
|
| 991 | 989 | if (isset($opParts['parameterOrder'])) {
|
| 992 | - $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"'; |
|
| 990 | + $portType_xml .= ' parameterOrder="'.$opParts['parameterOrder'].'"'; |
|
| 993 | 991 | } |
| 994 | 992 | $portType_xml .= '>'; |
| 995 | - if(isset($opParts['documentation']) && $opParts['documentation'] != '') {
|
|
| 996 | - $portType_xml .= "\n" . ' <documentation>' . htmlspecialchars($opParts['documentation']) . '</documentation>'; |
|
| 993 | + if (isset($opParts['documentation']) && $opParts['documentation'] != '') {
|
|
| 994 | + $portType_xml .= "\n".' <documentation>'.htmlspecialchars($opParts['documentation']).'</documentation>'; |
|
| 997 | 995 | } |
| 998 | - $portType_xml .= "\n" . ' <input message="tns:' . $opParts['input']['message'] . '"/>'; |
|
| 999 | - $portType_xml .= "\n" . ' <output message="tns:' . $opParts['output']['message'] . '"/>'; |
|
| 1000 | - $portType_xml .= "\n" . ' </operation>'; |
|
| 996 | + $portType_xml .= "\n".' <input message="tns:'.$opParts['input']['message'].'"/>'; |
|
| 997 | + $portType_xml .= "\n".' <output message="tns:'.$opParts['output']['message'].'"/>'; |
|
| 998 | + $portType_xml .= "\n".' </operation>'; |
|
| 1001 | 999 | } |
| 1002 | - $portType_xml .= "\n" . '</portType>'; |
|
| 1003 | - $binding_xml .= "\n" . '</binding>'; |
|
| 1000 | + $portType_xml .= "\n".'</portType>'; |
|
| 1001 | + $binding_xml .= "\n".'</binding>'; |
|
| 1004 | 1002 | } |
| 1005 | - $xml .= $portType_xml . $binding_xml; |
|
| 1003 | + $xml .= $portType_xml.$binding_xml; |
|
| 1006 | 1004 | } |
| 1007 | 1005 | // services |
| 1008 | - $xml .= "\n<service name=\"" . $this->serviceName . '">'; |
|
| 1006 | + $xml .= "\n<service name=\"".$this->serviceName.'">'; |
|
| 1009 | 1007 | if (count($this->ports) >= 1) {
|
| 1010 | - foreach($this->ports as $pName => $attrs) {
|
|
| 1011 | - $xml .= "\n" . ' <port name="' . $pName . '" binding="tns:' . $attrs['binding'] . '">'; |
|
| 1012 | - $xml .= "\n" . ' <soap:address location="' . $attrs['location'] . ($debug ? '?debug=1' : '') . '"/>'; |
|
| 1013 | - $xml .= "\n" . ' </port>'; |
|
| 1008 | + foreach ($this->ports as $pName => $attrs) {
|
|
| 1009 | + $xml .= "\n".' <port name="'.$pName.'" binding="tns:'.$attrs['binding'].'">'; |
|
| 1010 | + $xml .= "\n".' <soap:address location="'.$attrs['location'].($debug ? '?debug=1' : '').'"/>'; |
|
| 1011 | + $xml .= "\n".' </port>'; |
|
| 1014 | 1012 | } |
| 1015 | 1013 | } |
| 1016 | - $xml .= "\n" . '</service>'; |
|
| 1017 | - return $xml . "\n</definitions>"; |
|
| 1014 | + $xml .= "\n".'</service>'; |
|
| 1015 | + return $xml."\n</definitions>"; |
|
| 1018 | 1016 | } |
| 1019 | 1017 | |
| 1020 | 1018 | /** |
@@ -1111,7 +1109,7 @@ discard block |
||
| 1111 | 1109 | */ |
| 1112 | 1110 | function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') {
|
| 1113 | 1111 | $this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType");
|
| 1114 | - $this->appendDebug('parameters=' . $this->varDump($parameters));
|
|
| 1112 | + $this->appendDebug('parameters='.$this->varDump($parameters));
|
|
| 1115 | 1113 | |
| 1116 | 1114 | if ($direction != 'input' && $direction != 'output') {
|
| 1117 | 1115 | $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
|
@@ -1119,8 +1117,8 @@ discard block |
||
| 1119 | 1117 | return false; |
| 1120 | 1118 | } |
| 1121 | 1119 | if (!$opData = $this->getOperationData($operation, $bindingType)) {
|
| 1122 | - $this->debug('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
|
|
| 1123 | - $this->setError('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
|
|
| 1120 | + $this->debug('Unable to retrieve WSDL data for operation: '.$operation.' bindingType: '.$bindingType);
|
|
| 1121 | + $this->setError('Unable to retrieve WSDL data for operation: '.$operation.' bindingType: '.$bindingType);
|
|
| 1124 | 1122 | return false; |
| 1125 | 1123 | } |
| 1126 | 1124 | $this->debug('in serializeRPCParameters: opData:');
|
@@ -1128,7 +1126,7 @@ discard block |
||
| 1128 | 1126 | |
| 1129 | 1127 | // Get encoding style for output and set to current |
| 1130 | 1128 | $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; |
| 1131 | - if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
|
|
| 1129 | + if (($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
|
|
| 1132 | 1130 | $encodingStyle = $opData['output']['encodingStyle']; |
| 1133 | 1131 | $enc_style = $encodingStyle; |
| 1134 | 1132 | } |
@@ -1213,7 +1211,7 @@ discard block |
||
| 1213 | 1211 | function serializeParameters($operation, $direction, $parameters) |
| 1214 | 1212 | {
|
| 1215 | 1213 | $this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
|
| 1216 | - $this->appendDebug('parameters=' . $this->varDump($parameters));
|
|
| 1214 | + $this->appendDebug('parameters='.$this->varDump($parameters));
|
|
| 1217 | 1215 | |
| 1218 | 1216 | if ($direction != 'input' && $direction != 'output') {
|
| 1219 | 1217 | $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
|
@@ -1221,8 +1219,8 @@ discard block |
||
| 1221 | 1219 | return false; |
| 1222 | 1220 | } |
| 1223 | 1221 | if (!$opData = $this->getOperationData($operation)) {
|
| 1224 | - $this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
|
|
| 1225 | - $this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
|
|
| 1222 | + $this->debug('Unable to retrieve WSDL data for operation: '.$operation);
|
|
| 1223 | + $this->setError('Unable to retrieve WSDL data for operation: '.$operation);
|
|
| 1226 | 1224 | return false; |
| 1227 | 1225 | } |
| 1228 | 1226 | $this->debug('opData:');
|
@@ -1230,7 +1228,7 @@ discard block |
||
| 1230 | 1228 | |
| 1231 | 1229 | // Get encoding style for output and set to current |
| 1232 | 1230 | $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; |
| 1233 | - if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
|
|
| 1231 | + if (($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
|
|
| 1234 | 1232 | $encodingStyle = $opData['output']['encodingStyle']; |
| 1235 | 1233 | $enc_style = $encodingStyle; |
| 1236 | 1234 | } |
@@ -1241,14 +1239,14 @@ discard block |
||
| 1241 | 1239 | |
| 1242 | 1240 | $use = $opData[$direction]['use']; |
| 1243 | 1241 | $this->debug("use=$use");
|
| 1244 | - $this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)');
|
|
| 1242 | + $this->debug('got '.count($opData[$direction]['parts']).' part(s)');
|
|
| 1245 | 1243 | if (is_array($parameters)) {
|
| 1246 | 1244 | $parametersArrayType = $this->isArraySimpleOrStruct($parameters); |
| 1247 | - $this->debug('have ' . $parametersArrayType . ' parameters');
|
|
| 1248 | - foreach($opData[$direction]['parts'] as $name => $type) {
|
|
| 1245 | + $this->debug('have '.$parametersArrayType.' parameters');
|
|
| 1246 | + foreach ($opData[$direction]['parts'] as $name => $type) {
|
|
| 1249 | 1247 | $this->debug('serializing part "'.$name.'" of type "'.$type.'"');
|
| 1250 | 1248 | // Track encoding style |
| 1251 | - if(isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
|
|
| 1249 | + if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
|
|
| 1252 | 1250 | $encodingStyle = $opData[$direction]['encodingStyle']; |
| 1253 | 1251 | $enc_style = $encodingStyle; |
| 1254 | 1252 | } else {
|
@@ -1289,18 +1287,18 @@ discard block |
||
| 1289 | 1287 | * @return string value serialized as an XML string |
| 1290 | 1288 | * @access private |
| 1291 | 1289 | */ |
| 1292 | - function serializeType($name, $type, $value, $use='encoded', $encodingStyle=false, $unqualified=false) |
|
| 1290 | + function serializeType($name, $type, $value, $use = 'encoded', $encodingStyle = false, $unqualified = false) |
|
| 1293 | 1291 | {
|
| 1294 | - $this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified"));
|
|
| 1295 | - $this->appendDebug("value=" . $this->varDump($value));
|
|
| 1296 | - if($use == 'encoded' && $encodingStyle) {
|
|
| 1297 | - $encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"'; |
|
| 1292 | + $this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=".($unqualified ? "unqualified" : "qualified"));
|
|
| 1293 | + $this->appendDebug("value=".$this->varDump($value));
|
|
| 1294 | + if ($use == 'encoded' && $encodingStyle) {
|
|
| 1295 | + $encodingStyle = ' SOAP-ENV:encodingStyle="'.$encodingStyle.'"'; |
|
| 1298 | 1296 | } |
| 1299 | 1297 | |
| 1300 | 1298 | // if a soapval has been supplied, let its type override the WSDL |
| 1301 | 1299 | if (is_object($value) && get_class($value) == 'soapval') {
|
| 1302 | 1300 | if ($value->type_ns) {
|
| 1303 | - $type = $value->type_ns . ':' . $value->type; |
|
| 1301 | + $type = $value->type_ns.':'.$value->type; |
|
| 1304 | 1302 | $forceType = true; |
| 1305 | 1303 | $this->debug("in serializeType: soapval overrides type to $type");
|
| 1306 | 1304 | } elseif ($value->type) {
|
@@ -1319,7 +1317,7 @@ discard block |
||
| 1319 | 1317 | $value['!'] = $value; |
| 1320 | 1318 | } |
| 1321 | 1319 | foreach ($attrs as $n => $v) {
|
| 1322 | - $value['!' . $n] = $v; |
|
| 1320 | + $value['!'.$n] = $v; |
|
| 1323 | 1321 | } |
| 1324 | 1322 | $this->debug("in serializeType: soapval provides attributes");
|
| 1325 | 1323 | } |
@@ -1337,7 +1335,7 @@ discard block |
||
| 1337 | 1335 | $this->debug("in serializeType: expanded prefixed type: $uqType, $ns");
|
| 1338 | 1336 | } |
| 1339 | 1337 | |
| 1340 | - if($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/'){
|
|
| 1338 | + if ($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/') {
|
|
| 1341 | 1339 | $this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
|
| 1342 | 1340 | if ($unqualified && $use == 'literal') {
|
| 1343 | 1341 | $elementNS = " xmlns=\"\""; |
@@ -1350,7 +1348,7 @@ discard block |
||
| 1350 | 1348 | $xml = "<$name$elementNS/>"; |
| 1351 | 1349 | } else {
|
| 1352 | 1350 | // TODO: depends on nillable, which should be checked before calling this method |
| 1353 | - $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>"; |
|
| 1351 | + $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\"/>"; |
|
| 1354 | 1352 | } |
| 1355 | 1353 | $this->debug("in serializeType: returning: $xml");
|
| 1356 | 1354 | return $xml; |
@@ -1360,7 +1358,7 @@ discard block |
||
| 1360 | 1358 | return $this->serialize_val($value, $name, false, false, false, false, $use); |
| 1361 | 1359 | } |
| 1362 | 1360 | if ($uqType == 'boolean') {
|
| 1363 | - if ((is_string($value) && $value == 'false') || (! $value)) {
|
|
| 1361 | + if ((is_string($value) && $value == 'false') || (!$value)) {
|
|
| 1364 | 1362 | $value = 'false'; |
| 1365 | 1363 | } else {
|
| 1366 | 1364 | $value = 'true'; |
@@ -1378,12 +1376,12 @@ discard block |
||
| 1378 | 1376 | if (!$this->getTypeDef($uqType, $ns)) {
|
| 1379 | 1377 | if ($use == 'literal') {
|
| 1380 | 1378 | if ($forceType) {
|
| 1381 | - $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>"; |
|
| 1379 | + $xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\">$value</$name>"; |
|
| 1382 | 1380 | } else {
|
| 1383 | 1381 | $xml = "<$name$elementNS>$value</$name>"; |
| 1384 | 1382 | } |
| 1385 | 1383 | } else {
|
| 1386 | - $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>"; |
|
| 1384 | + $xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\"$encodingStyle>$value</$name>"; |
|
| 1387 | 1385 | } |
| 1388 | 1386 | $this->debug("in serializeType: returning: $xml");
|
| 1389 | 1387 | return $xml; |
@@ -1393,29 +1391,29 @@ discard block |
||
| 1393 | 1391 | $this->debug('in serializeType: appears to be Apache SOAP type');
|
| 1394 | 1392 | if ($uqType == 'Map') {
|
| 1395 | 1393 | $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
|
| 1396 | - if (! $tt_prefix) {
|
|
| 1394 | + if (!$tt_prefix) {
|
|
| 1397 | 1395 | $this->debug('in serializeType: Add namespace for Apache SOAP type');
|
| 1398 | - $tt_prefix = 'ns' . rand(1000, 9999); |
|
| 1396 | + $tt_prefix = 'ns'.rand(1000, 9999); |
|
| 1399 | 1397 | $this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap'; |
| 1400 | 1398 | // force this to be added to usedNamespaces |
| 1401 | 1399 | $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
|
| 1402 | 1400 | } |
| 1403 | 1401 | $contents = ''; |
| 1404 | - foreach($value as $k => $v) {
|
|
| 1402 | + foreach ($value as $k => $v) {
|
|
| 1405 | 1403 | $this->debug("serializing map element: key $k, value $v");
|
| 1406 | 1404 | $contents .= '<item>'; |
| 1407 | - $contents .= $this->serialize_val($k,'key',false,false,false,false,$use); |
|
| 1408 | - $contents .= $this->serialize_val($v,'value',false,false,false,false,$use); |
|
| 1405 | + $contents .= $this->serialize_val($k, 'key', false, false, false, false, $use); |
|
| 1406 | + $contents .= $this->serialize_val($v, 'value', false, false, false, false, $use); |
|
| 1409 | 1407 | $contents .= '</item>'; |
| 1410 | 1408 | } |
| 1411 | 1409 | if ($use == 'literal') {
|
| 1412 | 1410 | if ($forceType) {
|
| 1413 | - $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\">$contents</$name>"; |
|
| 1411 | + $xml = "<$name xsi:type=\"".$tt_prefix.":$uqType\">$contents</$name>"; |
|
| 1414 | 1412 | } else {
|
| 1415 | 1413 | $xml = "<$name>$contents</$name>"; |
| 1416 | 1414 | } |
| 1417 | 1415 | } else {
|
| 1418 | - $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\"$encodingStyle>$contents</$name>"; |
|
| 1416 | + $xml = "<$name xsi:type=\"".$tt_prefix.":$uqType\"$encodingStyle>$contents</$name>"; |
|
| 1419 | 1417 | } |
| 1420 | 1418 | $this->debug("in serializeType: returning: $xml");
|
| 1421 | 1419 | return $xml; |
@@ -1429,13 +1427,13 @@ discard block |
||
| 1429 | 1427 | $ns = ''; |
| 1430 | 1428 | $uqType = $type; |
| 1431 | 1429 | } |
| 1432 | - if(!$typeDef = $this->getTypeDef($uqType, $ns)){
|
|
| 1430 | + if (!$typeDef = $this->getTypeDef($uqType, $ns)) {
|
|
| 1433 | 1431 | $this->setError("$type ($uqType) is not a supported type.");
|
| 1434 | 1432 | $this->debug("in serializeType: $type ($uqType) is not a supported type.");
|
| 1435 | 1433 | return false; |
| 1436 | 1434 | } else {
|
| 1437 | 1435 | $this->debug("in serializeType: found typeDef");
|
| 1438 | - $this->appendDebug('typeDef=' . $this->varDump($typeDef));
|
|
| 1436 | + $this->appendDebug('typeDef='.$this->varDump($typeDef));
|
|
| 1439 | 1437 | if (substr($uqType, -1) == '^') {
|
| 1440 | 1438 | $uqType = substr($uqType, 0, -1); |
| 1441 | 1439 | } |
@@ -1446,7 +1444,7 @@ discard block |
||
| 1446 | 1444 | return false; |
| 1447 | 1445 | } |
| 1448 | 1446 | $phpType = $typeDef['phpType']; |
| 1449 | - $this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') );
|
|
| 1447 | + $this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: ".(isset($typeDef['arrayType']) ? $typeDef['arrayType'] : ''));
|
|
| 1450 | 1448 | // if php type == struct, map value to the <all> element names |
| 1451 | 1449 | if ($phpType == 'struct') {
|
| 1452 | 1450 | if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
|
@@ -1469,7 +1467,7 @@ discard block |
||
| 1469 | 1467 | // TODO: depends on minOccurs and nillable |
| 1470 | 1468 | $xml = "<$elementName$elementNS/>"; |
| 1471 | 1469 | } else {
|
| 1472 | - $xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>"; |
|
| 1470 | + $xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\"/>"; |
|
| 1473 | 1471 | } |
| 1474 | 1472 | $this->debug("in serializeType: returning: $xml");
|
| 1475 | 1473 | return $xml; |
@@ -1481,12 +1479,12 @@ discard block |
||
| 1481 | 1479 | $elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType); |
| 1482 | 1480 | if ($use == 'literal') {
|
| 1483 | 1481 | if ($forceType) {
|
| 1484 | - $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">"; |
|
| 1482 | + $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\">"; |
|
| 1485 | 1483 | } else {
|
| 1486 | 1484 | $xml = "<$elementName$elementNS$elementAttrs>"; |
| 1487 | 1485 | } |
| 1488 | 1486 | } else {
|
| 1489 | - $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>"; |
|
| 1487 | + $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\"$encodingStyle>"; |
|
| 1490 | 1488 | } |
| 1491 | 1489 | |
| 1492 | 1490 | if (isset($typeDef['simpleContent']) && $typeDef['simpleContent'] == 'true') {
|
@@ -1521,13 +1519,13 @@ discard block |
||
| 1521 | 1519 | // TODO: depends on minOccurs |
| 1522 | 1520 | $xml = "<$name$elementNS/>"; |
| 1523 | 1521 | } else {
|
| 1524 | - $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . |
|
| 1525 | - $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
|
|
| 1526 | - ":Array\" " . |
|
| 1527 | - $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
|
|
| 1528 | - ':arrayType="' . |
|
| 1529 | - $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) . |
|
| 1530 | - ':' . |
|
| 1522 | + $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"". |
|
| 1523 | + $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').
|
|
| 1524 | + ":Array\" ". |
|
| 1525 | + $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').
|
|
| 1526 | + ':arrayType="'. |
|
| 1527 | + $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])). |
|
| 1528 | + ':'. |
|
| 1531 | 1529 | $this->getLocalPart($typeDef['arrayType'])."[0]\"/>"; |
| 1532 | 1530 | } |
| 1533 | 1531 | $this->debug("in serializeType: returning: $xml");
|
@@ -1535,8 +1533,8 @@ discard block |
||
| 1535 | 1533 | } |
| 1536 | 1534 | if (isset($typeDef['multidimensional'])) {
|
| 1537 | 1535 | $nv = array(); |
| 1538 | - foreach($value as $v) {
|
|
| 1539 | - $cols = ',' . sizeof($v); |
|
| 1536 | + foreach ($value as $v) {
|
|
| 1537 | + $cols = ','.sizeof($v); |
|
| 1540 | 1538 | $nv = array_merge($nv, $v); |
| 1541 | 1539 | } |
| 1542 | 1540 | $value = $nv; |
@@ -1546,10 +1544,10 @@ discard block |
||
| 1546 | 1544 | if (is_array($value) && sizeof($value) >= 1) {
|
| 1547 | 1545 | $rows = sizeof($value); |
| 1548 | 1546 | $contents = ''; |
| 1549 | - foreach($value as $k => $v) {
|
|
| 1547 | + foreach ($value as $k => $v) {
|
|
| 1550 | 1548 | //$this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
|
| 1551 | 1549 | //if (strpos($typeDef['arrayType'], ':') ) {
|
| 1552 | - if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) {
|
|
| 1550 | + if (!in_array($typeDef['arrayType'], $this->typemap['http://www.w3.org/2001/XMLSchema'])) {
|
|
| 1553 | 1551 | $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use);
|
| 1554 | 1552 | } else {
|
| 1555 | 1553 | $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use); |
@@ -1586,12 +1584,12 @@ discard block |
||
| 1586 | 1584 | } |
| 1587 | 1585 | if ($use == 'literal') {
|
| 1588 | 1586 | if ($forceType) {
|
| 1589 | - $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>"; |
|
| 1587 | + $xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\">$value</$name>"; |
|
| 1590 | 1588 | } else {
|
| 1591 | 1589 | $xml = "<$name$elementNS>$value</$name>"; |
| 1592 | 1590 | } |
| 1593 | 1591 | } else {
|
| 1594 | - $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>"; |
|
| 1592 | + $xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\"$encodingStyle>$value</$name>"; |
|
| 1595 | 1593 | } |
| 1596 | 1594 | } |
| 1597 | 1595 | $this->debug("in serializeType: returning: $xml");
|
@@ -1635,22 +1633,22 @@ discard block |
||
| 1635 | 1633 | $xvalue = array(); |
| 1636 | 1634 | } |
| 1637 | 1635 | foreach ($typeDef['attrs'] as $aName => $attrs) {
|
| 1638 | - if (isset($xvalue['!' . $aName])) {
|
|
| 1639 | - $xname = '!' . $aName; |
|
| 1636 | + if (isset($xvalue['!'.$aName])) {
|
|
| 1637 | + $xname = '!'.$aName; |
|
| 1640 | 1638 | $this->debug("value provided for attribute $aName with key $xname");
|
| 1641 | 1639 | } elseif (isset($xvalue[$aName])) {
|
| 1642 | 1640 | $xname = $aName; |
| 1643 | 1641 | $this->debug("value provided for attribute $aName with key $xname");
|
| 1644 | 1642 | } elseif (isset($attrs['default'])) {
|
| 1645 | - $xname = '!' . $aName; |
|
| 1643 | + $xname = '!'.$aName; |
|
| 1646 | 1644 | $xvalue[$xname] = $attrs['default']; |
| 1647 | - $this->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName);
|
|
| 1645 | + $this->debug('use default value of '.$xvalue[$aName].' for attribute '.$aName);
|
|
| 1648 | 1646 | } else {
|
| 1649 | 1647 | $xname = ''; |
| 1650 | 1648 | $this->debug("no value provided for attribute $aName");
|
| 1651 | 1649 | } |
| 1652 | 1650 | if ($xname) {
|
| 1653 | - $xml .= " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\""; |
|
| 1651 | + $xml .= " $aName=\"".$this->expandEntities($xvalue[$xname])."\""; |
|
| 1654 | 1652 | } |
| 1655 | 1653 | } |
| 1656 | 1654 | } else {
|
@@ -1671,7 +1669,7 @@ discard block |
||
| 1671 | 1669 | * @return string value serialized as an XML string |
| 1672 | 1670 | * @access private |
| 1673 | 1671 | */ |
| 1674 | - function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='encoded', $encodingStyle=false) {
|
|
| 1672 | + function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use = 'encoded', $encodingStyle = false) {
|
|
| 1675 | 1673 | $this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType");
|
| 1676 | 1674 | $xml = ''; |
| 1677 | 1675 | if (isset($typeDef['extensionBase'])) {
|
@@ -1698,23 +1696,23 @@ discard block |
||
| 1698 | 1696 | $xvalue = array(); |
| 1699 | 1697 | } |
| 1700 | 1698 | // toggle whether all elements are present - ideally should validate against schema |
| 1701 | - if (count($typeDef['elements']) != count($xvalue)){
|
|
| 1699 | + if (count($typeDef['elements']) != count($xvalue)) {
|
|
| 1702 | 1700 | $optionals = true; |
| 1703 | 1701 | } |
| 1704 | 1702 | foreach ($typeDef['elements'] as $eName => $attrs) {
|
| 1705 | 1703 | if (!isset($xvalue[$eName])) {
|
| 1706 | 1704 | if (isset($attrs['default'])) {
|
| 1707 | 1705 | $xvalue[$eName] = $attrs['default']; |
| 1708 | - $this->debug('use default value of ' . $xvalue[$eName] . ' for element ' . $eName);
|
|
| 1706 | + $this->debug('use default value of '.$xvalue[$eName].' for element '.$eName);
|
|
| 1709 | 1707 | } |
| 1710 | 1708 | } |
| 1711 | 1709 | // if user took advantage of a minOccurs=0, then only serialize named parameters |
| 1712 | 1710 | if (isset($optionals) |
| 1713 | 1711 | && (!isset($xvalue[$eName])) |
| 1714 | - && ( (!isset($attrs['nillable'])) || $attrs['nillable'] != 'true') |
|
| 1715 | - ){
|
|
| 1712 | + && ((!isset($attrs['nillable'])) || $attrs['nillable'] != 'true') |
|
| 1713 | + ) {
|
|
| 1716 | 1714 | if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') {
|
| 1717 | - $this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minOccurs']);
|
|
| 1715 | + $this->debug("apparent error: no value provided for element $eName with minOccurs=".$attrs['minOccurs']);
|
|
| 1718 | 1716 | } |
| 1719 | 1717 | // do nothing |
| 1720 | 1718 | $this->debug("no value provided for complexType element $eName and element is not nillable, so serialize nothing");
|
@@ -1779,15 +1777,15 @@ discard block |
||
| 1779 | 1777 | * @see nusoap_xmlschema |
| 1780 | 1778 | * @access public |
| 1781 | 1779 | */ |
| 1782 | - function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType='') {
|
|
| 1780 | + function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = array(), $attrs = array(), $arrayType = '') {
|
|
| 1783 | 1781 | if (count($elements) > 0) {
|
| 1784 | 1782 | $eElements = array(); |
| 1785 | - foreach($elements as $n => $e){
|
|
| 1783 | + foreach ($elements as $n => $e) {
|
|
| 1786 | 1784 | // expand each element |
| 1787 | 1785 | $ee = array(); |
| 1788 | 1786 | foreach ($e as $k => $v) {
|
| 1789 | - $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 1790 | - $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 1787 | + $k = strpos($k, ':') ? $this->expandQname($k) : $k; |
|
| 1788 | + $v = strpos($v, ':') ? $this->expandQname($v) : $v; |
|
| 1791 | 1789 | $ee[$k] = $v; |
| 1792 | 1790 | } |
| 1793 | 1791 | $eElements[$n] = $ee; |
@@ -1796,11 +1794,11 @@ discard block |
||
| 1796 | 1794 | } |
| 1797 | 1795 | |
| 1798 | 1796 | if (count($attrs) > 0) {
|
| 1799 | - foreach($attrs as $n => $a){
|
|
| 1797 | + foreach ($attrs as $n => $a) {
|
|
| 1800 | 1798 | // expand each attribute |
| 1801 | 1799 | foreach ($a as $k => $v) {
|
| 1802 | - $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 1803 | - $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 1800 | + $k = strpos($k, ':') ? $this->expandQname($k) : $k; |
|
| 1801 | + $v = strpos($v, ':') ? $this->expandQname($v) : $v; |
|
| 1804 | 1802 | $aa[$k] = $v; |
| 1805 | 1803 | } |
| 1806 | 1804 | $eAttrs[$n] = $aa; |
@@ -1808,11 +1806,11 @@ discard block |
||
| 1808 | 1806 | $attrs = $eAttrs; |
| 1809 | 1807 | } |
| 1810 | 1808 | |
| 1811 | - $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase; |
|
| 1812 | - $arrayType = strpos($arrayType,':') ? $this->expandQname($arrayType) : $arrayType; |
|
| 1809 | + $restrictionBase = strpos($restrictionBase, ':') ? $this->expandQname($restrictionBase) : $restrictionBase; |
|
| 1810 | + $arrayType = strpos($arrayType, ':') ? $this->expandQname($arrayType) : $arrayType; |
|
| 1813 | 1811 | |
| 1814 | 1812 | $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns']; |
| 1815 | - $this->schemas[$typens][0]->addComplexType($name,$typeClass,$phpType,$compositor,$restrictionBase,$elements,$attrs,$arrayType); |
|
| 1813 | + $this->schemas[$typens][0]->addComplexType($name, $typeClass, $phpType, $compositor, $restrictionBase, $elements, $attrs, $arrayType); |
|
| 1816 | 1814 | } |
| 1817 | 1815 | |
| 1818 | 1816 | /** |
@@ -1826,8 +1824,8 @@ discard block |
||
| 1826 | 1824 | * @see nusoap_xmlschema |
| 1827 | 1825 | * @access public |
| 1828 | 1826 | */ |
| 1829 | - function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
|
|
| 1830 | - $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase; |
|
| 1827 | + function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = array()) {
|
|
| 1828 | + $restrictionBase = strpos($restrictionBase, ':') ? $this->expandQname($restrictionBase) : $restrictionBase; |
|
| 1831 | 1829 | |
| 1832 | 1830 | $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns']; |
| 1833 | 1831 | $this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumeration); |
@@ -1859,7 +1857,7 @@ discard block |
||
| 1859 | 1857 | * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
| 1860 | 1858 | * @access public |
| 1861 | 1859 | */ |
| 1862 | - function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = ''){
|
|
| 1860 | + function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = '') {
|
|
| 1863 | 1861 | if ($use == 'encoded' && $encodingStyle == '') {
|
| 1864 | 1862 | $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; |
| 1865 | 1863 | } |
@@ -1869,24 +1867,24 @@ discard block |
||
| 1869 | 1867 | foreach ($in as $n => $t) {
|
| 1870 | 1868 | $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
|
| 1871 | 1869 | } |
| 1872 | - $this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements); |
|
| 1873 | - $this->addElement(array('name' => $name, 'type' => $name . 'RequestType'));
|
|
| 1874 | - $in = array('parameters' => 'tns:' . $name . '^');
|
|
| 1870 | + $this->addComplexType($name.'RequestType', 'complexType', 'struct', 'all', '', $elements); |
|
| 1871 | + $this->addElement(array('name' => $name, 'type' => $name.'RequestType'));
|
|
| 1872 | + $in = array('parameters' => 'tns:'.$name.'^');
|
|
| 1875 | 1873 | |
| 1876 | 1874 | $elements = array(); |
| 1877 | 1875 | foreach ($out as $n => $t) {
|
| 1878 | 1876 | $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
|
| 1879 | 1877 | } |
| 1880 | - $this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements); |
|
| 1881 | - $this->addElement(array('name' => $name . 'Response', 'type' => $name . 'ResponseType', 'form' => 'qualified'));
|
|
| 1882 | - $out = array('parameters' => 'tns:' . $name . 'Response' . '^');
|
|
| 1878 | + $this->addComplexType($name.'ResponseType', 'complexType', 'struct', 'all', '', $elements); |
|
| 1879 | + $this->addElement(array('name' => $name.'Response', 'type' => $name.'ResponseType', 'form' => 'qualified'));
|
|
| 1880 | + $out = array('parameters' => 'tns:'.$name.'Response'.'^');
|
|
| 1883 | 1881 | } |
| 1884 | 1882 | |
| 1885 | 1883 | // get binding |
| 1886 | - $this->bindings[ $this->serviceName . 'Binding' ]['operations'][$name] = |
|
| 1884 | + $this->bindings[$this->serviceName.'Binding']['operations'][$name] = |
|
| 1887 | 1885 | array( |
| 1888 | 1886 | 'name' => $name, |
| 1889 | - 'binding' => $this->serviceName . 'Binding', |
|
| 1887 | + 'binding' => $this->serviceName.'Binding', |
|
| 1890 | 1888 | 'endpoint' => $this->endpoint, |
| 1891 | 1889 | 'soapAction' => $soapaction, |
| 1892 | 1890 | 'style' => $style, |
@@ -1894,42 +1892,42 @@ discard block |
||
| 1894 | 1892 | 'use' => $use, |
| 1895 | 1893 | 'namespace' => $namespace, |
| 1896 | 1894 | 'encodingStyle' => $encodingStyle, |
| 1897 | - 'message' => $name . 'Request', |
|
| 1895 | + 'message' => $name.'Request', |
|
| 1898 | 1896 | 'parts' => $in), |
| 1899 | 1897 | 'output' => array( |
| 1900 | 1898 | 'use' => $use, |
| 1901 | 1899 | 'namespace' => $namespace, |
| 1902 | 1900 | 'encodingStyle' => $encodingStyle, |
| 1903 | - 'message' => $name . 'Response', |
|
| 1901 | + 'message' => $name.'Response', |
|
| 1904 | 1902 | 'parts' => $out), |
| 1905 | 1903 | 'namespace' => $namespace, |
| 1906 | 1904 | 'transport' => 'http://schemas.xmlsoap.org/soap/http', |
| 1907 | 1905 | 'documentation' => $documentation); |
| 1908 | 1906 | // add portTypes |
| 1909 | 1907 | // add messages |
| 1910 | - if($in) |
|
| 1908 | + if ($in) |
|
| 1911 | 1909 | {
|
| 1912 | - foreach($in as $pName => $pType) |
|
| 1910 | + foreach ($in as $pName => $pType) |
|
| 1913 | 1911 | {
|
| 1914 | - if(strpos($pType,':')) {
|
|
| 1912 | + if (strpos($pType, ':')) {
|
|
| 1915 | 1913 | $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType); |
| 1916 | 1914 | } |
| 1917 | 1915 | $this->messages[$name.'Request'][$pName] = $pType; |
| 1918 | 1916 | } |
| 1919 | 1917 | } else {
|
| 1920 | - $this->messages[$name.'Request']= '0'; |
|
| 1918 | + $this->messages[$name.'Request'] = '0'; |
|
| 1921 | 1919 | } |
| 1922 | - if($out) |
|
| 1920 | + if ($out) |
|
| 1923 | 1921 | {
|
| 1924 | - foreach($out as $pName => $pType) |
|
| 1922 | + foreach ($out as $pName => $pType) |
|
| 1925 | 1923 | {
|
| 1926 | - if(strpos($pType,':')) {
|
|
| 1924 | + if (strpos($pType, ':')) {
|
|
| 1927 | 1925 | $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType); |
| 1928 | 1926 | } |
| 1929 | 1927 | $this->messages[$name.'Response'][$pName] = $pType; |
| 1930 | 1928 | } |
| 1931 | 1929 | } else {
|
| 1932 | - $this->messages[$name.'Response']= '0'; |
|
| 1930 | + $this->messages[$name.'Response'] = '0'; |
|
| 1933 | 1931 | } |
| 1934 | 1932 | return true; |
| 1935 | 1933 | } |
@@ -78,8 +78,9 @@ |
||
| 78 | 78 | $this->proxypassword = $proxypassword; |
| 79 | 79 | $this->timeout = $timeout; |
| 80 | 80 | $this->response_timeout = $response_timeout; |
| 81 | - if (is_array($curl_options)) |
|
| 82 | - $this->curl_options = $curl_options; |
|
| 81 | + if (is_array($curl_options)) { |
|
| 82 | + $this->curl_options = $curl_options; |
|
| 83 | + } |
|
| 83 | 84 | $this->use_curl = $use_curl; |
| 84 | 85 | $this->fetchWSDL($wsdl); |
| 85 | 86 | } |
@@ -791,7 +791,7 @@ |
||
| 791 | 791 | * returns a sample serialization of a given type, or false if no type by the given name |
| 792 | 792 | * |
| 793 | 793 | * @param string $type name of type |
| 794 | - * @return mixed |
|
| 794 | + * @return string|false |
|
| 795 | 795 | * @access public |
| 796 | 796 | * @deprecated |
| 797 | 797 | */ |
@@ -14,275 +14,275 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | class nusoap_xmlschema extends nusoap_base {
|
| 16 | 16 | |
| 17 | - // files |
|
| 18 | - var $schema = ''; |
|
| 19 | - var $xml = ''; |
|
| 20 | - // namespaces |
|
| 21 | - var $enclosingNamespaces; |
|
| 22 | - // schema info |
|
| 23 | - var $schemaInfo = array(); |
|
| 24 | - var $schemaTargetNamespace = ''; |
|
| 25 | - // types, elements, attributes defined by the schema |
|
| 26 | - var $attributes = array(); |
|
| 27 | - var $complexTypes = array(); |
|
| 28 | - var $complexTypeStack = array(); |
|
| 29 | - var $currentComplexType = null; |
|
| 30 | - var $elements = array(); |
|
| 31 | - var $elementStack = array(); |
|
| 32 | - var $currentElement = null; |
|
| 33 | - var $simpleTypes = array(); |
|
| 34 | - var $simpleTypeStack = array(); |
|
| 35 | - var $currentSimpleType = null; |
|
| 36 | - // imports |
|
| 37 | - var $imports = array(); |
|
| 38 | - // parser vars |
|
| 39 | - var $parser; |
|
| 40 | - var $position = 0; |
|
| 41 | - var $depth = 0; |
|
| 42 | - var $depth_array = array(); |
|
| 43 | - var $message = array(); |
|
| 44 | - var $defaultNamespace = array(); |
|
| 17 | + // files |
|
| 18 | + var $schema = ''; |
|
| 19 | + var $xml = ''; |
|
| 20 | + // namespaces |
|
| 21 | + var $enclosingNamespaces; |
|
| 22 | + // schema info |
|
| 23 | + var $schemaInfo = array(); |
|
| 24 | + var $schemaTargetNamespace = ''; |
|
| 25 | + // types, elements, attributes defined by the schema |
|
| 26 | + var $attributes = array(); |
|
| 27 | + var $complexTypes = array(); |
|
| 28 | + var $complexTypeStack = array(); |
|
| 29 | + var $currentComplexType = null; |
|
| 30 | + var $elements = array(); |
|
| 31 | + var $elementStack = array(); |
|
| 32 | + var $currentElement = null; |
|
| 33 | + var $simpleTypes = array(); |
|
| 34 | + var $simpleTypeStack = array(); |
|
| 35 | + var $currentSimpleType = null; |
|
| 36 | + // imports |
|
| 37 | + var $imports = array(); |
|
| 38 | + // parser vars |
|
| 39 | + var $parser; |
|
| 40 | + var $position = 0; |
|
| 41 | + var $depth = 0; |
|
| 42 | + var $depth_array = array(); |
|
| 43 | + var $message = array(); |
|
| 44 | + var $defaultNamespace = array(); |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * constructor |
|
| 48 | - * |
|
| 49 | - * @param string $schema schema document URI |
|
| 50 | - * @param string $xml xml document URI |
|
| 51 | - * @param string $namespaces namespaces defined in enclosing XML |
|
| 52 | - * @access public |
|
| 53 | - */ |
|
| 54 | - function nusoap_xmlschema($schema='',$xml='',$namespaces=array()){
|
|
| 55 | - parent::nusoap_base(); |
|
| 56 | - $this->debug('nusoap_xmlschema class instantiated, inside constructor');
|
|
| 57 | - // files |
|
| 58 | - $this->schema = $schema; |
|
| 59 | - $this->xml = $xml; |
|
| 46 | + /** |
|
| 47 | + * constructor |
|
| 48 | + * |
|
| 49 | + * @param string $schema schema document URI |
|
| 50 | + * @param string $xml xml document URI |
|
| 51 | + * @param string $namespaces namespaces defined in enclosing XML |
|
| 52 | + * @access public |
|
| 53 | + */ |
|
| 54 | + function nusoap_xmlschema($schema='',$xml='',$namespaces=array()){
|
|
| 55 | + parent::nusoap_base(); |
|
| 56 | + $this->debug('nusoap_xmlschema class instantiated, inside constructor');
|
|
| 57 | + // files |
|
| 58 | + $this->schema = $schema; |
|
| 59 | + $this->xml = $xml; |
|
| 60 | 60 | |
| 61 | - // namespaces |
|
| 62 | - $this->enclosingNamespaces = $namespaces; |
|
| 63 | - $this->namespaces = array_merge($this->namespaces, $namespaces); |
|
| 61 | + // namespaces |
|
| 62 | + $this->enclosingNamespaces = $namespaces; |
|
| 63 | + $this->namespaces = array_merge($this->namespaces, $namespaces); |
|
| 64 | 64 | |
| 65 | - // parse schema file |
|
| 66 | - if($schema != ''){
|
|
| 67 | - $this->debug('initial schema file: '.$schema);
|
|
| 68 | - $this->parseFile($schema, 'schema'); |
|
| 69 | - } |
|
| 65 | + // parse schema file |
|
| 66 | + if($schema != ''){
|
|
| 67 | + $this->debug('initial schema file: '.$schema);
|
|
| 68 | + $this->parseFile($schema, 'schema'); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - // parse xml file |
|
| 72 | - if($xml != ''){
|
|
| 73 | - $this->debug('initial xml file: '.$xml);
|
|
| 74 | - $this->parseFile($xml, 'xml'); |
|
| 75 | - } |
|
| 71 | + // parse xml file |
|
| 72 | + if($xml != ''){
|
|
| 73 | + $this->debug('initial xml file: '.$xml);
|
|
| 74 | + $this->parseFile($xml, 'xml'); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | - * parse an XML file |
|
| 81 | - * |
|
| 82 | - * @param string $xml path/URL to XML file |
|
| 83 | - * @param string $type (schema | xml) |
|
| 84 | - * @return boolean |
|
| 85 | - * @access public |
|
| 86 | - */ |
|
| 87 | - function parseFile($xml,$type){
|
|
| 88 | - // parse xml file |
|
| 89 | - if($xml != ""){
|
|
| 90 | - $xmlStr = @join("",@file($xml));
|
|
| 91 | - if($xmlStr == ""){
|
|
| 92 | - $msg = 'Error reading XML from '.$xml; |
|
| 93 | - $this->setError($msg); |
|
| 94 | - $this->debug($msg); |
|
| 95 | - return false; |
|
| 96 | - } else {
|
|
| 97 | - $this->debug("parsing $xml");
|
|
| 98 | - $this->parseString($xmlStr,$type); |
|
| 99 | - $this->debug("done parsing $xml");
|
|
| 100 | - return true; |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - return false; |
|
| 104 | - } |
|
| 80 | + * parse an XML file |
|
| 81 | + * |
|
| 82 | + * @param string $xml path/URL to XML file |
|
| 83 | + * @param string $type (schema | xml) |
|
| 84 | + * @return boolean |
|
| 85 | + * @access public |
|
| 86 | + */ |
|
| 87 | + function parseFile($xml,$type){
|
|
| 88 | + // parse xml file |
|
| 89 | + if($xml != ""){
|
|
| 90 | + $xmlStr = @join("",@file($xml));
|
|
| 91 | + if($xmlStr == ""){
|
|
| 92 | + $msg = 'Error reading XML from '.$xml; |
|
| 93 | + $this->setError($msg); |
|
| 94 | + $this->debug($msg); |
|
| 95 | + return false; |
|
| 96 | + } else {
|
|
| 97 | + $this->debug("parsing $xml");
|
|
| 98 | + $this->parseString($xmlStr,$type); |
|
| 99 | + $this->debug("done parsing $xml");
|
|
| 100 | + return true; |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + return false; |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * parse an XML string |
|
| 108 | - * |
|
| 109 | - * @param string $xml path or URL |
|
| 110 | - * @param string $type (schema|xml) |
|
| 111 | - * @access private |
|
| 112 | - */ |
|
| 113 | - function parseString($xml,$type){
|
|
| 114 | - // parse xml string |
|
| 115 | - if($xml != ""){
|
|
| 106 | + /** |
|
| 107 | + * parse an XML string |
|
| 108 | + * |
|
| 109 | + * @param string $xml path or URL |
|
| 110 | + * @param string $type (schema|xml) |
|
| 111 | + * @access private |
|
| 112 | + */ |
|
| 113 | + function parseString($xml,$type){
|
|
| 114 | + // parse xml string |
|
| 115 | + if($xml != ""){
|
|
| 116 | 116 | |
| 117 | - // Create an XML parser. |
|
| 118 | - $this->parser = xml_parser_create(); |
|
| 119 | - // Set the options for parsing the XML data. |
|
| 120 | - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
| 117 | + // Create an XML parser. |
|
| 118 | + $this->parser = xml_parser_create(); |
|
| 119 | + // Set the options for parsing the XML data. |
|
| 120 | + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
| 121 | 121 | |
| 122 | - // Set the object for the parser. |
|
| 123 | - xml_set_object($this->parser, $this); |
|
| 122 | + // Set the object for the parser. |
|
| 123 | + xml_set_object($this->parser, $this); |
|
| 124 | 124 | |
| 125 | - // Set the element handlers for the parser. |
|
| 126 | - if($type == "schema"){
|
|
| 127 | - xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement'); |
|
| 128 | - xml_set_character_data_handler($this->parser,'schemaCharacterData'); |
|
| 129 | - } elseif($type == "xml"){
|
|
| 130 | - xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement'); |
|
| 131 | - xml_set_character_data_handler($this->parser,'xmlCharacterData'); |
|
| 132 | - } |
|
| 125 | + // Set the element handlers for the parser. |
|
| 126 | + if($type == "schema"){
|
|
| 127 | + xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement'); |
|
| 128 | + xml_set_character_data_handler($this->parser,'schemaCharacterData'); |
|
| 129 | + } elseif($type == "xml"){
|
|
| 130 | + xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement'); |
|
| 131 | + xml_set_character_data_handler($this->parser,'xmlCharacterData'); |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - // Parse the XML file. |
|
| 135 | - if(!xml_parse($this->parser,$xml,true)){
|
|
| 136 | - // Display an error message. |
|
| 137 | - $errstr = sprintf('XML error parsing XML schema on line %d: %s',
|
|
| 138 | - xml_get_current_line_number($this->parser), |
|
| 139 | - xml_error_string(xml_get_error_code($this->parser)) |
|
| 140 | - ); |
|
| 141 | - $this->debug($errstr); |
|
| 142 | - $this->debug("XML payload:\n" . $xml);
|
|
| 143 | - $this->setError($errstr); |
|
| 144 | - } |
|
| 134 | + // Parse the XML file. |
|
| 135 | + if(!xml_parse($this->parser,$xml,true)){
|
|
| 136 | + // Display an error message. |
|
| 137 | + $errstr = sprintf('XML error parsing XML schema on line %d: %s',
|
|
| 138 | + xml_get_current_line_number($this->parser), |
|
| 139 | + xml_error_string(xml_get_error_code($this->parser)) |
|
| 140 | + ); |
|
| 141 | + $this->debug($errstr); |
|
| 142 | + $this->debug("XML payload:\n" . $xml);
|
|
| 143 | + $this->setError($errstr); |
|
| 144 | + } |
|
| 145 | 145 | |
| 146 | - xml_parser_free($this->parser); |
|
| 147 | - } else{
|
|
| 148 | - $this->debug('no xml passed to parseString()!!');
|
|
| 149 | - $this->setError('no xml passed to parseString()!!');
|
|
| 150 | - } |
|
| 151 | - } |
|
| 146 | + xml_parser_free($this->parser); |
|
| 147 | + } else{
|
|
| 148 | + $this->debug('no xml passed to parseString()!!');
|
|
| 149 | + $this->setError('no xml passed to parseString()!!');
|
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - /** |
|
| 154 | - * gets a type name for an unnamed type |
|
| 155 | - * |
|
| 156 | - * @param string Element name |
|
| 157 | - * @return string A type name for an unnamed type |
|
| 158 | - * @access private |
|
| 159 | - */ |
|
| 160 | - function CreateTypeName($ename) {
|
|
| 161 | - $scope = ''; |
|
| 162 | - for ($i = 0; $i < count($this->complexTypeStack); $i++) {
|
|
| 163 | - $scope .= $this->complexTypeStack[$i] . '_'; |
|
| 164 | - } |
|
| 165 | - return $scope . $ename . '_ContainedType'; |
|
| 166 | - } |
|
| 153 | + /** |
|
| 154 | + * gets a type name for an unnamed type |
|
| 155 | + * |
|
| 156 | + * @param string Element name |
|
| 157 | + * @return string A type name for an unnamed type |
|
| 158 | + * @access private |
|
| 159 | + */ |
|
| 160 | + function CreateTypeName($ename) {
|
|
| 161 | + $scope = ''; |
|
| 162 | + for ($i = 0; $i < count($this->complexTypeStack); $i++) {
|
|
| 163 | + $scope .= $this->complexTypeStack[$i] . '_'; |
|
| 164 | + } |
|
| 165 | + return $scope . $ename . '_ContainedType'; |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * start-element handler |
|
| 170 | - * |
|
| 171 | - * @param string $parser XML parser object |
|
| 172 | - * @param string $name element name |
|
| 173 | - * @param string $attrs associative array of attributes |
|
| 174 | - * @access private |
|
| 175 | - */ |
|
| 176 | - function schemaStartElement($parser, $name, $attrs) {
|
|
| 168 | + /** |
|
| 169 | + * start-element handler |
|
| 170 | + * |
|
| 171 | + * @param string $parser XML parser object |
|
| 172 | + * @param string $name element name |
|
| 173 | + * @param string $attrs associative array of attributes |
|
| 174 | + * @access private |
|
| 175 | + */ |
|
| 176 | + function schemaStartElement($parser, $name, $attrs) {
|
|
| 177 | 177 | |
| 178 | - // position in the total number of elements, starting from 0 |
|
| 179 | - $pos = $this->position++; |
|
| 180 | - $depth = $this->depth++; |
|
| 181 | - // set self as current value for this depth |
|
| 182 | - $this->depth_array[$depth] = $pos; |
|
| 183 | - $this->message[$pos] = array('cdata' => '');
|
|
| 184 | - if ($depth > 0) {
|
|
| 185 | - $this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]]; |
|
| 186 | - } else {
|
|
| 187 | - $this->defaultNamespace[$pos] = false; |
|
| 188 | - } |
|
| 178 | + // position in the total number of elements, starting from 0 |
|
| 179 | + $pos = $this->position++; |
|
| 180 | + $depth = $this->depth++; |
|
| 181 | + // set self as current value for this depth |
|
| 182 | + $this->depth_array[$depth] = $pos; |
|
| 183 | + $this->message[$pos] = array('cdata' => '');
|
|
| 184 | + if ($depth > 0) {
|
|
| 185 | + $this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]]; |
|
| 186 | + } else {
|
|
| 187 | + $this->defaultNamespace[$pos] = false; |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | - // get element prefix |
|
| 191 | - if($prefix = $this->getPrefix($name)){
|
|
| 192 | - // get unqualified name |
|
| 193 | - $name = $this->getLocalPart($name); |
|
| 194 | - } else {
|
|
| 195 | - $prefix = ''; |
|
| 190 | + // get element prefix |
|
| 191 | + if($prefix = $this->getPrefix($name)){
|
|
| 192 | + // get unqualified name |
|
| 193 | + $name = $this->getLocalPart($name); |
|
| 194 | + } else {
|
|
| 195 | + $prefix = ''; |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | // loop thru attributes, expanding, and registering namespace declarations |
| 199 | 199 | if(count($attrs) > 0){
|
| 200 | - foreach($attrs as $k => $v){
|
|
| 200 | + foreach($attrs as $k => $v){
|
|
| 201 | 201 | // if ns declarations, add to class level array of valid namespaces |
| 202 | - if(preg_match('/^xmlns/',$k)){
|
|
| 203 | - //$this->xdebug("$k: $v");
|
|
| 204 | - //$this->xdebug('ns_prefix: '.$this->getPrefix($k));
|
|
| 205 | - if($ns_prefix = substr(strrchr($k,':'),1)){
|
|
| 206 | - //$this->xdebug("Add namespace[$ns_prefix] = $v");
|
|
| 207 | - $this->namespaces[$ns_prefix] = $v; |
|
| 208 | - } else {
|
|
| 209 | - $this->defaultNamespace[$pos] = $v; |
|
| 210 | - if (! $this->getPrefixFromNamespace($v)) {
|
|
| 211 | - $this->namespaces['ns'.(count($this->namespaces)+1)] = $v; |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - if($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema'){
|
|
| 215 | - $this->XMLSchemaVersion = $v; |
|
| 216 | - $this->namespaces['xsi'] = $v.'-instance'; |
|
| 217 | - } |
|
| 218 | - } |
|
| 219 | - } |
|
| 220 | - foreach($attrs as $k => $v){
|
|
| 202 | + if(preg_match('/^xmlns/',$k)){
|
|
| 203 | + //$this->xdebug("$k: $v");
|
|
| 204 | + //$this->xdebug('ns_prefix: '.$this->getPrefix($k));
|
|
| 205 | + if($ns_prefix = substr(strrchr($k,':'),1)){
|
|
| 206 | + //$this->xdebug("Add namespace[$ns_prefix] = $v");
|
|
| 207 | + $this->namespaces[$ns_prefix] = $v; |
|
| 208 | + } else {
|
|
| 209 | + $this->defaultNamespace[$pos] = $v; |
|
| 210 | + if (! $this->getPrefixFromNamespace($v)) {
|
|
| 211 | + $this->namespaces['ns'.(count($this->namespaces)+1)] = $v; |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + if($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema'){
|
|
| 215 | + $this->XMLSchemaVersion = $v; |
|
| 216 | + $this->namespaces['xsi'] = $v.'-instance'; |
|
| 217 | + } |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | + foreach($attrs as $k => $v){
|
|
| 221 | 221 | // expand each attribute |
| 222 | 222 | $k = strpos($k,':') ? $this->expandQname($k) : $k; |
| 223 | 223 | $v = strpos($v,':') ? $this->expandQname($v) : $v; |
| 224 | - $eAttrs[$k] = $v; |
|
| 225 | - } |
|
| 226 | - $attrs = $eAttrs; |
|
| 224 | + $eAttrs[$k] = $v; |
|
| 225 | + } |
|
| 226 | + $attrs = $eAttrs; |
|
| 227 | 227 | } else {
|
| 228 | - $attrs = array(); |
|
| 228 | + $attrs = array(); |
|
| 229 | 229 | } |
| 230 | - // find status, register data |
|
| 231 | - switch($name){
|
|
| 232 | - case 'all': // (optional) compositor content for a complexType |
|
| 233 | - case 'choice': |
|
| 234 | - case 'group': |
|
| 235 | - case 'sequence': |
|
| 236 | - //$this->xdebug("compositor $name for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement");
|
|
| 237 | - $this->complexTypes[$this->currentComplexType]['compositor'] = $name; |
|
| 238 | - //if($name == 'all' || $name == 'sequence'){
|
|
| 239 | - // $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; |
|
| 240 | - //} |
|
| 241 | - break; |
|
| 242 | - case 'attribute': // complexType attribute |
|
| 243 | - //$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']);
|
|
| 244 | - $this->xdebug("parsing attribute:");
|
|
| 245 | - $this->appendDebug($this->varDump($attrs)); |
|
| 246 | - if (!isset($attrs['form'])) {
|
|
| 247 | - // TODO: handle globals |
|
| 248 | - $attrs['form'] = $this->schemaInfo['attributeFormDefault']; |
|
| 249 | - } |
|
| 250 | - if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
|
|
| 251 | - $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 252 | - if (!strpos($v, ':')) {
|
|
| 253 | - // no namespace in arrayType attribute value... |
|
| 254 | - if ($this->defaultNamespace[$pos]) {
|
|
| 255 | - // ...so use the default |
|
| 256 | - $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 257 | - } |
|
| 258 | - } |
|
| 259 | - } |
|
| 230 | + // find status, register data |
|
| 231 | + switch($name){
|
|
| 232 | + case 'all': // (optional) compositor content for a complexType |
|
| 233 | + case 'choice': |
|
| 234 | + case 'group': |
|
| 235 | + case 'sequence': |
|
| 236 | + //$this->xdebug("compositor $name for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement");
|
|
| 237 | + $this->complexTypes[$this->currentComplexType]['compositor'] = $name; |
|
| 238 | + //if($name == 'all' || $name == 'sequence'){
|
|
| 239 | + // $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; |
|
| 240 | + //} |
|
| 241 | + break; |
|
| 242 | + case 'attribute': // complexType attribute |
|
| 243 | + //$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']);
|
|
| 244 | + $this->xdebug("parsing attribute:");
|
|
| 245 | + $this->appendDebug($this->varDump($attrs)); |
|
| 246 | + if (!isset($attrs['form'])) {
|
|
| 247 | + // TODO: handle globals |
|
| 248 | + $attrs['form'] = $this->schemaInfo['attributeFormDefault']; |
|
| 249 | + } |
|
| 250 | + if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
|
|
| 251 | + $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 252 | + if (!strpos($v, ':')) {
|
|
| 253 | + // no namespace in arrayType attribute value... |
|
| 254 | + if ($this->defaultNamespace[$pos]) {
|
|
| 255 | + // ...so use the default |
|
| 256 | + $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | 260 | if(isset($attrs['name'])){
|
| 261 | - $this->attributes[$attrs['name']] = $attrs; |
|
| 262 | - $aname = $attrs['name']; |
|
| 263 | - } elseif(isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){
|
|
| 264 | - if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
|
|
| 265 | - $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 266 | - } else {
|
|
| 267 | - $aname = ''; |
|
| 268 | - } |
|
| 269 | - } elseif(isset($attrs['ref'])){
|
|
| 270 | - $aname = $attrs['ref']; |
|
| 261 | + $this->attributes[$attrs['name']] = $attrs; |
|
| 262 | + $aname = $attrs['name']; |
|
| 263 | + } elseif(isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){
|
|
| 264 | + if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
|
|
| 265 | + $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 266 | + } else {
|
|
| 267 | + $aname = ''; |
|
| 268 | + } |
|
| 269 | + } elseif(isset($attrs['ref'])){
|
|
| 270 | + $aname = $attrs['ref']; |
|
| 271 | 271 | $this->attributes[$attrs['ref']] = $attrs; |
| 272 | - } |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - if($this->currentComplexType){ // This should *always* be
|
|
| 275 | - $this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs; |
|
| 276 | - } |
|
| 277 | - // arrayType attribute |
|
| 278 | - if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType'){
|
|
| 279 | - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 280 | - $prefix = $this->getPrefix($aname); |
|
| 281 | - if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])){
|
|
| 282 | - $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 283 | - } else {
|
|
| 284 | - $v = ''; |
|
| 285 | - } |
|
| 274 | + if($this->currentComplexType){ // This should *always* be
|
|
| 275 | + $this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs; |
|
| 276 | + } |
|
| 277 | + // arrayType attribute |
|
| 278 | + if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType'){
|
|
| 279 | + $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 280 | + $prefix = $this->getPrefix($aname); |
|
| 281 | + if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])){
|
|
| 282 | + $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 283 | + } else {
|
|
| 284 | + $v = ''; |
|
| 285 | + } |
|
| 286 | 286 | if(strpos($v,'[,]')){
|
| 287 | 287 | $this->complexTypes[$this->currentComplexType]['multidimensional'] = true; |
| 288 | 288 | } |
@@ -291,676 +291,676 @@ discard block |
||
| 291 | 291 | $v = $this->XMLSchemaVersion.':'.$v; |
| 292 | 292 | } |
| 293 | 293 | $this->complexTypes[$this->currentComplexType]['arrayType'] = $v; |
| 294 | - } |
|
| 295 | - break; |
|
| 296 | - case 'complexContent': // (optional) content for a complexType |
|
| 297 | - $this->xdebug("do nothing for element $name");
|
|
| 298 | - break; |
|
| 299 | - case 'complexType': |
|
| 300 | - array_push($this->complexTypeStack, $this->currentComplexType); |
|
| 301 | - if(isset($attrs['name'])){
|
|
| 302 | - // TODO: what is the scope of named complexTypes that appear |
|
| 303 | - // nested within other c complexTypes? |
|
| 304 | - $this->xdebug('processing named complexType '.$attrs['name']);
|
|
| 305 | - //$this->currentElement = false; |
|
| 306 | - $this->currentComplexType = $attrs['name']; |
|
| 307 | - $this->complexTypes[$this->currentComplexType] = $attrs; |
|
| 308 | - $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; |
|
| 309 | - // This is for constructs like |
|
| 310 | - // <complexType name="ListOfString" base="soap:Array"> |
|
| 311 | - // <sequence> |
|
| 312 | - // <element name="string" type="xsd:string" |
|
| 313 | - // minOccurs="0" maxOccurs="unbounded" /> |
|
| 314 | - // </sequence> |
|
| 315 | - // </complexType> |
|
| 316 | - if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
|
|
| 317 | - $this->xdebug('complexType is unusual array');
|
|
| 318 | - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 319 | - } else {
|
|
| 320 | - $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; |
|
| 321 | - } |
|
| 322 | - } else {
|
|
| 323 | - $name = $this->CreateTypeName($this->currentElement); |
|
| 324 | - $this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name);
|
|
| 325 | - $this->currentComplexType = $name; |
|
| 326 | - //$this->currentElement = false; |
|
| 327 | - $this->complexTypes[$this->currentComplexType] = $attrs; |
|
| 328 | - $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; |
|
| 329 | - // This is for constructs like |
|
| 330 | - // <complexType name="ListOfString" base="soap:Array"> |
|
| 331 | - // <sequence> |
|
| 332 | - // <element name="string" type="xsd:string" |
|
| 333 | - // minOccurs="0" maxOccurs="unbounded" /> |
|
| 334 | - // </sequence> |
|
| 335 | - // </complexType> |
|
| 336 | - if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
|
|
| 337 | - $this->xdebug('complexType is unusual array');
|
|
| 338 | - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 339 | - } else {
|
|
| 340 | - $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; |
|
| 341 | - } |
|
| 342 | - } |
|
| 343 | - $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'false'; |
|
| 344 | - break; |
|
| 345 | - case 'element': |
|
| 346 | - array_push($this->elementStack, $this->currentElement); |
|
| 347 | - if (!isset($attrs['form'])) {
|
|
| 348 | - if ($this->currentComplexType) {
|
|
| 349 | - $attrs['form'] = $this->schemaInfo['elementFormDefault']; |
|
| 350 | - } else {
|
|
| 351 | - // global |
|
| 352 | - $attrs['form'] = 'qualified'; |
|
| 353 | - } |
|
| 354 | - } |
|
| 355 | - if(isset($attrs['type'])){
|
|
| 356 | - $this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']);
|
|
| 357 | - if (! $this->getPrefix($attrs['type'])) {
|
|
| 358 | - if ($this->defaultNamespace[$pos]) {
|
|
| 359 | - $attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type']; |
|
| 360 | - $this->xdebug('used default namespace to make type ' . $attrs['type']);
|
|
| 361 | - } |
|
| 362 | - } |
|
| 363 | - // This is for constructs like |
|
| 364 | - // <complexType name="ListOfString" base="soap:Array"> |
|
| 365 | - // <sequence> |
|
| 366 | - // <element name="string" type="xsd:string" |
|
| 367 | - // minOccurs="0" maxOccurs="unbounded" /> |
|
| 368 | - // </sequence> |
|
| 369 | - // </complexType> |
|
| 370 | - if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') {
|
|
| 371 | - $this->xdebug('arrayType for unusual array is ' . $attrs['type']);
|
|
| 372 | - $this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type']; |
|
| 373 | - } |
|
| 374 | - $this->currentElement = $attrs['name']; |
|
| 375 | - $ename = $attrs['name']; |
|
| 376 | - } elseif(isset($attrs['ref'])){
|
|
| 377 | - $this->xdebug("processing element as ref to ".$attrs['ref']);
|
|
| 378 | - $this->currentElement = "ref to ".$attrs['ref']; |
|
| 379 | - $ename = $this->getLocalPart($attrs['ref']); |
|
| 380 | - } else {
|
|
| 381 | - $type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']); |
|
| 382 | - $this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type);
|
|
| 383 | - $this->currentElement = $attrs['name']; |
|
| 384 | - $attrs['type'] = $this->schemaTargetNamespace . ':' . $type; |
|
| 385 | - $ename = $attrs['name']; |
|
| 386 | - } |
|
| 387 | - if (isset($ename) && $this->currentComplexType) {
|
|
| 388 | - $this->xdebug("add element $ename to complexType $this->currentComplexType");
|
|
| 389 | - $this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs; |
|
| 390 | - } elseif (!isset($attrs['ref'])) {
|
|
| 391 | - $this->xdebug("add element $ename to elements array");
|
|
| 392 | - $this->elements[ $attrs['name'] ] = $attrs; |
|
| 393 | - $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; |
|
| 394 | - } |
|
| 395 | - break; |
|
| 396 | - case 'enumeration': // restriction value list member |
|
| 397 | - $this->xdebug('enumeration ' . $attrs['value']);
|
|
| 398 | - if ($this->currentSimpleType) {
|
|
| 399 | - $this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value']; |
|
| 400 | - } elseif ($this->currentComplexType) {
|
|
| 401 | - $this->complexTypes[$this->currentComplexType]['enumeration'][] = $attrs['value']; |
|
| 402 | - } |
|
| 403 | - break; |
|
| 404 | - case 'extension': // simpleContent or complexContent type extension |
|
| 405 | - $this->xdebug('extension ' . $attrs['base']);
|
|
| 406 | - if ($this->currentComplexType) {
|
|
| 407 | - $ns = $this->getPrefix($attrs['base']); |
|
| 408 | - if ($ns == '') {
|
|
| 409 | - $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base']; |
|
| 410 | - } else {
|
|
| 411 | - $this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base']; |
|
| 412 | - } |
|
| 413 | - } else {
|
|
| 414 | - $this->xdebug('no current complexType to set extensionBase');
|
|
| 415 | - } |
|
| 416 | - break; |
|
| 417 | - case 'import': |
|
| 418 | - if (isset($attrs['schemaLocation'])) {
|
|
| 419 | - $this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
|
|
| 294 | + } |
|
| 295 | + break; |
|
| 296 | + case 'complexContent': // (optional) content for a complexType |
|
| 297 | + $this->xdebug("do nothing for element $name");
|
|
| 298 | + break; |
|
| 299 | + case 'complexType': |
|
| 300 | + array_push($this->complexTypeStack, $this->currentComplexType); |
|
| 301 | + if(isset($attrs['name'])){
|
|
| 302 | + // TODO: what is the scope of named complexTypes that appear |
|
| 303 | + // nested within other c complexTypes? |
|
| 304 | + $this->xdebug('processing named complexType '.$attrs['name']);
|
|
| 305 | + //$this->currentElement = false; |
|
| 306 | + $this->currentComplexType = $attrs['name']; |
|
| 307 | + $this->complexTypes[$this->currentComplexType] = $attrs; |
|
| 308 | + $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; |
|
| 309 | + // This is for constructs like |
|
| 310 | + // <complexType name="ListOfString" base="soap:Array"> |
|
| 311 | + // <sequence> |
|
| 312 | + // <element name="string" type="xsd:string" |
|
| 313 | + // minOccurs="0" maxOccurs="unbounded" /> |
|
| 314 | + // </sequence> |
|
| 315 | + // </complexType> |
|
| 316 | + if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
|
|
| 317 | + $this->xdebug('complexType is unusual array');
|
|
| 318 | + $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 319 | + } else {
|
|
| 320 | + $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; |
|
| 321 | + } |
|
| 322 | + } else {
|
|
| 323 | + $name = $this->CreateTypeName($this->currentElement); |
|
| 324 | + $this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name);
|
|
| 325 | + $this->currentComplexType = $name; |
|
| 326 | + //$this->currentElement = false; |
|
| 327 | + $this->complexTypes[$this->currentComplexType] = $attrs; |
|
| 328 | + $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType'; |
|
| 329 | + // This is for constructs like |
|
| 330 | + // <complexType name="ListOfString" base="soap:Array"> |
|
| 331 | + // <sequence> |
|
| 332 | + // <element name="string" type="xsd:string" |
|
| 333 | + // minOccurs="0" maxOccurs="unbounded" /> |
|
| 334 | + // </sequence> |
|
| 335 | + // </complexType> |
|
| 336 | + if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
|
|
| 337 | + $this->xdebug('complexType is unusual array');
|
|
| 338 | + $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 339 | + } else {
|
|
| 340 | + $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct'; |
|
| 341 | + } |
|
| 342 | + } |
|
| 343 | + $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'false'; |
|
| 344 | + break; |
|
| 345 | + case 'element': |
|
| 346 | + array_push($this->elementStack, $this->currentElement); |
|
| 347 | + if (!isset($attrs['form'])) {
|
|
| 348 | + if ($this->currentComplexType) {
|
|
| 349 | + $attrs['form'] = $this->schemaInfo['elementFormDefault']; |
|
| 350 | + } else {
|
|
| 351 | + // global |
|
| 352 | + $attrs['form'] = 'qualified'; |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | + if(isset($attrs['type'])){
|
|
| 356 | + $this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']);
|
|
| 357 | + if (! $this->getPrefix($attrs['type'])) {
|
|
| 358 | + if ($this->defaultNamespace[$pos]) {
|
|
| 359 | + $attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type']; |
|
| 360 | + $this->xdebug('used default namespace to make type ' . $attrs['type']);
|
|
| 361 | + } |
|
| 362 | + } |
|
| 363 | + // This is for constructs like |
|
| 364 | + // <complexType name="ListOfString" base="soap:Array"> |
|
| 365 | + // <sequence> |
|
| 366 | + // <element name="string" type="xsd:string" |
|
| 367 | + // minOccurs="0" maxOccurs="unbounded" /> |
|
| 368 | + // </sequence> |
|
| 369 | + // </complexType> |
|
| 370 | + if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') {
|
|
| 371 | + $this->xdebug('arrayType for unusual array is ' . $attrs['type']);
|
|
| 372 | + $this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type']; |
|
| 373 | + } |
|
| 374 | + $this->currentElement = $attrs['name']; |
|
| 375 | + $ename = $attrs['name']; |
|
| 376 | + } elseif(isset($attrs['ref'])){
|
|
| 377 | + $this->xdebug("processing element as ref to ".$attrs['ref']);
|
|
| 378 | + $this->currentElement = "ref to ".$attrs['ref']; |
|
| 379 | + $ename = $this->getLocalPart($attrs['ref']); |
|
| 380 | + } else {
|
|
| 381 | + $type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']); |
|
| 382 | + $this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type);
|
|
| 383 | + $this->currentElement = $attrs['name']; |
|
| 384 | + $attrs['type'] = $this->schemaTargetNamespace . ':' . $type; |
|
| 385 | + $ename = $attrs['name']; |
|
| 386 | + } |
|
| 387 | + if (isset($ename) && $this->currentComplexType) {
|
|
| 388 | + $this->xdebug("add element $ename to complexType $this->currentComplexType");
|
|
| 389 | + $this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs; |
|
| 390 | + } elseif (!isset($attrs['ref'])) {
|
|
| 391 | + $this->xdebug("add element $ename to elements array");
|
|
| 392 | + $this->elements[ $attrs['name'] ] = $attrs; |
|
| 393 | + $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; |
|
| 394 | + } |
|
| 395 | + break; |
|
| 396 | + case 'enumeration': // restriction value list member |
|
| 397 | + $this->xdebug('enumeration ' . $attrs['value']);
|
|
| 398 | + if ($this->currentSimpleType) {
|
|
| 399 | + $this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value']; |
|
| 400 | + } elseif ($this->currentComplexType) {
|
|
| 401 | + $this->complexTypes[$this->currentComplexType]['enumeration'][] = $attrs['value']; |
|
| 402 | + } |
|
| 403 | + break; |
|
| 404 | + case 'extension': // simpleContent or complexContent type extension |
|
| 405 | + $this->xdebug('extension ' . $attrs['base']);
|
|
| 406 | + if ($this->currentComplexType) {
|
|
| 407 | + $ns = $this->getPrefix($attrs['base']); |
|
| 408 | + if ($ns == '') {
|
|
| 409 | + $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base']; |
|
| 410 | + } else {
|
|
| 411 | + $this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base']; |
|
| 412 | + } |
|
| 413 | + } else {
|
|
| 414 | + $this->xdebug('no current complexType to set extensionBase');
|
|
| 415 | + } |
|
| 416 | + break; |
|
| 417 | + case 'import': |
|
| 418 | + if (isset($attrs['schemaLocation'])) {
|
|
| 419 | + $this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
|
|
| 420 | 420 | $this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
|
| 421 | - } else {
|
|
| 422 | - $this->xdebug('import namespace ' . $attrs['namespace']);
|
|
| 421 | + } else {
|
|
| 422 | + $this->xdebug('import namespace ' . $attrs['namespace']);
|
|
| 423 | 423 | $this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
|
| 424 | - if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
|
|
| 425 | - $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace']; |
|
| 426 | - } |
|
| 427 | - } |
|
| 428 | - break; |
|
| 429 | - case 'include': |
|
| 430 | - if (isset($attrs['schemaLocation'])) {
|
|
| 431 | - $this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']);
|
|
| 424 | + if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
|
|
| 425 | + $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace']; |
|
| 426 | + } |
|
| 427 | + } |
|
| 428 | + break; |
|
| 429 | + case 'include': |
|
| 430 | + if (isset($attrs['schemaLocation'])) {
|
|
| 431 | + $this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']);
|
|
| 432 | 432 | $this->imports[$this->schemaTargetNamespace][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
|
| 433 | - } else {
|
|
| 434 | - $this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute');
|
|
| 435 | - } |
|
| 436 | - break; |
|
| 437 | - case 'list': // simpleType value list |
|
| 438 | - $this->xdebug("do nothing for element $name");
|
|
| 439 | - break; |
|
| 440 | - case 'restriction': // simpleType, simpleContent or complexContent value restriction |
|
| 441 | - $this->xdebug('restriction ' . $attrs['base']);
|
|
| 442 | - if($this->currentSimpleType){
|
|
| 443 | - $this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base']; |
|
| 444 | - } elseif($this->currentComplexType){
|
|
| 445 | - $this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base']; |
|
| 446 | - if(strstr($attrs['base'],':') == ':Array'){
|
|
| 447 | - $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 448 | - } |
|
| 449 | - } |
|
| 450 | - break; |
|
| 451 | - case 'schema': |
|
| 452 | - $this->schemaInfo = $attrs; |
|
| 453 | - $this->schemaInfo['schemaVersion'] = $this->getNamespaceFromPrefix($prefix); |
|
| 454 | - if (isset($attrs['targetNamespace'])) {
|
|
| 455 | - $this->schemaTargetNamespace = $attrs['targetNamespace']; |
|
| 456 | - } |
|
| 457 | - if (!isset($attrs['elementFormDefault'])) {
|
|
| 458 | - $this->schemaInfo['elementFormDefault'] = 'unqualified'; |
|
| 459 | - } |
|
| 460 | - if (!isset($attrs['attributeFormDefault'])) {
|
|
| 461 | - $this->schemaInfo['attributeFormDefault'] = 'unqualified'; |
|
| 462 | - } |
|
| 463 | - break; |
|
| 464 | - case 'simpleContent': // (optional) content for a complexType |
|
| 465 | - if ($this->currentComplexType) { // This should *always* be
|
|
| 466 | - $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'true'; |
|
| 467 | - } else {
|
|
| 468 | - $this->xdebug("do nothing for element $name because there is no current complexType");
|
|
| 469 | - } |
|
| 470 | - break; |
|
| 471 | - case 'simpleType': |
|
| 472 | - array_push($this->simpleTypeStack, $this->currentSimpleType); |
|
| 473 | - if(isset($attrs['name'])){
|
|
| 474 | - $this->xdebug("processing simpleType for name " . $attrs['name']);
|
|
| 475 | - $this->currentSimpleType = $attrs['name']; |
|
| 476 | - $this->simpleTypes[ $attrs['name'] ] = $attrs; |
|
| 477 | - $this->simpleTypes[ $attrs['name'] ]['typeClass'] = 'simpleType'; |
|
| 478 | - $this->simpleTypes[ $attrs['name'] ]['phpType'] = 'scalar'; |
|
| 479 | - } else {
|
|
| 480 | - $name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement); |
|
| 481 | - $this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $name);
|
|
| 482 | - $this->currentSimpleType = $name; |
|
| 483 | - //$this->currentElement = false; |
|
| 484 | - $this->simpleTypes[$this->currentSimpleType] = $attrs; |
|
| 485 | - $this->simpleTypes[$this->currentSimpleType]['phpType'] = 'scalar'; |
|
| 486 | - } |
|
| 487 | - break; |
|
| 488 | - case 'union': // simpleType type list |
|
| 489 | - $this->xdebug("do nothing for element $name");
|
|
| 490 | - break; |
|
| 491 | - default: |
|
| 492 | - $this->xdebug("do not have any logic to process element $name");
|
|
| 493 | - } |
|
| 494 | - } |
|
| 433 | + } else {
|
|
| 434 | + $this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute');
|
|
| 435 | + } |
|
| 436 | + break; |
|
| 437 | + case 'list': // simpleType value list |
|
| 438 | + $this->xdebug("do nothing for element $name");
|
|
| 439 | + break; |
|
| 440 | + case 'restriction': // simpleType, simpleContent or complexContent value restriction |
|
| 441 | + $this->xdebug('restriction ' . $attrs['base']);
|
|
| 442 | + if($this->currentSimpleType){
|
|
| 443 | + $this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base']; |
|
| 444 | + } elseif($this->currentComplexType){
|
|
| 445 | + $this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base']; |
|
| 446 | + if(strstr($attrs['base'],':') == ':Array'){
|
|
| 447 | + $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
|
| 448 | + } |
|
| 449 | + } |
|
| 450 | + break; |
|
| 451 | + case 'schema': |
|
| 452 | + $this->schemaInfo = $attrs; |
|
| 453 | + $this->schemaInfo['schemaVersion'] = $this->getNamespaceFromPrefix($prefix); |
|
| 454 | + if (isset($attrs['targetNamespace'])) {
|
|
| 455 | + $this->schemaTargetNamespace = $attrs['targetNamespace']; |
|
| 456 | + } |
|
| 457 | + if (!isset($attrs['elementFormDefault'])) {
|
|
| 458 | + $this->schemaInfo['elementFormDefault'] = 'unqualified'; |
|
| 459 | + } |
|
| 460 | + if (!isset($attrs['attributeFormDefault'])) {
|
|
| 461 | + $this->schemaInfo['attributeFormDefault'] = 'unqualified'; |
|
| 462 | + } |
|
| 463 | + break; |
|
| 464 | + case 'simpleContent': // (optional) content for a complexType |
|
| 465 | + if ($this->currentComplexType) { // This should *always* be
|
|
| 466 | + $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'true'; |
|
| 467 | + } else {
|
|
| 468 | + $this->xdebug("do nothing for element $name because there is no current complexType");
|
|
| 469 | + } |
|
| 470 | + break; |
|
| 471 | + case 'simpleType': |
|
| 472 | + array_push($this->simpleTypeStack, $this->currentSimpleType); |
|
| 473 | + if(isset($attrs['name'])){
|
|
| 474 | + $this->xdebug("processing simpleType for name " . $attrs['name']);
|
|
| 475 | + $this->currentSimpleType = $attrs['name']; |
|
| 476 | + $this->simpleTypes[ $attrs['name'] ] = $attrs; |
|
| 477 | + $this->simpleTypes[ $attrs['name'] ]['typeClass'] = 'simpleType'; |
|
| 478 | + $this->simpleTypes[ $attrs['name'] ]['phpType'] = 'scalar'; |
|
| 479 | + } else {
|
|
| 480 | + $name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement); |
|
| 481 | + $this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $name);
|
|
| 482 | + $this->currentSimpleType = $name; |
|
| 483 | + //$this->currentElement = false; |
|
| 484 | + $this->simpleTypes[$this->currentSimpleType] = $attrs; |
|
| 485 | + $this->simpleTypes[$this->currentSimpleType]['phpType'] = 'scalar'; |
|
| 486 | + } |
|
| 487 | + break; |
|
| 488 | + case 'union': // simpleType type list |
|
| 489 | + $this->xdebug("do nothing for element $name");
|
|
| 490 | + break; |
|
| 491 | + default: |
|
| 492 | + $this->xdebug("do not have any logic to process element $name");
|
|
| 493 | + } |
|
| 494 | + } |
|
| 495 | 495 | |
| 496 | - /** |
|
| 497 | - * end-element handler |
|
| 498 | - * |
|
| 499 | - * @param string $parser XML parser object |
|
| 500 | - * @param string $name element name |
|
| 501 | - * @access private |
|
| 502 | - */ |
|
| 503 | - function schemaEndElement($parser, $name) {
|
|
| 504 | - // bring depth down a notch |
|
| 505 | - $this->depth--; |
|
| 506 | - // position of current element is equal to the last value left in depth_array for my depth |
|
| 507 | - if(isset($this->depth_array[$this->depth])){
|
|
| 508 | - $pos = $this->depth_array[$this->depth]; |
|
| 496 | + /** |
|
| 497 | + * end-element handler |
|
| 498 | + * |
|
| 499 | + * @param string $parser XML parser object |
|
| 500 | + * @param string $name element name |
|
| 501 | + * @access private |
|
| 502 | + */ |
|
| 503 | + function schemaEndElement($parser, $name) {
|
|
| 504 | + // bring depth down a notch |
|
| 505 | + $this->depth--; |
|
| 506 | + // position of current element is equal to the last value left in depth_array for my depth |
|
| 507 | + if(isset($this->depth_array[$this->depth])){
|
|
| 508 | + $pos = $this->depth_array[$this->depth]; |
|
| 509 | + } |
|
| 510 | + // get element prefix |
|
| 511 | + if ($prefix = $this->getPrefix($name)){
|
|
| 512 | + // get unqualified name |
|
| 513 | + $name = $this->getLocalPart($name); |
|
| 514 | + } else {
|
|
| 515 | + $prefix = ''; |
|
| 516 | + } |
|
| 517 | + // move on... |
|
| 518 | + if($name == 'complexType'){
|
|
| 519 | + $this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType : '(unknown)'));
|
|
| 520 | + $this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType])); |
|
| 521 | + $this->currentComplexType = array_pop($this->complexTypeStack); |
|
| 522 | + //$this->currentElement = false; |
|
| 509 | 523 | } |
| 510 | - // get element prefix |
|
| 511 | - if ($prefix = $this->getPrefix($name)){
|
|
| 512 | - // get unqualified name |
|
| 513 | - $name = $this->getLocalPart($name); |
|
| 514 | - } else {
|
|
| 515 | - $prefix = ''; |
|
| 524 | + if($name == 'element'){
|
|
| 525 | + $this->xdebug('done processing element ' . ($this->currentElement ? $this->currentElement : '(unknown)'));
|
|
| 526 | + $this->currentElement = array_pop($this->elementStack); |
|
| 516 | 527 | } |
| 517 | - // move on... |
|
| 518 | - if($name == 'complexType'){
|
|
| 519 | - $this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType : '(unknown)'));
|
|
| 520 | - $this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType])); |
|
| 521 | - $this->currentComplexType = array_pop($this->complexTypeStack); |
|
| 522 | - //$this->currentElement = false; |
|
| 523 | - } |
|
| 524 | - if($name == 'element'){
|
|
| 525 | - $this->xdebug('done processing element ' . ($this->currentElement ? $this->currentElement : '(unknown)'));
|
|
| 526 | - $this->currentElement = array_pop($this->elementStack); |
|
| 527 | - } |
|
| 528 | - if($name == 'simpleType'){
|
|
| 529 | - $this->xdebug('done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType : '(unknown)'));
|
|
| 530 | - $this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType])); |
|
| 531 | - $this->currentSimpleType = array_pop($this->simpleTypeStack); |
|
| 532 | - } |
|
| 533 | - } |
|
| 528 | + if($name == 'simpleType'){
|
|
| 529 | + $this->xdebug('done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType : '(unknown)'));
|
|
| 530 | + $this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType])); |
|
| 531 | + $this->currentSimpleType = array_pop($this->simpleTypeStack); |
|
| 532 | + } |
|
| 533 | + } |
|
| 534 | 534 | |
| 535 | - /** |
|
| 536 | - * element content handler |
|
| 537 | - * |
|
| 538 | - * @param string $parser XML parser object |
|
| 539 | - * @param string $data element content |
|
| 540 | - * @access private |
|
| 541 | - */ |
|
| 542 | - function schemaCharacterData($parser, $data){
|
|
| 543 | - $pos = $this->depth_array[$this->depth - 1]; |
|
| 544 | - $this->message[$pos]['cdata'] .= $data; |
|
| 545 | - } |
|
| 535 | + /** |
|
| 536 | + * element content handler |
|
| 537 | + * |
|
| 538 | + * @param string $parser XML parser object |
|
| 539 | + * @param string $data element content |
|
| 540 | + * @access private |
|
| 541 | + */ |
|
| 542 | + function schemaCharacterData($parser, $data){
|
|
| 543 | + $pos = $this->depth_array[$this->depth - 1]; |
|
| 544 | + $this->message[$pos]['cdata'] .= $data; |
|
| 545 | + } |
|
| 546 | 546 | |
| 547 | - /** |
|
| 548 | - * serialize the schema |
|
| 549 | - * |
|
| 550 | - * @access public |
|
| 551 | - */ |
|
| 552 | - function serializeSchema(){
|
|
| 547 | + /** |
|
| 548 | + * serialize the schema |
|
| 549 | + * |
|
| 550 | + * @access public |
|
| 551 | + */ |
|
| 552 | + function serializeSchema(){
|
|
| 553 | 553 | |
| 554 | - $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion); |
|
| 555 | - $xml = ''; |
|
| 556 | - // imports |
|
| 557 | - if (sizeof($this->imports) > 0) {
|
|
| 558 | - foreach($this->imports as $ns => $list) {
|
|
| 559 | - foreach ($list as $ii) {
|
|
| 560 | - if ($ii['location'] != '') {
|
|
| 561 | - $xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n"; |
|
| 562 | - } else {
|
|
| 563 | - $xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n"; |
|
| 564 | - } |
|
| 565 | - } |
|
| 566 | - } |
|
| 567 | - } |
|
| 568 | - // complex types |
|
| 569 | - foreach($this->complexTypes as $typeName => $attrs){
|
|
| 570 | - $contentStr = ''; |
|
| 571 | - // serialize child elements |
|
| 572 | - if(isset($attrs['elements']) && (count($attrs['elements']) > 0)){
|
|
| 573 | - foreach($attrs['elements'] as $element => $eParts){
|
|
| 574 | - if(isset($eParts['ref'])){
|
|
| 575 | - $contentStr .= " <$schemaPrefix:element ref=\"$element\"/>\n"; |
|
| 576 | - } else {
|
|
| 577 | - $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\""; |
|
| 578 | - foreach ($eParts as $aName => $aValue) {
|
|
| 579 | - // handle, e.g., abstract, default, form, minOccurs, maxOccurs, nillable |
|
| 580 | - if ($aName != 'name' && $aName != 'type') {
|
|
| 581 | - $contentStr .= " $aName=\"$aValue\""; |
|
| 582 | - } |
|
| 583 | - } |
|
| 584 | - $contentStr .= "/>\n"; |
|
| 585 | - } |
|
| 586 | - } |
|
| 587 | - // compositor wraps elements |
|
| 588 | - if (isset($attrs['compositor']) && ($attrs['compositor'] != '')) {
|
|
| 589 | - $contentStr = " <$schemaPrefix:$attrs[compositor]>\n".$contentStr." </$schemaPrefix:$attrs[compositor]>\n"; |
|
| 590 | - } |
|
| 591 | - } |
|
| 592 | - // attributes |
|
| 593 | - if(isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)){
|
|
| 594 | - foreach($attrs['attrs'] as $attr => $aParts){
|
|
| 595 | - $contentStr .= " <$schemaPrefix:attribute"; |
|
| 596 | - foreach ($aParts as $a => $v) {
|
|
| 597 | - if ($a == 'ref' || $a == 'type') {
|
|
| 598 | - $contentStr .= " $a=\"".$this->contractQName($v).'"'; |
|
| 599 | - } elseif ($a == 'http://schemas.xmlsoap.org/wsdl/:arrayType') {
|
|
| 600 | - $this->usedNamespaces['wsdl'] = $this->namespaces['wsdl']; |
|
| 601 | - $contentStr .= ' wsdl:arrayType="'.$this->contractQName($v).'"'; |
|
| 602 | - } else {
|
|
| 603 | - $contentStr .= " $a=\"$v\""; |
|
| 604 | - } |
|
| 605 | - } |
|
| 606 | - $contentStr .= "/>\n"; |
|
| 607 | - } |
|
| 608 | - } |
|
| 609 | - // if restriction |
|
| 610 | - if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != ''){
|
|
| 611 | - $contentStr = " <$schemaPrefix:restriction base=\"".$this->contractQName($attrs['restrictionBase'])."\">\n".$contentStr." </$schemaPrefix:restriction>\n"; |
|
| 612 | - // complex or simple content |
|
| 613 | - if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)){
|
|
| 614 | - $contentStr = " <$schemaPrefix:complexContent>\n".$contentStr." </$schemaPrefix:complexContent>\n"; |
|
| 615 | - } |
|
| 616 | - } |
|
| 617 | - // finalize complex type |
|
| 618 | - if($contentStr != ''){
|
|
| 619 | - $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n".$contentStr." </$schemaPrefix:complexType>\n"; |
|
| 620 | - } else {
|
|
| 621 | - $contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n"; |
|
| 622 | - } |
|
| 623 | - $xml .= $contentStr; |
|
| 624 | - } |
|
| 625 | - // simple types |
|
| 626 | - if(isset($this->simpleTypes) && count($this->simpleTypes) > 0){
|
|
| 627 | - foreach($this->simpleTypes as $typeName => $eParts){
|
|
| 628 | - $xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n <$schemaPrefix:restriction base=\"".$this->contractQName($eParts['type'])."\">\n"; |
|
| 629 | - if (isset($eParts['enumeration'])) {
|
|
| 630 | - foreach ($eParts['enumeration'] as $e) {
|
|
| 631 | - $xml .= " <$schemaPrefix:enumeration value=\"$e\"/>\n"; |
|
| 632 | - } |
|
| 633 | - } |
|
| 634 | - $xml .= " </$schemaPrefix:restriction>\n </$schemaPrefix:simpleType>"; |
|
| 635 | - } |
|
| 636 | - } |
|
| 637 | - // elements |
|
| 638 | - if(isset($this->elements) && count($this->elements) > 0){
|
|
| 639 | - foreach($this->elements as $element => $eParts){
|
|
| 640 | - $xml .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\"/>\n"; |
|
| 641 | - } |
|
| 642 | - } |
|
| 643 | - // attributes |
|
| 644 | - if(isset($this->attributes) && count($this->attributes) > 0){
|
|
| 645 | - foreach($this->attributes as $attr => $aParts){
|
|
| 646 | - $xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"".$this->contractQName($aParts['type'])."\"\n/>"; |
|
| 647 | - } |
|
| 648 | - } |
|
| 649 | - // finish 'er up |
|
| 650 | - $attr = ''; |
|
| 651 | - foreach ($this->schemaInfo as $k => $v) {
|
|
| 652 | - if ($k == 'elementFormDefault' || $k == 'attributeFormDefault') {
|
|
| 653 | - $attr .= " $k=\"$v\""; |
|
| 654 | - } |
|
| 655 | - } |
|
| 656 | - $el = "<$schemaPrefix:schema$attr targetNamespace=\"$this->schemaTargetNamespace\"\n"; |
|
| 657 | - foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
|
|
| 658 | - $el .= " xmlns:$nsp=\"$ns\""; |
|
| 659 | - } |
|
| 660 | - $xml = $el . ">\n".$xml."</$schemaPrefix:schema>\n"; |
|
| 661 | - return $xml; |
|
| 662 | - } |
|
| 554 | + $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion); |
|
| 555 | + $xml = ''; |
|
| 556 | + // imports |
|
| 557 | + if (sizeof($this->imports) > 0) {
|
|
| 558 | + foreach($this->imports as $ns => $list) {
|
|
| 559 | + foreach ($list as $ii) {
|
|
| 560 | + if ($ii['location'] != '') {
|
|
| 561 | + $xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n"; |
|
| 562 | + } else {
|
|
| 563 | + $xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n"; |
|
| 564 | + } |
|
| 565 | + } |
|
| 566 | + } |
|
| 567 | + } |
|
| 568 | + // complex types |
|
| 569 | + foreach($this->complexTypes as $typeName => $attrs){
|
|
| 570 | + $contentStr = ''; |
|
| 571 | + // serialize child elements |
|
| 572 | + if(isset($attrs['elements']) && (count($attrs['elements']) > 0)){
|
|
| 573 | + foreach($attrs['elements'] as $element => $eParts){
|
|
| 574 | + if(isset($eParts['ref'])){
|
|
| 575 | + $contentStr .= " <$schemaPrefix:element ref=\"$element\"/>\n"; |
|
| 576 | + } else {
|
|
| 577 | + $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\""; |
|
| 578 | + foreach ($eParts as $aName => $aValue) {
|
|
| 579 | + // handle, e.g., abstract, default, form, minOccurs, maxOccurs, nillable |
|
| 580 | + if ($aName != 'name' && $aName != 'type') {
|
|
| 581 | + $contentStr .= " $aName=\"$aValue\""; |
|
| 582 | + } |
|
| 583 | + } |
|
| 584 | + $contentStr .= "/>\n"; |
|
| 585 | + } |
|
| 586 | + } |
|
| 587 | + // compositor wraps elements |
|
| 588 | + if (isset($attrs['compositor']) && ($attrs['compositor'] != '')) {
|
|
| 589 | + $contentStr = " <$schemaPrefix:$attrs[compositor]>\n".$contentStr." </$schemaPrefix:$attrs[compositor]>\n"; |
|
| 590 | + } |
|
| 591 | + } |
|
| 592 | + // attributes |
|
| 593 | + if(isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)){
|
|
| 594 | + foreach($attrs['attrs'] as $attr => $aParts){
|
|
| 595 | + $contentStr .= " <$schemaPrefix:attribute"; |
|
| 596 | + foreach ($aParts as $a => $v) {
|
|
| 597 | + if ($a == 'ref' || $a == 'type') {
|
|
| 598 | + $contentStr .= " $a=\"".$this->contractQName($v).'"'; |
|
| 599 | + } elseif ($a == 'http://schemas.xmlsoap.org/wsdl/:arrayType') {
|
|
| 600 | + $this->usedNamespaces['wsdl'] = $this->namespaces['wsdl']; |
|
| 601 | + $contentStr .= ' wsdl:arrayType="'.$this->contractQName($v).'"'; |
|
| 602 | + } else {
|
|
| 603 | + $contentStr .= " $a=\"$v\""; |
|
| 604 | + } |
|
| 605 | + } |
|
| 606 | + $contentStr .= "/>\n"; |
|
| 607 | + } |
|
| 608 | + } |
|
| 609 | + // if restriction |
|
| 610 | + if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != ''){
|
|
| 611 | + $contentStr = " <$schemaPrefix:restriction base=\"".$this->contractQName($attrs['restrictionBase'])."\">\n".$contentStr." </$schemaPrefix:restriction>\n"; |
|
| 612 | + // complex or simple content |
|
| 613 | + if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)){
|
|
| 614 | + $contentStr = " <$schemaPrefix:complexContent>\n".$contentStr." </$schemaPrefix:complexContent>\n"; |
|
| 615 | + } |
|
| 616 | + } |
|
| 617 | + // finalize complex type |
|
| 618 | + if($contentStr != ''){
|
|
| 619 | + $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n".$contentStr." </$schemaPrefix:complexType>\n"; |
|
| 620 | + } else {
|
|
| 621 | + $contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n"; |
|
| 622 | + } |
|
| 623 | + $xml .= $contentStr; |
|
| 624 | + } |
|
| 625 | + // simple types |
|
| 626 | + if(isset($this->simpleTypes) && count($this->simpleTypes) > 0){
|
|
| 627 | + foreach($this->simpleTypes as $typeName => $eParts){
|
|
| 628 | + $xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n <$schemaPrefix:restriction base=\"".$this->contractQName($eParts['type'])."\">\n"; |
|
| 629 | + if (isset($eParts['enumeration'])) {
|
|
| 630 | + foreach ($eParts['enumeration'] as $e) {
|
|
| 631 | + $xml .= " <$schemaPrefix:enumeration value=\"$e\"/>\n"; |
|
| 632 | + } |
|
| 633 | + } |
|
| 634 | + $xml .= " </$schemaPrefix:restriction>\n </$schemaPrefix:simpleType>"; |
|
| 635 | + } |
|
| 636 | + } |
|
| 637 | + // elements |
|
| 638 | + if(isset($this->elements) && count($this->elements) > 0){
|
|
| 639 | + foreach($this->elements as $element => $eParts){
|
|
| 640 | + $xml .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\"/>\n"; |
|
| 641 | + } |
|
| 642 | + } |
|
| 643 | + // attributes |
|
| 644 | + if(isset($this->attributes) && count($this->attributes) > 0){
|
|
| 645 | + foreach($this->attributes as $attr => $aParts){
|
|
| 646 | + $xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"".$this->contractQName($aParts['type'])."\"\n/>"; |
|
| 647 | + } |
|
| 648 | + } |
|
| 649 | + // finish 'er up |
|
| 650 | + $attr = ''; |
|
| 651 | + foreach ($this->schemaInfo as $k => $v) {
|
|
| 652 | + if ($k == 'elementFormDefault' || $k == 'attributeFormDefault') {
|
|
| 653 | + $attr .= " $k=\"$v\""; |
|
| 654 | + } |
|
| 655 | + } |
|
| 656 | + $el = "<$schemaPrefix:schema$attr targetNamespace=\"$this->schemaTargetNamespace\"\n"; |
|
| 657 | + foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
|
|
| 658 | + $el .= " xmlns:$nsp=\"$ns\""; |
|
| 659 | + } |
|
| 660 | + $xml = $el . ">\n".$xml."</$schemaPrefix:schema>\n"; |
|
| 661 | + return $xml; |
|
| 662 | + } |
|
| 663 | 663 | |
| 664 | - /** |
|
| 665 | - * adds debug data to the clas level debug string |
|
| 666 | - * |
|
| 667 | - * @param string $string debug data |
|
| 668 | - * @access private |
|
| 669 | - */ |
|
| 670 | - function xdebug($string){
|
|
| 671 | - $this->debug('<' . $this->schemaTargetNamespace . '> '.$string);
|
|
| 672 | - } |
|
| 664 | + /** |
|
| 665 | + * adds debug data to the clas level debug string |
|
| 666 | + * |
|
| 667 | + * @param string $string debug data |
|
| 668 | + * @access private |
|
| 669 | + */ |
|
| 670 | + function xdebug($string){
|
|
| 671 | + $this->debug('<' . $this->schemaTargetNamespace . '> '.$string);
|
|
| 672 | + } |
|
| 673 | 673 | |
| 674 | 674 | /** |
| 675 | - * get the PHP type of a user defined type in the schema |
|
| 676 | - * PHP type is kind of a misnomer since it actually returns 'struct' for assoc. arrays |
|
| 677 | - * returns false if no type exists, or not w/ the given namespace |
|
| 678 | - * else returns a string that is either a native php type, or 'struct' |
|
| 679 | - * |
|
| 680 | - * @param string $type name of defined type |
|
| 681 | - * @param string $ns namespace of type |
|
| 682 | - * @return mixed |
|
| 683 | - * @access public |
|
| 684 | - * @deprecated |
|
| 685 | - */ |
|
| 686 | - function getPHPType($type,$ns){
|
|
| 687 | - if(isset($this->typemap[$ns][$type])){
|
|
| 688 | - //print "found type '$type' and ns $ns in typemap<br>"; |
|
| 689 | - return $this->typemap[$ns][$type]; |
|
| 690 | - } elseif(isset($this->complexTypes[$type])){
|
|
| 691 | - //print "getting type '$type' and ns $ns from complexTypes array<br>"; |
|
| 692 | - return $this->complexTypes[$type]['phpType']; |
|
| 693 | - } |
|
| 694 | - return false; |
|
| 695 | - } |
|
| 675 | + * get the PHP type of a user defined type in the schema |
|
| 676 | + * PHP type is kind of a misnomer since it actually returns 'struct' for assoc. arrays |
|
| 677 | + * returns false if no type exists, or not w/ the given namespace |
|
| 678 | + * else returns a string that is either a native php type, or 'struct' |
|
| 679 | + * |
|
| 680 | + * @param string $type name of defined type |
|
| 681 | + * @param string $ns namespace of type |
|
| 682 | + * @return mixed |
|
| 683 | + * @access public |
|
| 684 | + * @deprecated |
|
| 685 | + */ |
|
| 686 | + function getPHPType($type,$ns){
|
|
| 687 | + if(isset($this->typemap[$ns][$type])){
|
|
| 688 | + //print "found type '$type' and ns $ns in typemap<br>"; |
|
| 689 | + return $this->typemap[$ns][$type]; |
|
| 690 | + } elseif(isset($this->complexTypes[$type])){
|
|
| 691 | + //print "getting type '$type' and ns $ns from complexTypes array<br>"; |
|
| 692 | + return $this->complexTypes[$type]['phpType']; |
|
| 693 | + } |
|
| 694 | + return false; |
|
| 695 | + } |
|
| 696 | 696 | |
| 697 | - /** |
|
| 698 | - * returns an associative array of information about a given type |
|
| 699 | - * returns false if no type exists by the given name |
|
| 700 | - * |
|
| 701 | - * For a complexType typeDef = array( |
|
| 702 | - * 'restrictionBase' => '', |
|
| 703 | - * 'phpType' => '', |
|
| 704 | - * 'compositor' => '(sequence|all)', |
|
| 705 | - * 'elements' => array(), // refs to elements array |
|
| 706 | - * 'attrs' => array() // refs to attributes array |
|
| 707 | - * ... and so on (see addComplexType) |
|
| 708 | - * ) |
|
| 709 | - * |
|
| 710 | - * For simpleType or element, the array has different keys. |
|
| 711 | - * |
|
| 712 | - * @param string $type |
|
| 713 | - * @return mixed |
|
| 714 | - * @access public |
|
| 715 | - * @see addComplexType |
|
| 716 | - * @see addSimpleType |
|
| 717 | - * @see addElement |
|
| 718 | - */ |
|
| 719 | - function getTypeDef($type){
|
|
| 720 | - //$this->debug("in getTypeDef for type $type");
|
|
| 721 | - if (substr($type, -1) == '^') {
|
|
| 722 | - $is_element = 1; |
|
| 723 | - $type = substr($type, 0, -1); |
|
| 724 | - } else {
|
|
| 725 | - $is_element = 0; |
|
| 726 | - } |
|
| 697 | + /** |
|
| 698 | + * returns an associative array of information about a given type |
|
| 699 | + * returns false if no type exists by the given name |
|
| 700 | + * |
|
| 701 | + * For a complexType typeDef = array( |
|
| 702 | + * 'restrictionBase' => '', |
|
| 703 | + * 'phpType' => '', |
|
| 704 | + * 'compositor' => '(sequence|all)', |
|
| 705 | + * 'elements' => array(), // refs to elements array |
|
| 706 | + * 'attrs' => array() // refs to attributes array |
|
| 707 | + * ... and so on (see addComplexType) |
|
| 708 | + * ) |
|
| 709 | + * |
|
| 710 | + * For simpleType or element, the array has different keys. |
|
| 711 | + * |
|
| 712 | + * @param string $type |
|
| 713 | + * @return mixed |
|
| 714 | + * @access public |
|
| 715 | + * @see addComplexType |
|
| 716 | + * @see addSimpleType |
|
| 717 | + * @see addElement |
|
| 718 | + */ |
|
| 719 | + function getTypeDef($type){
|
|
| 720 | + //$this->debug("in getTypeDef for type $type");
|
|
| 721 | + if (substr($type, -1) == '^') {
|
|
| 722 | + $is_element = 1; |
|
| 723 | + $type = substr($type, 0, -1); |
|
| 724 | + } else {
|
|
| 725 | + $is_element = 0; |
|
| 726 | + } |
|
| 727 | 727 | |
| 728 | - if((! $is_element) && isset($this->complexTypes[$type])){
|
|
| 729 | - $this->xdebug("in getTypeDef, found complexType $type");
|
|
| 730 | - return $this->complexTypes[$type]; |
|
| 731 | - } elseif((! $is_element) && isset($this->simpleTypes[$type])){
|
|
| 732 | - $this->xdebug("in getTypeDef, found simpleType $type");
|
|
| 733 | - if (!isset($this->simpleTypes[$type]['phpType'])) {
|
|
| 734 | - // get info for type to tack onto the simple type |
|
| 735 | - // TODO: can this ever really apply (i.e. what is a simpleType really?) |
|
| 736 | - $uqType = substr($this->simpleTypes[$type]['type'], strrpos($this->simpleTypes[$type]['type'], ':') + 1); |
|
| 737 | - $ns = substr($this->simpleTypes[$type]['type'], 0, strrpos($this->simpleTypes[$type]['type'], ':')); |
|
| 738 | - $etype = $this->getTypeDef($uqType); |
|
| 739 | - if ($etype) {
|
|
| 740 | - $this->xdebug("in getTypeDef, found type for simpleType $type:");
|
|
| 741 | - $this->xdebug($this->varDump($etype)); |
|
| 742 | - if (isset($etype['phpType'])) {
|
|
| 743 | - $this->simpleTypes[$type]['phpType'] = $etype['phpType']; |
|
| 744 | - } |
|
| 745 | - if (isset($etype['elements'])) {
|
|
| 746 | - $this->simpleTypes[$type]['elements'] = $etype['elements']; |
|
| 747 | - } |
|
| 748 | - } |
|
| 749 | - } |
|
| 750 | - return $this->simpleTypes[$type]; |
|
| 751 | - } elseif(isset($this->elements[$type])){
|
|
| 752 | - $this->xdebug("in getTypeDef, found element $type");
|
|
| 753 | - if (!isset($this->elements[$type]['phpType'])) {
|
|
| 754 | - // get info for type to tack onto the element |
|
| 755 | - $uqType = substr($this->elements[$type]['type'], strrpos($this->elements[$type]['type'], ':') + 1); |
|
| 756 | - $ns = substr($this->elements[$type]['type'], 0, strrpos($this->elements[$type]['type'], ':')); |
|
| 757 | - $etype = $this->getTypeDef($uqType); |
|
| 758 | - if ($etype) {
|
|
| 759 | - $this->xdebug("in getTypeDef, found type for element $type:");
|
|
| 760 | - $this->xdebug($this->varDump($etype)); |
|
| 761 | - if (isset($etype['phpType'])) {
|
|
| 762 | - $this->elements[$type]['phpType'] = $etype['phpType']; |
|
| 763 | - } |
|
| 764 | - if (isset($etype['elements'])) {
|
|
| 765 | - $this->elements[$type]['elements'] = $etype['elements']; |
|
| 766 | - } |
|
| 767 | - if (isset($etype['extensionBase'])) {
|
|
| 768 | - $this->elements[$type]['extensionBase'] = $etype['extensionBase']; |
|
| 769 | - } |
|
| 770 | - } elseif ($ns == 'http://www.w3.org/2001/XMLSchema') {
|
|
| 771 | - $this->xdebug("in getTypeDef, element $type is an XSD type");
|
|
| 772 | - $this->elements[$type]['phpType'] = 'scalar'; |
|
| 773 | - } |
|
| 774 | - } |
|
| 775 | - return $this->elements[$type]; |
|
| 776 | - } elseif(isset($this->attributes[$type])){
|
|
| 777 | - $this->xdebug("in getTypeDef, found attribute $type");
|
|
| 778 | - return $this->attributes[$type]; |
|
| 779 | - } elseif (preg_match('/_ContainedType$/', $type)) {
|
|
| 780 | - $this->xdebug("in getTypeDef, have an untyped element $type");
|
|
| 781 | - $typeDef['typeClass'] = 'simpleType'; |
|
| 782 | - $typeDef['phpType'] = 'scalar'; |
|
| 783 | - $typeDef['type'] = 'http://www.w3.org/2001/XMLSchema:string'; |
|
| 784 | - return $typeDef; |
|
| 785 | - } |
|
| 786 | - $this->xdebug("in getTypeDef, did not find $type");
|
|
| 787 | - return false; |
|
| 788 | - } |
|
| 728 | + if((! $is_element) && isset($this->complexTypes[$type])){
|
|
| 729 | + $this->xdebug("in getTypeDef, found complexType $type");
|
|
| 730 | + return $this->complexTypes[$type]; |
|
| 731 | + } elseif((! $is_element) && isset($this->simpleTypes[$type])){
|
|
| 732 | + $this->xdebug("in getTypeDef, found simpleType $type");
|
|
| 733 | + if (!isset($this->simpleTypes[$type]['phpType'])) {
|
|
| 734 | + // get info for type to tack onto the simple type |
|
| 735 | + // TODO: can this ever really apply (i.e. what is a simpleType really?) |
|
| 736 | + $uqType = substr($this->simpleTypes[$type]['type'], strrpos($this->simpleTypes[$type]['type'], ':') + 1); |
|
| 737 | + $ns = substr($this->simpleTypes[$type]['type'], 0, strrpos($this->simpleTypes[$type]['type'], ':')); |
|
| 738 | + $etype = $this->getTypeDef($uqType); |
|
| 739 | + if ($etype) {
|
|
| 740 | + $this->xdebug("in getTypeDef, found type for simpleType $type:");
|
|
| 741 | + $this->xdebug($this->varDump($etype)); |
|
| 742 | + if (isset($etype['phpType'])) {
|
|
| 743 | + $this->simpleTypes[$type]['phpType'] = $etype['phpType']; |
|
| 744 | + } |
|
| 745 | + if (isset($etype['elements'])) {
|
|
| 746 | + $this->simpleTypes[$type]['elements'] = $etype['elements']; |
|
| 747 | + } |
|
| 748 | + } |
|
| 749 | + } |
|
| 750 | + return $this->simpleTypes[$type]; |
|
| 751 | + } elseif(isset($this->elements[$type])){
|
|
| 752 | + $this->xdebug("in getTypeDef, found element $type");
|
|
| 753 | + if (!isset($this->elements[$type]['phpType'])) {
|
|
| 754 | + // get info for type to tack onto the element |
|
| 755 | + $uqType = substr($this->elements[$type]['type'], strrpos($this->elements[$type]['type'], ':') + 1); |
|
| 756 | + $ns = substr($this->elements[$type]['type'], 0, strrpos($this->elements[$type]['type'], ':')); |
|
| 757 | + $etype = $this->getTypeDef($uqType); |
|
| 758 | + if ($etype) {
|
|
| 759 | + $this->xdebug("in getTypeDef, found type for element $type:");
|
|
| 760 | + $this->xdebug($this->varDump($etype)); |
|
| 761 | + if (isset($etype['phpType'])) {
|
|
| 762 | + $this->elements[$type]['phpType'] = $etype['phpType']; |
|
| 763 | + } |
|
| 764 | + if (isset($etype['elements'])) {
|
|
| 765 | + $this->elements[$type]['elements'] = $etype['elements']; |
|
| 766 | + } |
|
| 767 | + if (isset($etype['extensionBase'])) {
|
|
| 768 | + $this->elements[$type]['extensionBase'] = $etype['extensionBase']; |
|
| 769 | + } |
|
| 770 | + } elseif ($ns == 'http://www.w3.org/2001/XMLSchema') {
|
|
| 771 | + $this->xdebug("in getTypeDef, element $type is an XSD type");
|
|
| 772 | + $this->elements[$type]['phpType'] = 'scalar'; |
|
| 773 | + } |
|
| 774 | + } |
|
| 775 | + return $this->elements[$type]; |
|
| 776 | + } elseif(isset($this->attributes[$type])){
|
|
| 777 | + $this->xdebug("in getTypeDef, found attribute $type");
|
|
| 778 | + return $this->attributes[$type]; |
|
| 779 | + } elseif (preg_match('/_ContainedType$/', $type)) {
|
|
| 780 | + $this->xdebug("in getTypeDef, have an untyped element $type");
|
|
| 781 | + $typeDef['typeClass'] = 'simpleType'; |
|
| 782 | + $typeDef['phpType'] = 'scalar'; |
|
| 783 | + $typeDef['type'] = 'http://www.w3.org/2001/XMLSchema:string'; |
|
| 784 | + return $typeDef; |
|
| 785 | + } |
|
| 786 | + $this->xdebug("in getTypeDef, did not find $type");
|
|
| 787 | + return false; |
|
| 788 | + } |
|
| 789 | 789 | |
| 790 | - /** |
|
| 791 | - * returns a sample serialization of a given type, or false if no type by the given name |
|
| 792 | - * |
|
| 793 | - * @param string $type name of type |
|
| 794 | - * @return mixed |
|
| 795 | - * @access public |
|
| 796 | - * @deprecated |
|
| 797 | - */ |
|
| 790 | + /** |
|
| 791 | + * returns a sample serialization of a given type, or false if no type by the given name |
|
| 792 | + * |
|
| 793 | + * @param string $type name of type |
|
| 794 | + * @return mixed |
|
| 795 | + * @access public |
|
| 796 | + * @deprecated |
|
| 797 | + */ |
|
| 798 | 798 | function serializeTypeDef($type){
|
| 799 | - //print "in sTD() for type $type<br>"; |
|
| 800 | - if($typeDef = $this->getTypeDef($type)){
|
|
| 801 | - $str .= '<'.$type; |
|
| 802 | - if(is_array($typeDef['attrs'])){
|
|
| 803 | - foreach($typeDef['attrs'] as $attName => $data){
|
|
| 804 | - $str .= " $attName=\"{type = ".$data['type']."}\"";
|
|
| 805 | - } |
|
| 806 | - } |
|
| 807 | - $str .= " xmlns=\"".$this->schema['targetNamespace']."\""; |
|
| 808 | - if(count($typeDef['elements']) > 0){
|
|
| 809 | - $str .= ">"; |
|
| 810 | - foreach($typeDef['elements'] as $element => $eData){
|
|
| 811 | - $str .= $this->serializeTypeDef($element); |
|
| 812 | - } |
|
| 813 | - $str .= "</$type>"; |
|
| 814 | - } elseif($typeDef['typeClass'] == 'element') {
|
|
| 815 | - $str .= "></$type>"; |
|
| 816 | - } else {
|
|
| 817 | - $str .= "/>"; |
|
| 818 | - } |
|
| 819 | - return $str; |
|
| 820 | - } |
|
| 821 | - return false; |
|
| 799 | + //print "in sTD() for type $type<br>"; |
|
| 800 | + if($typeDef = $this->getTypeDef($type)){
|
|
| 801 | + $str .= '<'.$type; |
|
| 802 | + if(is_array($typeDef['attrs'])){
|
|
| 803 | + foreach($typeDef['attrs'] as $attName => $data){
|
|
| 804 | + $str .= " $attName=\"{type = ".$data['type']."}\"";
|
|
| 805 | + } |
|
| 806 | + } |
|
| 807 | + $str .= " xmlns=\"".$this->schema['targetNamespace']."\""; |
|
| 808 | + if(count($typeDef['elements']) > 0){
|
|
| 809 | + $str .= ">"; |
|
| 810 | + foreach($typeDef['elements'] as $element => $eData){
|
|
| 811 | + $str .= $this->serializeTypeDef($element); |
|
| 812 | + } |
|
| 813 | + $str .= "</$type>"; |
|
| 814 | + } elseif($typeDef['typeClass'] == 'element') {
|
|
| 815 | + $str .= "></$type>"; |
|
| 816 | + } else {
|
|
| 817 | + $str .= "/>"; |
|
| 818 | + } |
|
| 819 | + return $str; |
|
| 820 | + } |
|
| 821 | + return false; |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | /** |
| 825 | - * returns HTML form elements that allow a user |
|
| 826 | - * to enter values for creating an instance of the given type. |
|
| 827 | - * |
|
| 828 | - * @param string $name name for type instance |
|
| 829 | - * @param string $type name of type |
|
| 830 | - * @return string |
|
| 831 | - * @access public |
|
| 832 | - * @deprecated |
|
| 833 | - */ |
|
| 834 | - function typeToForm($name,$type){
|
|
| 835 | - // get typedef |
|
| 836 | - if($typeDef = $this->getTypeDef($type)){
|
|
| 837 | - // if struct |
|
| 838 | - if($typeDef['phpType'] == 'struct'){
|
|
| 839 | - $buffer .= '<table>'; |
|
| 840 | - foreach($typeDef['elements'] as $child => $childDef){
|
|
| 841 | - $buffer .= " |
|
| 825 | + * returns HTML form elements that allow a user |
|
| 826 | + * to enter values for creating an instance of the given type. |
|
| 827 | + * |
|
| 828 | + * @param string $name name for type instance |
|
| 829 | + * @param string $type name of type |
|
| 830 | + * @return string |
|
| 831 | + * @access public |
|
| 832 | + * @deprecated |
|
| 833 | + */ |
|
| 834 | + function typeToForm($name,$type){
|
|
| 835 | + // get typedef |
|
| 836 | + if($typeDef = $this->getTypeDef($type)){
|
|
| 837 | + // if struct |
|
| 838 | + if($typeDef['phpType'] == 'struct'){
|
|
| 839 | + $buffer .= '<table>'; |
|
| 840 | + foreach($typeDef['elements'] as $child => $childDef){
|
|
| 841 | + $buffer .= " |
|
| 842 | 842 | <tr><td align='right'>$childDef[name] (type: ".$this->getLocalPart($childDef['type'])."):</td> |
| 843 | 843 | <td><input type='text' name='parameters[".$name."][$childDef[name]]'></td></tr>"; |
| 844 | - } |
|
| 845 | - $buffer .= '</table>'; |
|
| 846 | - // if array |
|
| 847 | - } elseif($typeDef['phpType'] == 'array'){
|
|
| 848 | - $buffer .= '<table>'; |
|
| 849 | - for($i=0;$i < 3; $i++){
|
|
| 850 | - $buffer .= " |
|
| 844 | + } |
|
| 845 | + $buffer .= '</table>'; |
|
| 846 | + // if array |
|
| 847 | + } elseif($typeDef['phpType'] == 'array'){
|
|
| 848 | + $buffer .= '<table>'; |
|
| 849 | + for($i=0;$i < 3; $i++){
|
|
| 850 | + $buffer .= " |
|
| 851 | 851 | <tr><td align='right'>array item (type: $typeDef[arrayType]):</td> |
| 852 | 852 | <td><input type='text' name='parameters[".$name."][]'></td></tr>"; |
| 853 | - } |
|
| 854 | - $buffer .= '</table>'; |
|
| 855 | - // if scalar |
|
| 856 | - } else {
|
|
| 857 | - $buffer .= "<input type='text' name='parameters[$name]'>"; |
|
| 858 | - } |
|
| 859 | - } else {
|
|
| 860 | - $buffer .= "<input type='text' name='parameters[$name]'>"; |
|
| 861 | - } |
|
| 862 | - return $buffer; |
|
| 863 | - } |
|
| 853 | + } |
|
| 854 | + $buffer .= '</table>'; |
|
| 855 | + // if scalar |
|
| 856 | + } else {
|
|
| 857 | + $buffer .= "<input type='text' name='parameters[$name]'>"; |
|
| 858 | + } |
|
| 859 | + } else {
|
|
| 860 | + $buffer .= "<input type='text' name='parameters[$name]'>"; |
|
| 861 | + } |
|
| 862 | + return $buffer; |
|
| 863 | + } |
|
| 864 | 864 | |
| 865 | - /** |
|
| 866 | - * adds a complex type to the schema |
|
| 867 | - * |
|
| 868 | - * example: array |
|
| 869 | - * |
|
| 870 | - * addType( |
|
| 871 | - * 'ArrayOfstring', |
|
| 872 | - * 'complexType', |
|
| 873 | - * 'array', |
|
| 874 | - * '', |
|
| 875 | - * 'SOAP-ENC:Array', |
|
| 876 | - * array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'),
|
|
| 877 | - * 'xsd:string' |
|
| 878 | - * ); |
|
| 879 | - * |
|
| 880 | - * example: PHP associative array ( SOAP Struct ) |
|
| 881 | - * |
|
| 882 | - * addType( |
|
| 883 | - * 'SOAPStruct', |
|
| 884 | - * 'complexType', |
|
| 885 | - * 'struct', |
|
| 886 | - * 'all', |
|
| 887 | - * array('myVar'=> array('name'=>'myVar','type'=>'string')
|
|
| 888 | - * ); |
|
| 889 | - * |
|
| 890 | - * @param name |
|
| 891 | - * @param typeClass (complexType|simpleType|attribute) |
|
| 892 | - * @param phpType: currently supported are array and struct (php assoc array) |
|
| 893 | - * @param compositor (all|sequence|choice) |
|
| 894 | - * @param restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 895 | - * @param elements = array ( name = array(name=>'',type=>'') ) |
|
| 896 | - * @param attrs = array( |
|
| 897 | - * array( |
|
| 898 | - * 'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType", |
|
| 899 | - * "http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]" |
|
| 900 | - * ) |
|
| 901 | - * ) |
|
| 902 | - * @param arrayType: namespace:name (http://www.w3.org/2001/XMLSchema:string) |
|
| 903 | - * @access public |
|
| 904 | - * @see getTypeDef |
|
| 905 | - */ |
|
| 906 | - function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType=''){
|
|
| 907 | - $this->complexTypes[$name] = array( |
|
| 908 | - 'name' => $name, |
|
| 909 | - 'typeClass' => $typeClass, |
|
| 910 | - 'phpType' => $phpType, |
|
| 911 | - 'compositor'=> $compositor, |
|
| 912 | - 'restrictionBase' => $restrictionBase, |
|
| 913 | - 'elements' => $elements, |
|
| 914 | - 'attrs' => $attrs, |
|
| 915 | - 'arrayType' => $arrayType |
|
| 916 | - ); |
|
| 865 | + /** |
|
| 866 | + * adds a complex type to the schema |
|
| 867 | + * |
|
| 868 | + * example: array |
|
| 869 | + * |
|
| 870 | + * addType( |
|
| 871 | + * 'ArrayOfstring', |
|
| 872 | + * 'complexType', |
|
| 873 | + * 'array', |
|
| 874 | + * '', |
|
| 875 | + * 'SOAP-ENC:Array', |
|
| 876 | + * array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'),
|
|
| 877 | + * 'xsd:string' |
|
| 878 | + * ); |
|
| 879 | + * |
|
| 880 | + * example: PHP associative array ( SOAP Struct ) |
|
| 881 | + * |
|
| 882 | + * addType( |
|
| 883 | + * 'SOAPStruct', |
|
| 884 | + * 'complexType', |
|
| 885 | + * 'struct', |
|
| 886 | + * 'all', |
|
| 887 | + * array('myVar'=> array('name'=>'myVar','type'=>'string')
|
|
| 888 | + * ); |
|
| 889 | + * |
|
| 890 | + * @param name |
|
| 891 | + * @param typeClass (complexType|simpleType|attribute) |
|
| 892 | + * @param phpType: currently supported are array and struct (php assoc array) |
|
| 893 | + * @param compositor (all|sequence|choice) |
|
| 894 | + * @param restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 895 | + * @param elements = array ( name = array(name=>'',type=>'') ) |
|
| 896 | + * @param attrs = array( |
|
| 897 | + * array( |
|
| 898 | + * 'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType", |
|
| 899 | + * "http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]" |
|
| 900 | + * ) |
|
| 901 | + * ) |
|
| 902 | + * @param arrayType: namespace:name (http://www.w3.org/2001/XMLSchema:string) |
|
| 903 | + * @access public |
|
| 904 | + * @see getTypeDef |
|
| 905 | + */ |
|
| 906 | + function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType=''){
|
|
| 907 | + $this->complexTypes[$name] = array( |
|
| 908 | + 'name' => $name, |
|
| 909 | + 'typeClass' => $typeClass, |
|
| 910 | + 'phpType' => $phpType, |
|
| 911 | + 'compositor'=> $compositor, |
|
| 912 | + 'restrictionBase' => $restrictionBase, |
|
| 913 | + 'elements' => $elements, |
|
| 914 | + 'attrs' => $attrs, |
|
| 915 | + 'arrayType' => $arrayType |
|
| 916 | + ); |
|
| 917 | 917 | |
| 918 | - $this->xdebug("addComplexType $name:");
|
|
| 919 | - $this->appendDebug($this->varDump($this->complexTypes[$name])); |
|
| 920 | - } |
|
| 918 | + $this->xdebug("addComplexType $name:");
|
|
| 919 | + $this->appendDebug($this->varDump($this->complexTypes[$name])); |
|
| 920 | + } |
|
| 921 | 921 | |
| 922 | - /** |
|
| 923 | - * adds a simple type to the schema |
|
| 924 | - * |
|
| 925 | - * @param string $name |
|
| 926 | - * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 927 | - * @param string $typeClass (should always be simpleType) |
|
| 928 | - * @param string $phpType (should always be scalar) |
|
| 929 | - * @param array $enumeration array of values |
|
| 930 | - * @access public |
|
| 931 | - * @see nusoap_xmlschema |
|
| 932 | - * @see getTypeDef |
|
| 933 | - */ |
|
| 934 | - function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
|
|
| 935 | - $this->simpleTypes[$name] = array( |
|
| 936 | - 'name' => $name, |
|
| 937 | - 'typeClass' => $typeClass, |
|
| 938 | - 'phpType' => $phpType, |
|
| 939 | - 'type' => $restrictionBase, |
|
| 940 | - 'enumeration' => $enumeration |
|
| 941 | - ); |
|
| 922 | + /** |
|
| 923 | + * adds a simple type to the schema |
|
| 924 | + * |
|
| 925 | + * @param string $name |
|
| 926 | + * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 927 | + * @param string $typeClass (should always be simpleType) |
|
| 928 | + * @param string $phpType (should always be scalar) |
|
| 929 | + * @param array $enumeration array of values |
|
| 930 | + * @access public |
|
| 931 | + * @see nusoap_xmlschema |
|
| 932 | + * @see getTypeDef |
|
| 933 | + */ |
|
| 934 | + function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
|
|
| 935 | + $this->simpleTypes[$name] = array( |
|
| 936 | + 'name' => $name, |
|
| 937 | + 'typeClass' => $typeClass, |
|
| 938 | + 'phpType' => $phpType, |
|
| 939 | + 'type' => $restrictionBase, |
|
| 940 | + 'enumeration' => $enumeration |
|
| 941 | + ); |
|
| 942 | 942 | |
| 943 | - $this->xdebug("addSimpleType $name:");
|
|
| 944 | - $this->appendDebug($this->varDump($this->simpleTypes[$name])); |
|
| 945 | - } |
|
| 943 | + $this->xdebug("addSimpleType $name:");
|
|
| 944 | + $this->appendDebug($this->varDump($this->simpleTypes[$name])); |
|
| 945 | + } |
|
| 946 | 946 | |
| 947 | - /** |
|
| 948 | - * adds an element to the schema |
|
| 949 | - * |
|
| 950 | - * @param array $attrs attributes that must include name and type |
|
| 951 | - * @see nusoap_xmlschema |
|
| 952 | - * @access public |
|
| 953 | - */ |
|
| 954 | - function addElement($attrs) {
|
|
| 955 | - if (! $this->getPrefix($attrs['type'])) {
|
|
| 956 | - $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type']; |
|
| 957 | - } |
|
| 958 | - $this->elements[ $attrs['name'] ] = $attrs; |
|
| 959 | - $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; |
|
| 947 | + /** |
|
| 948 | + * adds an element to the schema |
|
| 949 | + * |
|
| 950 | + * @param array $attrs attributes that must include name and type |
|
| 951 | + * @see nusoap_xmlschema |
|
| 952 | + * @access public |
|
| 953 | + */ |
|
| 954 | + function addElement($attrs) {
|
|
| 955 | + if (! $this->getPrefix($attrs['type'])) {
|
|
| 956 | + $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type']; |
|
| 957 | + } |
|
| 958 | + $this->elements[ $attrs['name'] ] = $attrs; |
|
| 959 | + $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; |
|
| 960 | 960 | |
| 961 | - $this->xdebug("addElement " . $attrs['name']);
|
|
| 962 | - $this->appendDebug($this->varDump($this->elements[ $attrs['name'] ])); |
|
| 963 | - } |
|
| 961 | + $this->xdebug("addElement " . $attrs['name']);
|
|
| 962 | + $this->appendDebug($this->varDump($this->elements[ $attrs['name'] ])); |
|
| 963 | + } |
|
| 964 | 964 | } |
| 965 | 965 | |
| 966 | 966 | /** |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | * @version $Id: class.xmlschema.php,v 1.53 2010/04/26 20:15:08 snichol Exp $ |
| 13 | 13 | * @access public |
| 14 | 14 | */ |
| 15 | -class nusoap_xmlschema extends nusoap_base {
|
|
| 15 | +class nusoap_xmlschema extends nusoap_base {
|
|
| 16 | 16 | |
| 17 | 17 | // files |
| 18 | 18 | var $schema = ''; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @param string $namespaces namespaces defined in enclosing XML |
| 52 | 52 | * @access public |
| 53 | 53 | */ |
| 54 | - function nusoap_xmlschema($schema='',$xml='',$namespaces=array()){
|
|
| 54 | + function nusoap_xmlschema($schema = '', $xml = '', $namespaces = array()) {
|
|
| 55 | 55 | parent::nusoap_base(); |
| 56 | 56 | $this->debug('nusoap_xmlschema class instantiated, inside constructor');
|
| 57 | 57 | // files |
@@ -63,13 +63,13 @@ discard block |
||
| 63 | 63 | $this->namespaces = array_merge($this->namespaces, $namespaces); |
| 64 | 64 | |
| 65 | 65 | // parse schema file |
| 66 | - if($schema != ''){
|
|
| 66 | + if ($schema != '') {
|
|
| 67 | 67 | $this->debug('initial schema file: '.$schema);
|
| 68 | 68 | $this->parseFile($schema, 'schema'); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // parse xml file |
| 72 | - if($xml != ''){
|
|
| 72 | + if ($xml != '') {
|
|
| 73 | 73 | $this->debug('initial xml file: '.$xml);
|
| 74 | 74 | $this->parseFile($xml, 'xml'); |
| 75 | 75 | } |
@@ -84,18 +84,18 @@ discard block |
||
| 84 | 84 | * @return boolean |
| 85 | 85 | * @access public |
| 86 | 86 | */ |
| 87 | - function parseFile($xml,$type){
|
|
| 87 | + function parseFile($xml, $type) {
|
|
| 88 | 88 | // parse xml file |
| 89 | - if($xml != ""){
|
|
| 90 | - $xmlStr = @join("",@file($xml));
|
|
| 91 | - if($xmlStr == ""){
|
|
| 89 | + if ($xml != "") {
|
|
| 90 | + $xmlStr = @join("", @file($xml));
|
|
| 91 | + if ($xmlStr == "") {
|
|
| 92 | 92 | $msg = 'Error reading XML from '.$xml; |
| 93 | 93 | $this->setError($msg); |
| 94 | 94 | $this->debug($msg); |
| 95 | 95 | return false; |
| 96 | 96 | } else {
|
| 97 | 97 | $this->debug("parsing $xml");
|
| 98 | - $this->parseString($xmlStr,$type); |
|
| 98 | + $this->parseString($xmlStr, $type); |
|
| 99 | 99 | $this->debug("done parsing $xml");
|
| 100 | 100 | return true; |
| 101 | 101 | } |
@@ -110,9 +110,9 @@ discard block |
||
| 110 | 110 | * @param string $type (schema|xml) |
| 111 | 111 | * @access private |
| 112 | 112 | */ |
| 113 | - function parseString($xml,$type){
|
|
| 113 | + function parseString($xml, $type) {
|
|
| 114 | 114 | // parse xml string |
| 115 | - if($xml != ""){
|
|
| 115 | + if ($xml != "") {
|
|
| 116 | 116 | |
| 117 | 117 | // Create an XML parser. |
| 118 | 118 | $this->parser = xml_parser_create(); |
@@ -123,28 +123,28 @@ discard block |
||
| 123 | 123 | xml_set_object($this->parser, $this); |
| 124 | 124 | |
| 125 | 125 | // Set the element handlers for the parser. |
| 126 | - if($type == "schema"){
|
|
| 127 | - xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement'); |
|
| 128 | - xml_set_character_data_handler($this->parser,'schemaCharacterData'); |
|
| 129 | - } elseif($type == "xml"){
|
|
| 130 | - xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement'); |
|
| 131 | - xml_set_character_data_handler($this->parser,'xmlCharacterData'); |
|
| 126 | + if ($type == "schema") {
|
|
| 127 | + xml_set_element_handler($this->parser, 'schemaStartElement', 'schemaEndElement'); |
|
| 128 | + xml_set_character_data_handler($this->parser, 'schemaCharacterData'); |
|
| 129 | + } elseif ($type == "xml") {
|
|
| 130 | + xml_set_element_handler($this->parser, 'xmlStartElement', 'xmlEndElement'); |
|
| 131 | + xml_set_character_data_handler($this->parser, 'xmlCharacterData'); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | // Parse the XML file. |
| 135 | - if(!xml_parse($this->parser,$xml,true)){
|
|
| 135 | + if (!xml_parse($this->parser, $xml, true)) {
|
|
| 136 | 136 | // Display an error message. |
| 137 | 137 | $errstr = sprintf('XML error parsing XML schema on line %d: %s',
|
| 138 | 138 | xml_get_current_line_number($this->parser), |
| 139 | 139 | xml_error_string(xml_get_error_code($this->parser)) |
| 140 | 140 | ); |
| 141 | 141 | $this->debug($errstr); |
| 142 | - $this->debug("XML payload:\n" . $xml);
|
|
| 142 | + $this->debug("XML payload:\n".$xml);
|
|
| 143 | 143 | $this->setError($errstr); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | xml_parser_free($this->parser); |
| 147 | - } else{
|
|
| 147 | + } else {
|
|
| 148 | 148 | $this->debug('no xml passed to parseString()!!');
|
| 149 | 149 | $this->setError('no xml passed to parseString()!!');
|
| 150 | 150 | } |
@@ -160,9 +160,9 @@ discard block |
||
| 160 | 160 | function CreateTypeName($ename) {
|
| 161 | 161 | $scope = ''; |
| 162 | 162 | for ($i = 0; $i < count($this->complexTypeStack); $i++) {
|
| 163 | - $scope .= $this->complexTypeStack[$i] . '_'; |
|
| 163 | + $scope .= $this->complexTypeStack[$i].'_'; |
|
| 164 | 164 | } |
| 165 | - return $scope . $ename . '_ContainedType'; |
|
| 165 | + return $scope.$ename.'_ContainedType'; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | // get element prefix |
| 191 | - if($prefix = $this->getPrefix($name)){
|
|
| 191 | + if ($prefix = $this->getPrefix($name)) {
|
|
| 192 | 192 | // get unqualified name |
| 193 | 193 | $name = $this->getLocalPart($name); |
| 194 | 194 | } else {
|
@@ -196,31 +196,31 @@ discard block |
||
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | // loop thru attributes, expanding, and registering namespace declarations |
| 199 | - if(count($attrs) > 0){
|
|
| 200 | - foreach($attrs as $k => $v){
|
|
| 199 | + if (count($attrs) > 0) {
|
|
| 200 | + foreach ($attrs as $k => $v) {
|
|
| 201 | 201 | // if ns declarations, add to class level array of valid namespaces |
| 202 | - if(preg_match('/^xmlns/',$k)){
|
|
| 202 | + if (preg_match('/^xmlns/', $k)) {
|
|
| 203 | 203 | //$this->xdebug("$k: $v");
|
| 204 | 204 | //$this->xdebug('ns_prefix: '.$this->getPrefix($k));
|
| 205 | - if($ns_prefix = substr(strrchr($k,':'),1)){
|
|
| 205 | + if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
|
|
| 206 | 206 | //$this->xdebug("Add namespace[$ns_prefix] = $v");
|
| 207 | 207 | $this->namespaces[$ns_prefix] = $v; |
| 208 | 208 | } else {
|
| 209 | 209 | $this->defaultNamespace[$pos] = $v; |
| 210 | - if (! $this->getPrefixFromNamespace($v)) {
|
|
| 211 | - $this->namespaces['ns'.(count($this->namespaces)+1)] = $v; |
|
| 210 | + if (!$this->getPrefixFromNamespace($v)) {
|
|
| 211 | + $this->namespaces['ns'.(count($this->namespaces) + 1)] = $v; |
|
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | - if($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema'){
|
|
| 214 | + if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
|
|
| 215 | 215 | $this->XMLSchemaVersion = $v; |
| 216 | 216 | $this->namespaces['xsi'] = $v.'-instance'; |
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | - foreach($attrs as $k => $v){
|
|
| 220 | + foreach ($attrs as $k => $v) {
|
|
| 221 | 221 | // expand each attribute |
| 222 | - $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 223 | - $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 222 | + $k = strpos($k, ':') ? $this->expandQname($k) : $k; |
|
| 223 | + $v = strpos($v, ':') ? $this->expandQname($v) : $v; |
|
| 224 | 224 | $eAttrs[$k] = $v; |
| 225 | 225 | } |
| 226 | 226 | $attrs = $eAttrs; |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | $attrs = array(); |
| 229 | 229 | } |
| 230 | 230 | // find status, register data |
| 231 | - switch($name){
|
|
| 231 | + switch ($name) {
|
|
| 232 | 232 | case 'all': // (optional) compositor content for a complexType |
| 233 | 233 | case 'choice': |
| 234 | 234 | case 'group': |
@@ -253,41 +253,41 @@ discard block |
||
| 253 | 253 | // no namespace in arrayType attribute value... |
| 254 | 254 | if ($this->defaultNamespace[$pos]) {
|
| 255 | 255 | // ...so use the default |
| 256 | - $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 256 | + $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos].':'.$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 257 | 257 | } |
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | - if(isset($attrs['name'])){
|
|
| 260 | + if (isset($attrs['name'])) {
|
|
| 261 | 261 | $this->attributes[$attrs['name']] = $attrs; |
| 262 | 262 | $aname = $attrs['name']; |
| 263 | - } elseif(isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){
|
|
| 263 | + } elseif (isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType') {
|
|
| 264 | 264 | if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
|
| 265 | 265 | $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
| 266 | 266 | } else {
|
| 267 | 267 | $aname = ''; |
| 268 | 268 | } |
| 269 | - } elseif(isset($attrs['ref'])){
|
|
| 269 | + } elseif (isset($attrs['ref'])) {
|
|
| 270 | 270 | $aname = $attrs['ref']; |
| 271 | 271 | $this->attributes[$attrs['ref']] = $attrs; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if($this->currentComplexType){ // This should *always* be
|
|
| 274 | + if ($this->currentComplexType) { // This should *always* be
|
|
| 275 | 275 | $this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs; |
| 276 | 276 | } |
| 277 | 277 | // arrayType attribute |
| 278 | - if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType'){
|
|
| 278 | + if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType') {
|
|
| 279 | 279 | $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
| 280 | 280 | $prefix = $this->getPrefix($aname); |
| 281 | - if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])){
|
|
| 281 | + if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
|
|
| 282 | 282 | $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
| 283 | 283 | } else {
|
| 284 | 284 | $v = ''; |
| 285 | 285 | } |
| 286 | - if(strpos($v,'[,]')){
|
|
| 286 | + if (strpos($v, '[,]')) {
|
|
| 287 | 287 | $this->complexTypes[$this->currentComplexType]['multidimensional'] = true; |
| 288 | 288 | } |
| 289 | - $v = substr($v,0,strpos($v,'[')); // clip the [] |
|
| 290 | - if(!strpos($v,':') && isset($this->typemap[$this->XMLSchemaVersion][$v])){
|
|
| 289 | + $v = substr($v, 0, strpos($v, '[')); // clip the [] |
|
| 290 | + if (!strpos($v, ':') && isset($this->typemap[$this->XMLSchemaVersion][$v])) {
|
|
| 291 | 291 | $v = $this->XMLSchemaVersion.':'.$v; |
| 292 | 292 | } |
| 293 | 293 | $this->complexTypes[$this->currentComplexType]['arrayType'] = $v; |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | break; |
| 299 | 299 | case 'complexType': |
| 300 | 300 | array_push($this->complexTypeStack, $this->currentComplexType); |
| 301 | - if(isset($attrs['name'])){
|
|
| 301 | + if (isset($attrs['name'])) {
|
|
| 302 | 302 | // TODO: what is the scope of named complexTypes that appear |
| 303 | 303 | // nested within other c complexTypes? |
| 304 | 304 | $this->xdebug('processing named complexType '.$attrs['name']);
|
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | // minOccurs="0" maxOccurs="unbounded" /> |
| 314 | 314 | // </sequence> |
| 315 | 315 | // </complexType> |
| 316 | - if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
|
|
| 316 | + if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) {
|
|
| 317 | 317 | $this->xdebug('complexType is unusual array');
|
| 318 | 318 | $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
| 319 | 319 | } else {
|
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | } |
| 322 | 322 | } else {
|
| 323 | 323 | $name = $this->CreateTypeName($this->currentElement); |
| 324 | - $this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name);
|
|
| 324 | + $this->xdebug('processing unnamed complexType for element '.$this->currentElement.' named '.$name);
|
|
| 325 | 325 | $this->currentComplexType = $name; |
| 326 | 326 | //$this->currentElement = false; |
| 327 | 327 | $this->complexTypes[$this->currentComplexType] = $attrs; |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | // minOccurs="0" maxOccurs="unbounded" /> |
| 334 | 334 | // </sequence> |
| 335 | 335 | // </complexType> |
| 336 | - if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
|
|
| 336 | + if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) {
|
|
| 337 | 337 | $this->xdebug('complexType is unusual array');
|
| 338 | 338 | $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
| 339 | 339 | } else {
|
@@ -352,12 +352,12 @@ discard block |
||
| 352 | 352 | $attrs['form'] = 'qualified'; |
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | - if(isset($attrs['type'])){
|
|
| 355 | + if (isset($attrs['type'])) {
|
|
| 356 | 356 | $this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']);
|
| 357 | - if (! $this->getPrefix($attrs['type'])) {
|
|
| 357 | + if (!$this->getPrefix($attrs['type'])) {
|
|
| 358 | 358 | if ($this->defaultNamespace[$pos]) {
|
| 359 | - $attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type']; |
|
| 360 | - $this->xdebug('used default namespace to make type ' . $attrs['type']);
|
|
| 359 | + $attrs['type'] = $this->defaultNamespace[$pos].':'.$attrs['type']; |
|
| 360 | + $this->xdebug('used default namespace to make type '.$attrs['type']);
|
|
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | 363 | // This is for constructs like |
@@ -368,20 +368,20 @@ discard block |
||
| 368 | 368 | // </sequence> |
| 369 | 369 | // </complexType> |
| 370 | 370 | if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') {
|
| 371 | - $this->xdebug('arrayType for unusual array is ' . $attrs['type']);
|
|
| 371 | + $this->xdebug('arrayType for unusual array is '.$attrs['type']);
|
|
| 372 | 372 | $this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type']; |
| 373 | 373 | } |
| 374 | 374 | $this->currentElement = $attrs['name']; |
| 375 | 375 | $ename = $attrs['name']; |
| 376 | - } elseif(isset($attrs['ref'])){
|
|
| 376 | + } elseif (isset($attrs['ref'])) {
|
|
| 377 | 377 | $this->xdebug("processing element as ref to ".$attrs['ref']);
|
| 378 | 378 | $this->currentElement = "ref to ".$attrs['ref']; |
| 379 | 379 | $ename = $this->getLocalPart($attrs['ref']); |
| 380 | 380 | } else {
|
| 381 | - $type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']); |
|
| 382 | - $this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type);
|
|
| 381 | + $type = $this->CreateTypeName($this->currentComplexType.'_'.$attrs['name']); |
|
| 382 | + $this->xdebug("processing untyped element ".$attrs['name'].' type '.$type);
|
|
| 383 | 383 | $this->currentElement = $attrs['name']; |
| 384 | - $attrs['type'] = $this->schemaTargetNamespace . ':' . $type; |
|
| 384 | + $attrs['type'] = $this->schemaTargetNamespace.':'.$type; |
|
| 385 | 385 | $ename = $attrs['name']; |
| 386 | 386 | } |
| 387 | 387 | if (isset($ename) && $this->currentComplexType) {
|
@@ -389,12 +389,12 @@ discard block |
||
| 389 | 389 | $this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs; |
| 390 | 390 | } elseif (!isset($attrs['ref'])) {
|
| 391 | 391 | $this->xdebug("add element $ename to elements array");
|
| 392 | - $this->elements[ $attrs['name'] ] = $attrs; |
|
| 393 | - $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; |
|
| 392 | + $this->elements[$attrs['name']] = $attrs; |
|
| 393 | + $this->elements[$attrs['name']]['typeClass'] = 'element'; |
|
| 394 | 394 | } |
| 395 | 395 | break; |
| 396 | 396 | case 'enumeration': // restriction value list member |
| 397 | - $this->xdebug('enumeration ' . $attrs['value']);
|
|
| 397 | + $this->xdebug('enumeration '.$attrs['value']);
|
|
| 398 | 398 | if ($this->currentSimpleType) {
|
| 399 | 399 | $this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value']; |
| 400 | 400 | } elseif ($this->currentComplexType) {
|
@@ -402,11 +402,11 @@ discard block |
||
| 402 | 402 | } |
| 403 | 403 | break; |
| 404 | 404 | case 'extension': // simpleContent or complexContent type extension |
| 405 | - $this->xdebug('extension ' . $attrs['base']);
|
|
| 405 | + $this->xdebug('extension '.$attrs['base']);
|
|
| 406 | 406 | if ($this->currentComplexType) {
|
| 407 | 407 | $ns = $this->getPrefix($attrs['base']); |
| 408 | 408 | if ($ns == '') {
|
| 409 | - $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base']; |
|
| 409 | + $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace.':'.$attrs['base']; |
|
| 410 | 410 | } else {
|
| 411 | 411 | $this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base']; |
| 412 | 412 | } |
@@ -416,19 +416,19 @@ discard block |
||
| 416 | 416 | break; |
| 417 | 417 | case 'import': |
| 418 | 418 | if (isset($attrs['schemaLocation'])) {
|
| 419 | - $this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
|
|
| 419 | + $this->xdebug('import namespace '.$attrs['namespace'].' from '.$attrs['schemaLocation']);
|
|
| 420 | 420 | $this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
|
| 421 | 421 | } else {
|
| 422 | - $this->xdebug('import namespace ' . $attrs['namespace']);
|
|
| 422 | + $this->xdebug('import namespace '.$attrs['namespace']);
|
|
| 423 | 423 | $this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
|
| 424 | - if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
|
|
| 425 | - $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace']; |
|
| 424 | + if (!$this->getPrefixFromNamespace($attrs['namespace'])) {
|
|
| 425 | + $this->namespaces['ns'.(count($this->namespaces) + 1)] = $attrs['namespace']; |
|
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | break; |
| 429 | 429 | case 'include': |
| 430 | 430 | if (isset($attrs['schemaLocation'])) {
|
| 431 | - $this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']);
|
|
| 431 | + $this->xdebug('include into namespace '.$this->schemaTargetNamespace.' from '.$attrs['schemaLocation']);
|
|
| 432 | 432 | $this->imports[$this->schemaTargetNamespace][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
|
| 433 | 433 | } else {
|
| 434 | 434 | $this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute');
|
@@ -438,12 +438,12 @@ discard block |
||
| 438 | 438 | $this->xdebug("do nothing for element $name");
|
| 439 | 439 | break; |
| 440 | 440 | case 'restriction': // simpleType, simpleContent or complexContent value restriction |
| 441 | - $this->xdebug('restriction ' . $attrs['base']);
|
|
| 442 | - if($this->currentSimpleType){
|
|
| 441 | + $this->xdebug('restriction '.$attrs['base']);
|
|
| 442 | + if ($this->currentSimpleType) {
|
|
| 443 | 443 | $this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base']; |
| 444 | - } elseif($this->currentComplexType){
|
|
| 444 | + } elseif ($this->currentComplexType) {
|
|
| 445 | 445 | $this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base']; |
| 446 | - if(strstr($attrs['base'],':') == ':Array'){
|
|
| 446 | + if (strstr($attrs['base'], ':') == ':Array') {
|
|
| 447 | 447 | $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
| 448 | 448 | } |
| 449 | 449 | } |
@@ -470,15 +470,15 @@ discard block |
||
| 470 | 470 | break; |
| 471 | 471 | case 'simpleType': |
| 472 | 472 | array_push($this->simpleTypeStack, $this->currentSimpleType); |
| 473 | - if(isset($attrs['name'])){
|
|
| 474 | - $this->xdebug("processing simpleType for name " . $attrs['name']);
|
|
| 473 | + if (isset($attrs['name'])) {
|
|
| 474 | + $this->xdebug("processing simpleType for name ".$attrs['name']);
|
|
| 475 | 475 | $this->currentSimpleType = $attrs['name']; |
| 476 | - $this->simpleTypes[ $attrs['name'] ] = $attrs; |
|
| 477 | - $this->simpleTypes[ $attrs['name'] ]['typeClass'] = 'simpleType'; |
|
| 478 | - $this->simpleTypes[ $attrs['name'] ]['phpType'] = 'scalar'; |
|
| 476 | + $this->simpleTypes[$attrs['name']] = $attrs; |
|
| 477 | + $this->simpleTypes[$attrs['name']]['typeClass'] = 'simpleType'; |
|
| 478 | + $this->simpleTypes[$attrs['name']]['phpType'] = 'scalar'; |
|
| 479 | 479 | } else {
|
| 480 | - $name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement); |
|
| 481 | - $this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $name);
|
|
| 480 | + $name = $this->CreateTypeName($this->currentComplexType.'_'.$this->currentElement); |
|
| 481 | + $this->xdebug('processing unnamed simpleType for element '.$this->currentElement.' named '.$name);
|
|
| 482 | 482 | $this->currentSimpleType = $name; |
| 483 | 483 | //$this->currentElement = false; |
| 484 | 484 | $this->simpleTypes[$this->currentSimpleType] = $attrs; |
@@ -504,29 +504,29 @@ discard block |
||
| 504 | 504 | // bring depth down a notch |
| 505 | 505 | $this->depth--; |
| 506 | 506 | // position of current element is equal to the last value left in depth_array for my depth |
| 507 | - if(isset($this->depth_array[$this->depth])){
|
|
| 507 | + if (isset($this->depth_array[$this->depth])) {
|
|
| 508 | 508 | $pos = $this->depth_array[$this->depth]; |
| 509 | 509 | } |
| 510 | 510 | // get element prefix |
| 511 | - if ($prefix = $this->getPrefix($name)){
|
|
| 511 | + if ($prefix = $this->getPrefix($name)) {
|
|
| 512 | 512 | // get unqualified name |
| 513 | 513 | $name = $this->getLocalPart($name); |
| 514 | 514 | } else {
|
| 515 | 515 | $prefix = ''; |
| 516 | 516 | } |
| 517 | 517 | // move on... |
| 518 | - if($name == 'complexType'){
|
|
| 519 | - $this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType : '(unknown)'));
|
|
| 518 | + if ($name == 'complexType') {
|
|
| 519 | + $this->xdebug('done processing complexType '.($this->currentComplexType ? $this->currentComplexType : '(unknown)'));
|
|
| 520 | 520 | $this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType])); |
| 521 | 521 | $this->currentComplexType = array_pop($this->complexTypeStack); |
| 522 | 522 | //$this->currentElement = false; |
| 523 | 523 | } |
| 524 | - if($name == 'element'){
|
|
| 525 | - $this->xdebug('done processing element ' . ($this->currentElement ? $this->currentElement : '(unknown)'));
|
|
| 524 | + if ($name == 'element') {
|
|
| 525 | + $this->xdebug('done processing element '.($this->currentElement ? $this->currentElement : '(unknown)'));
|
|
| 526 | 526 | $this->currentElement = array_pop($this->elementStack); |
| 527 | 527 | } |
| 528 | - if($name == 'simpleType'){
|
|
| 529 | - $this->xdebug('done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType : '(unknown)'));
|
|
| 528 | + if ($name == 'simpleType') {
|
|
| 529 | + $this->xdebug('done processing simpleType '.($this->currentSimpleType ? $this->currentSimpleType : '(unknown)'));
|
|
| 530 | 530 | $this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType])); |
| 531 | 531 | $this->currentSimpleType = array_pop($this->simpleTypeStack); |
| 532 | 532 | } |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | * @param string $data element content |
| 540 | 540 | * @access private |
| 541 | 541 | */ |
| 542 | - function schemaCharacterData($parser, $data){
|
|
| 542 | + function schemaCharacterData($parser, $data) {
|
|
| 543 | 543 | $pos = $this->depth_array[$this->depth - 1]; |
| 544 | 544 | $this->message[$pos]['cdata'] .= $data; |
| 545 | 545 | } |
@@ -549,32 +549,32 @@ discard block |
||
| 549 | 549 | * |
| 550 | 550 | * @access public |
| 551 | 551 | */ |
| 552 | - function serializeSchema(){
|
|
| 552 | + function serializeSchema() {
|
|
| 553 | 553 | |
| 554 | 554 | $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion); |
| 555 | 555 | $xml = ''; |
| 556 | 556 | // imports |
| 557 | 557 | if (sizeof($this->imports) > 0) {
|
| 558 | - foreach($this->imports as $ns => $list) {
|
|
| 558 | + foreach ($this->imports as $ns => $list) {
|
|
| 559 | 559 | foreach ($list as $ii) {
|
| 560 | 560 | if ($ii['location'] != '') {
|
| 561 | - $xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n"; |
|
| 561 | + $xml .= " <$schemaPrefix:import location=\"".$ii['location'].'" namespace="'.$ns."\" />\n"; |
|
| 562 | 562 | } else {
|
| 563 | - $xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n"; |
|
| 563 | + $xml .= " <$schemaPrefix:import namespace=\"".$ns."\" />\n"; |
|
| 564 | 564 | } |
| 565 | 565 | } |
| 566 | 566 | } |
| 567 | 567 | } |
| 568 | 568 | // complex types |
| 569 | - foreach($this->complexTypes as $typeName => $attrs){
|
|
| 569 | + foreach ($this->complexTypes as $typeName => $attrs) {
|
|
| 570 | 570 | $contentStr = ''; |
| 571 | 571 | // serialize child elements |
| 572 | - if(isset($attrs['elements']) && (count($attrs['elements']) > 0)){
|
|
| 573 | - foreach($attrs['elements'] as $element => $eParts){
|
|
| 574 | - if(isset($eParts['ref'])){
|
|
| 572 | + if (isset($attrs['elements']) && (count($attrs['elements']) > 0)) {
|
|
| 573 | + foreach ($attrs['elements'] as $element => $eParts) {
|
|
| 574 | + if (isset($eParts['ref'])) {
|
|
| 575 | 575 | $contentStr .= " <$schemaPrefix:element ref=\"$element\"/>\n"; |
| 576 | 576 | } else {
|
| 577 | - $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\""; |
|
| 577 | + $contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\""; |
|
| 578 | 578 | foreach ($eParts as $aName => $aValue) {
|
| 579 | 579 | // handle, e.g., abstract, default, form, minOccurs, maxOccurs, nillable |
| 580 | 580 | if ($aName != 'name' && $aName != 'type') {
|
@@ -590,8 +590,8 @@ discard block |
||
| 590 | 590 | } |
| 591 | 591 | } |
| 592 | 592 | // attributes |
| 593 | - if(isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)){
|
|
| 594 | - foreach($attrs['attrs'] as $attr => $aParts){
|
|
| 593 | + if (isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)) {
|
|
| 594 | + foreach ($attrs['attrs'] as $attr => $aParts) {
|
|
| 595 | 595 | $contentStr .= " <$schemaPrefix:attribute"; |
| 596 | 596 | foreach ($aParts as $a => $v) {
|
| 597 | 597 | if ($a == 'ref' || $a == 'type') {
|
@@ -607,15 +607,15 @@ discard block |
||
| 607 | 607 | } |
| 608 | 608 | } |
| 609 | 609 | // if restriction |
| 610 | - if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != ''){
|
|
| 610 | + if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != '') {
|
|
| 611 | 611 | $contentStr = " <$schemaPrefix:restriction base=\"".$this->contractQName($attrs['restrictionBase'])."\">\n".$contentStr." </$schemaPrefix:restriction>\n"; |
| 612 | 612 | // complex or simple content |
| 613 | - if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)){
|
|
| 613 | + if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)) {
|
|
| 614 | 614 | $contentStr = " <$schemaPrefix:complexContent>\n".$contentStr." </$schemaPrefix:complexContent>\n"; |
| 615 | 615 | } |
| 616 | 616 | } |
| 617 | 617 | // finalize complex type |
| 618 | - if($contentStr != ''){
|
|
| 618 | + if ($contentStr != '') {
|
|
| 619 | 619 | $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n".$contentStr." </$schemaPrefix:complexType>\n"; |
| 620 | 620 | } else {
|
| 621 | 621 | $contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n"; |
@@ -623,8 +623,8 @@ discard block |
||
| 623 | 623 | $xml .= $contentStr; |
| 624 | 624 | } |
| 625 | 625 | // simple types |
| 626 | - if(isset($this->simpleTypes) && count($this->simpleTypes) > 0){
|
|
| 627 | - foreach($this->simpleTypes as $typeName => $eParts){
|
|
| 626 | + if (isset($this->simpleTypes) && count($this->simpleTypes) > 0) {
|
|
| 627 | + foreach ($this->simpleTypes as $typeName => $eParts) {
|
|
| 628 | 628 | $xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n <$schemaPrefix:restriction base=\"".$this->contractQName($eParts['type'])."\">\n"; |
| 629 | 629 | if (isset($eParts['enumeration'])) {
|
| 630 | 630 | foreach ($eParts['enumeration'] as $e) {
|
@@ -635,14 +635,14 @@ discard block |
||
| 635 | 635 | } |
| 636 | 636 | } |
| 637 | 637 | // elements |
| 638 | - if(isset($this->elements) && count($this->elements) > 0){
|
|
| 639 | - foreach($this->elements as $element => $eParts){
|
|
| 638 | + if (isset($this->elements) && count($this->elements) > 0) {
|
|
| 639 | + foreach ($this->elements as $element => $eParts) {
|
|
| 640 | 640 | $xml .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\"/>\n"; |
| 641 | 641 | } |
| 642 | 642 | } |
| 643 | 643 | // attributes |
| 644 | - if(isset($this->attributes) && count($this->attributes) > 0){
|
|
| 645 | - foreach($this->attributes as $attr => $aParts){
|
|
| 644 | + if (isset($this->attributes) && count($this->attributes) > 0) {
|
|
| 645 | + foreach ($this->attributes as $attr => $aParts) {
|
|
| 646 | 646 | $xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"".$this->contractQName($aParts['type'])."\"\n/>"; |
| 647 | 647 | } |
| 648 | 648 | } |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
|
| 658 | 658 | $el .= " xmlns:$nsp=\"$ns\""; |
| 659 | 659 | } |
| 660 | - $xml = $el . ">\n".$xml."</$schemaPrefix:schema>\n"; |
|
| 660 | + $xml = $el.">\n".$xml."</$schemaPrefix:schema>\n"; |
|
| 661 | 661 | return $xml; |
| 662 | 662 | } |
| 663 | 663 | |
@@ -667,8 +667,8 @@ discard block |
||
| 667 | 667 | * @param string $string debug data |
| 668 | 668 | * @access private |
| 669 | 669 | */ |
| 670 | - function xdebug($string){
|
|
| 671 | - $this->debug('<' . $this->schemaTargetNamespace . '> '.$string);
|
|
| 670 | + function xdebug($string) {
|
|
| 671 | + $this->debug('<'.$this->schemaTargetNamespace.'> '.$string);
|
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | /** |
@@ -683,11 +683,11 @@ discard block |
||
| 683 | 683 | * @access public |
| 684 | 684 | * @deprecated |
| 685 | 685 | */ |
| 686 | - function getPHPType($type,$ns){
|
|
| 687 | - if(isset($this->typemap[$ns][$type])){
|
|
| 686 | + function getPHPType($type, $ns) {
|
|
| 687 | + if (isset($this->typemap[$ns][$type])) {
|
|
| 688 | 688 | //print "found type '$type' and ns $ns in typemap<br>"; |
| 689 | 689 | return $this->typemap[$ns][$type]; |
| 690 | - } elseif(isset($this->complexTypes[$type])){
|
|
| 690 | + } elseif (isset($this->complexTypes[$type])) {
|
|
| 691 | 691 | //print "getting type '$type' and ns $ns from complexTypes array<br>"; |
| 692 | 692 | return $this->complexTypes[$type]['phpType']; |
| 693 | 693 | } |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | * @see addSimpleType |
| 717 | 717 | * @see addElement |
| 718 | 718 | */ |
| 719 | - function getTypeDef($type){
|
|
| 719 | + function getTypeDef($type) {
|
|
| 720 | 720 | //$this->debug("in getTypeDef for type $type");
|
| 721 | 721 | if (substr($type, -1) == '^') {
|
| 722 | 722 | $is_element = 1; |
@@ -725,10 +725,10 @@ discard block |
||
| 725 | 725 | $is_element = 0; |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | - if((! $is_element) && isset($this->complexTypes[$type])){
|
|
| 728 | + if ((!$is_element) && isset($this->complexTypes[$type])) {
|
|
| 729 | 729 | $this->xdebug("in getTypeDef, found complexType $type");
|
| 730 | 730 | return $this->complexTypes[$type]; |
| 731 | - } elseif((! $is_element) && isset($this->simpleTypes[$type])){
|
|
| 731 | + } elseif ((!$is_element) && isset($this->simpleTypes[$type])) {
|
|
| 732 | 732 | $this->xdebug("in getTypeDef, found simpleType $type");
|
| 733 | 733 | if (!isset($this->simpleTypes[$type]['phpType'])) {
|
| 734 | 734 | // get info for type to tack onto the simple type |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | } |
| 749 | 749 | } |
| 750 | 750 | return $this->simpleTypes[$type]; |
| 751 | - } elseif(isset($this->elements[$type])){
|
|
| 751 | + } elseif (isset($this->elements[$type])) {
|
|
| 752 | 752 | $this->xdebug("in getTypeDef, found element $type");
|
| 753 | 753 | if (!isset($this->elements[$type]['phpType'])) {
|
| 754 | 754 | // get info for type to tack onto the element |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | } |
| 774 | 774 | } |
| 775 | 775 | return $this->elements[$type]; |
| 776 | - } elseif(isset($this->attributes[$type])){
|
|
| 776 | + } elseif (isset($this->attributes[$type])) {
|
|
| 777 | 777 | $this->xdebug("in getTypeDef, found attribute $type");
|
| 778 | 778 | return $this->attributes[$type]; |
| 779 | 779 | } elseif (preg_match('/_ContainedType$/', $type)) {
|
@@ -795,23 +795,23 @@ discard block |
||
| 795 | 795 | * @access public |
| 796 | 796 | * @deprecated |
| 797 | 797 | */ |
| 798 | - function serializeTypeDef($type){
|
|
| 798 | + function serializeTypeDef($type) {
|
|
| 799 | 799 | //print "in sTD() for type $type<br>"; |
| 800 | - if($typeDef = $this->getTypeDef($type)){
|
|
| 800 | + if ($typeDef = $this->getTypeDef($type)) {
|
|
| 801 | 801 | $str .= '<'.$type; |
| 802 | - if(is_array($typeDef['attrs'])){
|
|
| 803 | - foreach($typeDef['attrs'] as $attName => $data){
|
|
| 802 | + if (is_array($typeDef['attrs'])) {
|
|
| 803 | + foreach ($typeDef['attrs'] as $attName => $data) {
|
|
| 804 | 804 | $str .= " $attName=\"{type = ".$data['type']."}\"";
|
| 805 | 805 | } |
| 806 | 806 | } |
| 807 | 807 | $str .= " xmlns=\"".$this->schema['targetNamespace']."\""; |
| 808 | - if(count($typeDef['elements']) > 0){
|
|
| 808 | + if (count($typeDef['elements']) > 0) {
|
|
| 809 | 809 | $str .= ">"; |
| 810 | - foreach($typeDef['elements'] as $element => $eData){
|
|
| 810 | + foreach ($typeDef['elements'] as $element => $eData) {
|
|
| 811 | 811 | $str .= $this->serializeTypeDef($element); |
| 812 | 812 | } |
| 813 | 813 | $str .= "</$type>"; |
| 814 | - } elseif($typeDef['typeClass'] == 'element') {
|
|
| 814 | + } elseif ($typeDef['typeClass'] == 'element') {
|
|
| 815 | 815 | $str .= "></$type>"; |
| 816 | 816 | } else {
|
| 817 | 817 | $str .= "/>"; |
@@ -831,22 +831,22 @@ discard block |
||
| 831 | 831 | * @access public |
| 832 | 832 | * @deprecated |
| 833 | 833 | */ |
| 834 | - function typeToForm($name,$type){
|
|
| 834 | + function typeToForm($name, $type) {
|
|
| 835 | 835 | // get typedef |
| 836 | - if($typeDef = $this->getTypeDef($type)){
|
|
| 836 | + if ($typeDef = $this->getTypeDef($type)) {
|
|
| 837 | 837 | // if struct |
| 838 | - if($typeDef['phpType'] == 'struct'){
|
|
| 838 | + if ($typeDef['phpType'] == 'struct') {
|
|
| 839 | 839 | $buffer .= '<table>'; |
| 840 | - foreach($typeDef['elements'] as $child => $childDef){
|
|
| 840 | + foreach ($typeDef['elements'] as $child => $childDef) {
|
|
| 841 | 841 | $buffer .= " |
| 842 | 842 | <tr><td align='right'>$childDef[name] (type: ".$this->getLocalPart($childDef['type'])."):</td> |
| 843 | 843 | <td><input type='text' name='parameters[".$name."][$childDef[name]]'></td></tr>"; |
| 844 | 844 | } |
| 845 | 845 | $buffer .= '</table>'; |
| 846 | 846 | // if array |
| 847 | - } elseif($typeDef['phpType'] == 'array'){
|
|
| 847 | + } elseif ($typeDef['phpType'] == 'array') {
|
|
| 848 | 848 | $buffer .= '<table>'; |
| 849 | - for($i=0;$i < 3; $i++){
|
|
| 849 | + for ($i = 0; $i < 3; $i++) {
|
|
| 850 | 850 | $buffer .= " |
| 851 | 851 | <tr><td align='right'>array item (type: $typeDef[arrayType]):</td> |
| 852 | 852 | <td><input type='text' name='parameters[".$name."][]'></td></tr>"; |
@@ -903,7 +903,7 @@ discard block |
||
| 903 | 903 | * @access public |
| 904 | 904 | * @see getTypeDef |
| 905 | 905 | */ |
| 906 | - function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType=''){
|
|
| 906 | + function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = array(), $attrs = array(), $arrayType = '') {
|
|
| 907 | 907 | $this->complexTypes[$name] = array( |
| 908 | 908 | 'name' => $name, |
| 909 | 909 | 'typeClass' => $typeClass, |
@@ -931,7 +931,7 @@ discard block |
||
| 931 | 931 | * @see nusoap_xmlschema |
| 932 | 932 | * @see getTypeDef |
| 933 | 933 | */ |
| 934 | - function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
|
|
| 934 | + function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = array()) {
|
|
| 935 | 935 | $this->simpleTypes[$name] = array( |
| 936 | 936 | 'name' => $name, |
| 937 | 937 | 'typeClass' => $typeClass, |
@@ -952,14 +952,14 @@ discard block |
||
| 952 | 952 | * @access public |
| 953 | 953 | */ |
| 954 | 954 | function addElement($attrs) {
|
| 955 | - if (! $this->getPrefix($attrs['type'])) {
|
|
| 956 | - $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type']; |
|
| 955 | + if (!$this->getPrefix($attrs['type'])) {
|
|
| 956 | + $attrs['type'] = $this->schemaTargetNamespace.':'.$attrs['type']; |
|
| 957 | 957 | } |
| 958 | - $this->elements[ $attrs['name'] ] = $attrs; |
|
| 959 | - $this->elements[ $attrs['name'] ]['typeClass'] = 'element'; |
|
| 958 | + $this->elements[$attrs['name']] = $attrs; |
|
| 959 | + $this->elements[$attrs['name']]['typeClass'] = 'element'; |
|
| 960 | 960 | |
| 961 | - $this->xdebug("addElement " . $attrs['name']);
|
|
| 962 | - $this->appendDebug($this->varDump($this->elements[ $attrs['name'] ])); |
|
| 961 | + $this->xdebug("addElement ".$attrs['name']);
|
|
| 962 | + $this->appendDebug($this->varDump($this->elements[$attrs['name']])); |
|
| 963 | 963 | } |
| 964 | 964 | } |
| 965 | 965 | |
@@ -447,7 +447,7 @@ |
||
| 447 | 447 | * |
| 448 | 448 | * @param array $headers The HTTP headers |
| 449 | 449 | * @param string $data unprocessed request data from client |
| 450 | - * @return mixed value of the message, decoded into a PHP type |
|
| 450 | + * @return false|null value of the message, decoded into a PHP type |
|
| 451 | 451 | * @access private |
| 452 | 452 | */ |
| 453 | 453 | function parseRequest($headers, $data) {
|
@@ -52,224 +52,224 @@ discard block |
||
| 52 | 52 | * @access public |
| 53 | 53 | */ |
| 54 | 54 | class nusoap_client_mime extends nusoap_client {
|
| 55 | - /** |
|
| 56 | - * @var array Each array element in the return is an associative array with keys |
|
| 57 | - * data, filename, contenttype, cid |
|
| 58 | - * @access private |
|
| 59 | - */ |
|
| 60 | - var $requestAttachments = array(); |
|
| 61 | - /** |
|
| 62 | - * @var array Each array element in the return is an associative array with keys |
|
| 63 | - * data, filename, contenttype, cid |
|
| 64 | - * @access private |
|
| 65 | - */ |
|
| 66 | - var $responseAttachments; |
|
| 67 | - /** |
|
| 68 | - * @var string |
|
| 69 | - * @access private |
|
| 70 | - */ |
|
| 71 | - var $mimeContentType; |
|
| 55 | + /** |
|
| 56 | + * @var array Each array element in the return is an associative array with keys |
|
| 57 | + * data, filename, contenttype, cid |
|
| 58 | + * @access private |
|
| 59 | + */ |
|
| 60 | + var $requestAttachments = array(); |
|
| 61 | + /** |
|
| 62 | + * @var array Each array element in the return is an associative array with keys |
|
| 63 | + * data, filename, contenttype, cid |
|
| 64 | + * @access private |
|
| 65 | + */ |
|
| 66 | + var $responseAttachments; |
|
| 67 | + /** |
|
| 68 | + * @var string |
|
| 69 | + * @access private |
|
| 70 | + */ |
|
| 71 | + var $mimeContentType; |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * adds a MIME attachment to the current request. |
|
| 75 | - * |
|
| 76 | - * If the $data parameter contains an empty string, this method will read |
|
| 77 | - * the contents of the file named by the $filename parameter. |
|
| 78 | - * |
|
| 79 | - * If the $cid parameter is false, this method will generate the cid. |
|
| 80 | - * |
|
| 81 | - * @param string $data The data of the attachment |
|
| 82 | - * @param string $filename The filename of the attachment (default is empty string) |
|
| 83 | - * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
| 84 | - * @param string $cid The content-id (cid) of the attachment (default is false) |
|
| 85 | - * @return string The content-id (cid) of the attachment |
|
| 86 | - * @access public |
|
| 87 | - */ |
|
| 88 | - function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
|
| 89 | - if (! $cid) {
|
|
| 90 | - $cid = md5(uniqid(time())); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - $info['data'] = $data; |
|
| 94 | - $info['filename'] = $filename; |
|
| 95 | - $info['contenttype'] = $contenttype; |
|
| 96 | - $info['cid'] = $cid; |
|
| 73 | + /** |
|
| 74 | + * adds a MIME attachment to the current request. |
|
| 75 | + * |
|
| 76 | + * If the $data parameter contains an empty string, this method will read |
|
| 77 | + * the contents of the file named by the $filename parameter. |
|
| 78 | + * |
|
| 79 | + * If the $cid parameter is false, this method will generate the cid. |
|
| 80 | + * |
|
| 81 | + * @param string $data The data of the attachment |
|
| 82 | + * @param string $filename The filename of the attachment (default is empty string) |
|
| 83 | + * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
| 84 | + * @param string $cid The content-id (cid) of the attachment (default is false) |
|
| 85 | + * @return string The content-id (cid) of the attachment |
|
| 86 | + * @access public |
|
| 87 | + */ |
|
| 88 | + function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
|
| 89 | + if (! $cid) {
|
|
| 90 | + $cid = md5(uniqid(time())); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + $info['data'] = $data; |
|
| 94 | + $info['filename'] = $filename; |
|
| 95 | + $info['contenttype'] = $contenttype; |
|
| 96 | + $info['cid'] = $cid; |
|
| 97 | 97 | |
| 98 | - $this->requestAttachments[] = $info; |
|
| 99 | - |
|
| 100 | - return $cid; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * clears the MIME attachments for the current request. |
|
| 105 | - * |
|
| 106 | - * @access public |
|
| 107 | - */ |
|
| 108 | - function clearAttachments() {
|
|
| 109 | - $this->requestAttachments = array(); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * gets the MIME attachments from the current response. |
|
| 114 | - * |
|
| 115 | - * Each array element in the return is an associative array with keys |
|
| 116 | - * data, filename, contenttype, cid. These keys correspond to the parameters |
|
| 117 | - * for addAttachment. |
|
| 118 | - * |
|
| 119 | - * @return array The attachments. |
|
| 120 | - * @access public |
|
| 121 | - */ |
|
| 122 | - function getAttachments() {
|
|
| 123 | - return $this->responseAttachments; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * gets the HTTP body for the current request. |
|
| 128 | - * |
|
| 129 | - * @param string $soapmsg The SOAP payload |
|
| 130 | - * @return string The HTTP body, which includes the SOAP payload |
|
| 131 | - * @access private |
|
| 132 | - */ |
|
| 133 | - function getHTTPBody($soapmsg) {
|
|
| 134 | - if (count($this->requestAttachments) > 0) {
|
|
| 135 | - $params['content_type'] = 'multipart/related; type="text/xml"'; |
|
| 136 | - $mimeMessage = new Mail_mimePart('', $params);
|
|
| 137 | - unset($params); |
|
| 138 | - |
|
| 139 | - $params['content_type'] = 'text/xml'; |
|
| 140 | - $params['encoding'] = '8bit'; |
|
| 141 | - $params['charset'] = $this->soap_defencoding; |
|
| 142 | - $mimeMessage->addSubpart($soapmsg, $params); |
|
| 98 | + $this->requestAttachments[] = $info; |
|
| 99 | + |
|
| 100 | + return $cid; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * clears the MIME attachments for the current request. |
|
| 105 | + * |
|
| 106 | + * @access public |
|
| 107 | + */ |
|
| 108 | + function clearAttachments() {
|
|
| 109 | + $this->requestAttachments = array(); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * gets the MIME attachments from the current response. |
|
| 114 | + * |
|
| 115 | + * Each array element in the return is an associative array with keys |
|
| 116 | + * data, filename, contenttype, cid. These keys correspond to the parameters |
|
| 117 | + * for addAttachment. |
|
| 118 | + * |
|
| 119 | + * @return array The attachments. |
|
| 120 | + * @access public |
|
| 121 | + */ |
|
| 122 | + function getAttachments() {
|
|
| 123 | + return $this->responseAttachments; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * gets the HTTP body for the current request. |
|
| 128 | + * |
|
| 129 | + * @param string $soapmsg The SOAP payload |
|
| 130 | + * @return string The HTTP body, which includes the SOAP payload |
|
| 131 | + * @access private |
|
| 132 | + */ |
|
| 133 | + function getHTTPBody($soapmsg) {
|
|
| 134 | + if (count($this->requestAttachments) > 0) {
|
|
| 135 | + $params['content_type'] = 'multipart/related; type="text/xml"'; |
|
| 136 | + $mimeMessage = new Mail_mimePart('', $params);
|
|
| 137 | + unset($params); |
|
| 138 | + |
|
| 139 | + $params['content_type'] = 'text/xml'; |
|
| 140 | + $params['encoding'] = '8bit'; |
|
| 141 | + $params['charset'] = $this->soap_defencoding; |
|
| 142 | + $mimeMessage->addSubpart($soapmsg, $params); |
|
| 143 | 143 | |
| 144 | - foreach ($this->requestAttachments as $att) {
|
|
| 145 | - unset($params); |
|
| 146 | - |
|
| 147 | - $params['content_type'] = $att['contenttype']; |
|
| 148 | - $params['encoding'] = 'base64'; |
|
| 149 | - $params['disposition'] = 'attachment'; |
|
| 150 | - $params['dfilename'] = $att['filename']; |
|
| 151 | - $params['cid'] = $att['cid']; |
|
| 152 | - |
|
| 153 | - if ($att['data'] == '' && $att['filename'] <> '') {
|
|
| 154 | - if ($fd = fopen($att['filename'], 'rb')) {
|
|
| 155 | - $data = fread($fd, filesize($att['filename'])); |
|
| 156 | - fclose($fd); |
|
| 157 | - } else {
|
|
| 158 | - $data = ''; |
|
| 159 | - } |
|
| 160 | - $mimeMessage->addSubpart($data, $params); |
|
| 161 | - } else {
|
|
| 162 | - $mimeMessage->addSubpart($att['data'], $params); |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - $output = $mimeMessage->encode(); |
|
| 167 | - $mimeHeaders = $output['headers']; |
|
| 144 | + foreach ($this->requestAttachments as $att) {
|
|
| 145 | + unset($params); |
|
| 146 | + |
|
| 147 | + $params['content_type'] = $att['contenttype']; |
|
| 148 | + $params['encoding'] = 'base64'; |
|
| 149 | + $params['disposition'] = 'attachment'; |
|
| 150 | + $params['dfilename'] = $att['filename']; |
|
| 151 | + $params['cid'] = $att['cid']; |
|
| 152 | + |
|
| 153 | + if ($att['data'] == '' && $att['filename'] <> '') {
|
|
| 154 | + if ($fd = fopen($att['filename'], 'rb')) {
|
|
| 155 | + $data = fread($fd, filesize($att['filename'])); |
|
| 156 | + fclose($fd); |
|
| 157 | + } else {
|
|
| 158 | + $data = ''; |
|
| 159 | + } |
|
| 160 | + $mimeMessage->addSubpart($data, $params); |
|
| 161 | + } else {
|
|
| 162 | + $mimeMessage->addSubpart($att['data'], $params); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + $output = $mimeMessage->encode(); |
|
| 167 | + $mimeHeaders = $output['headers']; |
|
| 168 | 168 | |
| 169 | - foreach ($mimeHeaders as $k => $v) {
|
|
| 170 | - $this->debug("MIME header $k: $v");
|
|
| 171 | - if (strtolower($k) == 'content-type') {
|
|
| 172 | - // PHP header() seems to strip leading whitespace starting |
|
| 173 | - // the second line, so force everything to one line |
|
| 174 | - $this->mimeContentType = str_replace("\r\n", " ", $v);
|
|
| 175 | - } |
|
| 176 | - } |
|
| 169 | + foreach ($mimeHeaders as $k => $v) {
|
|
| 170 | + $this->debug("MIME header $k: $v");
|
|
| 171 | + if (strtolower($k) == 'content-type') {
|
|
| 172 | + // PHP header() seems to strip leading whitespace starting |
|
| 173 | + // the second line, so force everything to one line |
|
| 174 | + $this->mimeContentType = str_replace("\r\n", " ", $v);
|
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | - return $output['body']; |
|
| 179 | - } |
|
| 178 | + return $output['body']; |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - return parent::getHTTPBody($soapmsg); |
|
| 182 | - } |
|
| 181 | + return parent::getHTTPBody($soapmsg); |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | - /** |
|
| 185 | - * gets the HTTP content type for the current request. |
|
| 186 | - * |
|
| 187 | - * Note: getHTTPBody must be called before this. |
|
| 188 | - * |
|
| 189 | - * @return string the HTTP content type for the current request. |
|
| 190 | - * @access private |
|
| 191 | - */ |
|
| 192 | - function getHTTPContentType() {
|
|
| 193 | - if (count($this->requestAttachments) > 0) {
|
|
| 194 | - return $this->mimeContentType; |
|
| 195 | - } |
|
| 196 | - return parent::getHTTPContentType(); |
|
| 197 | - } |
|
| 184 | + /** |
|
| 185 | + * gets the HTTP content type for the current request. |
|
| 186 | + * |
|
| 187 | + * Note: getHTTPBody must be called before this. |
|
| 188 | + * |
|
| 189 | + * @return string the HTTP content type for the current request. |
|
| 190 | + * @access private |
|
| 191 | + */ |
|
| 192 | + function getHTTPContentType() {
|
|
| 193 | + if (count($this->requestAttachments) > 0) {
|
|
| 194 | + return $this->mimeContentType; |
|
| 195 | + } |
|
| 196 | + return parent::getHTTPContentType(); |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - /** |
|
| 200 | - * gets the HTTP content type charset for the current request. |
|
| 201 | - * returns false for non-text content types. |
|
| 202 | - * |
|
| 203 | - * Note: getHTTPBody must be called before this. |
|
| 204 | - * |
|
| 205 | - * @return string the HTTP content type charset for the current request. |
|
| 206 | - * @access private |
|
| 207 | - */ |
|
| 208 | - function getHTTPContentTypeCharset() {
|
|
| 209 | - if (count($this->requestAttachments) > 0) {
|
|
| 210 | - return false; |
|
| 211 | - } |
|
| 212 | - return parent::getHTTPContentTypeCharset(); |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * processes SOAP message returned from server |
|
| 217 | - * |
|
| 218 | - * @param array $headers The HTTP headers |
|
| 219 | - * @param string $data unprocessed response data from server |
|
| 220 | - * @return mixed value of the message, decoded into a PHP type |
|
| 221 | - * @access private |
|
| 222 | - */ |
|
| 199 | + /** |
|
| 200 | + * gets the HTTP content type charset for the current request. |
|
| 201 | + * returns false for non-text content types. |
|
| 202 | + * |
|
| 203 | + * Note: getHTTPBody must be called before this. |
|
| 204 | + * |
|
| 205 | + * @return string the HTTP content type charset for the current request. |
|
| 206 | + * @access private |
|
| 207 | + */ |
|
| 208 | + function getHTTPContentTypeCharset() {
|
|
| 209 | + if (count($this->requestAttachments) > 0) {
|
|
| 210 | + return false; |
|
| 211 | + } |
|
| 212 | + return parent::getHTTPContentTypeCharset(); |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * processes SOAP message returned from server |
|
| 217 | + * |
|
| 218 | + * @param array $headers The HTTP headers |
|
| 219 | + * @param string $data unprocessed response data from server |
|
| 220 | + * @return mixed value of the message, decoded into a PHP type |
|
| 221 | + * @access private |
|
| 222 | + */ |
|
| 223 | 223 | function parseResponse($headers, $data) {
|
| 224 | - $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 225 | - $this->responseAttachments = array(); |
|
| 226 | - if (strstr($headers['content-type'], 'multipart/related')) {
|
|
| 227 | - $this->debug('Decode multipart/related');
|
|
| 228 | - $input = ''; |
|
| 229 | - foreach ($headers as $k => $v) {
|
|
| 230 | - $input .= "$k: $v\r\n"; |
|
| 231 | - } |
|
| 232 | - $params['input'] = $input . "\r\n" . $data; |
|
| 233 | - $params['include_bodies'] = true; |
|
| 234 | - $params['decode_bodies'] = true; |
|
| 235 | - $params['decode_headers'] = true; |
|
| 224 | + $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 225 | + $this->responseAttachments = array(); |
|
| 226 | + if (strstr($headers['content-type'], 'multipart/related')) {
|
|
| 227 | + $this->debug('Decode multipart/related');
|
|
| 228 | + $input = ''; |
|
| 229 | + foreach ($headers as $k => $v) {
|
|
| 230 | + $input .= "$k: $v\r\n"; |
|
| 231 | + } |
|
| 232 | + $params['input'] = $input . "\r\n" . $data; |
|
| 233 | + $params['include_bodies'] = true; |
|
| 234 | + $params['decode_bodies'] = true; |
|
| 235 | + $params['decode_headers'] = true; |
|
| 236 | 236 | |
| 237 | - $structure = Mail_mimeDecode::decode($params); |
|
| 238 | - |
|
| 239 | - foreach ($structure->parts as $part) {
|
|
| 240 | - if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
|
| 241 | - $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 242 | - $root = $part->body; |
|
| 243 | - $return = parent::parseResponse($part->headers, $part->body); |
|
| 244 | - } else {
|
|
| 245 | - $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 246 | - $info['data'] = $part->body; |
|
| 247 | - $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
|
| 248 | - $info['contenttype'] = $part->headers['content-type']; |
|
| 249 | - $info['cid'] = $part->headers['content-id']; |
|
| 250 | - $this->responseAttachments[] = $info; |
|
| 251 | - } |
|
| 252 | - } |
|
| 237 | + $structure = Mail_mimeDecode::decode($params); |
|
| 238 | + |
|
| 239 | + foreach ($structure->parts as $part) {
|
|
| 240 | + if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
|
| 241 | + $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 242 | + $root = $part->body; |
|
| 243 | + $return = parent::parseResponse($part->headers, $part->body); |
|
| 244 | + } else {
|
|
| 245 | + $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 246 | + $info['data'] = $part->body; |
|
| 247 | + $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
|
| 248 | + $info['contenttype'] = $part->headers['content-type']; |
|
| 249 | + $info['cid'] = $part->headers['content-id']; |
|
| 250 | + $this->responseAttachments[] = $info; |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | - if (isset($return)) {
|
|
| 255 | - $this->responseData = $root; |
|
| 256 | - return $return; |
|
| 257 | - } |
|
| 254 | + if (isset($return)) {
|
|
| 255 | + $this->responseData = $root; |
|
| 256 | + return $return; |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - $this->setError('No root part found in multipart/related content');
|
|
| 260 | - return ''; |
|
| 261 | - } |
|
| 262 | - $this->debug('Not multipart/related');
|
|
| 263 | - return parent::parseResponse($headers, $data); |
|
| 264 | - } |
|
| 259 | + $this->setError('No root part found in multipart/related content');
|
|
| 260 | + return ''; |
|
| 261 | + } |
|
| 262 | + $this->debug('Not multipart/related');
|
|
| 263 | + return parent::parseResponse($headers, $data); |
|
| 264 | + } |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /* |
| 268 | 268 | * For backwards compatiblity, define soapclientmime unless the PHP SOAP extension is loaded. |
| 269 | 269 | */ |
| 270 | 270 | if (!extension_loaded('soap')) {
|
| 271 | - class soapclientmime extends nusoap_client_mime {
|
|
| 272 | - } |
|
| 271 | + class soapclientmime extends nusoap_client_mime {
|
|
| 272 | + } |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -282,214 +282,214 @@ discard block |
||
| 282 | 282 | * @access public |
| 283 | 283 | */ |
| 284 | 284 | class nusoap_server_mime extends nusoap_server {
|
| 285 | - /** |
|
| 286 | - * @var array Each array element in the return is an associative array with keys |
|
| 287 | - * data, filename, contenttype, cid |
|
| 288 | - * @access private |
|
| 289 | - */ |
|
| 290 | - var $requestAttachments = array(); |
|
| 291 | - /** |
|
| 292 | - * @var array Each array element in the return is an associative array with keys |
|
| 293 | - * data, filename, contenttype, cid |
|
| 294 | - * @access private |
|
| 295 | - */ |
|
| 296 | - var $responseAttachments; |
|
| 297 | - /** |
|
| 298 | - * @var string |
|
| 299 | - * @access private |
|
| 300 | - */ |
|
| 301 | - var $mimeContentType; |
|
| 285 | + /** |
|
| 286 | + * @var array Each array element in the return is an associative array with keys |
|
| 287 | + * data, filename, contenttype, cid |
|
| 288 | + * @access private |
|
| 289 | + */ |
|
| 290 | + var $requestAttachments = array(); |
|
| 291 | + /** |
|
| 292 | + * @var array Each array element in the return is an associative array with keys |
|
| 293 | + * data, filename, contenttype, cid |
|
| 294 | + * @access private |
|
| 295 | + */ |
|
| 296 | + var $responseAttachments; |
|
| 297 | + /** |
|
| 298 | + * @var string |
|
| 299 | + * @access private |
|
| 300 | + */ |
|
| 301 | + var $mimeContentType; |
|
| 302 | 302 | |
| 303 | - /** |
|
| 304 | - * adds a MIME attachment to the current response. |
|
| 305 | - * |
|
| 306 | - * If the $data parameter contains an empty string, this method will read |
|
| 307 | - * the contents of the file named by the $filename parameter. |
|
| 308 | - * |
|
| 309 | - * If the $cid parameter is false, this method will generate the cid. |
|
| 310 | - * |
|
| 311 | - * @param string $data The data of the attachment |
|
| 312 | - * @param string $filename The filename of the attachment (default is empty string) |
|
| 313 | - * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
| 314 | - * @param string $cid The content-id (cid) of the attachment (default is false) |
|
| 315 | - * @return string The content-id (cid) of the attachment |
|
| 316 | - * @access public |
|
| 317 | - */ |
|
| 318 | - function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
|
| 319 | - if (! $cid) {
|
|
| 320 | - $cid = md5(uniqid(time())); |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - $info['data'] = $data; |
|
| 324 | - $info['filename'] = $filename; |
|
| 325 | - $info['contenttype'] = $contenttype; |
|
| 326 | - $info['cid'] = $cid; |
|
| 303 | + /** |
|
| 304 | + * adds a MIME attachment to the current response. |
|
| 305 | + * |
|
| 306 | + * If the $data parameter contains an empty string, this method will read |
|
| 307 | + * the contents of the file named by the $filename parameter. |
|
| 308 | + * |
|
| 309 | + * If the $cid parameter is false, this method will generate the cid. |
|
| 310 | + * |
|
| 311 | + * @param string $data The data of the attachment |
|
| 312 | + * @param string $filename The filename of the attachment (default is empty string) |
|
| 313 | + * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
| 314 | + * @param string $cid The content-id (cid) of the attachment (default is false) |
|
| 315 | + * @return string The content-id (cid) of the attachment |
|
| 316 | + * @access public |
|
| 317 | + */ |
|
| 318 | + function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
|
| 319 | + if (! $cid) {
|
|
| 320 | + $cid = md5(uniqid(time())); |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + $info['data'] = $data; |
|
| 324 | + $info['filename'] = $filename; |
|
| 325 | + $info['contenttype'] = $contenttype; |
|
| 326 | + $info['cid'] = $cid; |
|
| 327 | 327 | |
| 328 | - $this->responseAttachments[] = $info; |
|
| 329 | - |
|
| 330 | - return $cid; |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - /** |
|
| 334 | - * clears the MIME attachments for the current response. |
|
| 335 | - * |
|
| 336 | - * @access public |
|
| 337 | - */ |
|
| 338 | - function clearAttachments() {
|
|
| 339 | - $this->responseAttachments = array(); |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - /** |
|
| 343 | - * gets the MIME attachments from the current request. |
|
| 344 | - * |
|
| 345 | - * Each array element in the return is an associative array with keys |
|
| 346 | - * data, filename, contenttype, cid. These keys correspond to the parameters |
|
| 347 | - * for addAttachment. |
|
| 348 | - * |
|
| 349 | - * @return array The attachments. |
|
| 350 | - * @access public |
|
| 351 | - */ |
|
| 352 | - function getAttachments() {
|
|
| 353 | - return $this->requestAttachments; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * gets the HTTP body for the current response. |
|
| 358 | - * |
|
| 359 | - * @param string $soapmsg The SOAP payload |
|
| 360 | - * @return string The HTTP body, which includes the SOAP payload |
|
| 361 | - * @access private |
|
| 362 | - */ |
|
| 363 | - function getHTTPBody($soapmsg) {
|
|
| 364 | - if (count($this->responseAttachments) > 0) {
|
|
| 365 | - $params['content_type'] = 'multipart/related; type="text/xml"'; |
|
| 366 | - $mimeMessage = new Mail_mimePart('', $params);
|
|
| 367 | - unset($params); |
|
| 368 | - |
|
| 369 | - $params['content_type'] = 'text/xml'; |
|
| 370 | - $params['encoding'] = '8bit'; |
|
| 371 | - $params['charset'] = $this->soap_defencoding; |
|
| 372 | - $mimeMessage->addSubpart($soapmsg, $params); |
|
| 328 | + $this->responseAttachments[] = $info; |
|
| 329 | + |
|
| 330 | + return $cid; |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + /** |
|
| 334 | + * clears the MIME attachments for the current response. |
|
| 335 | + * |
|
| 336 | + * @access public |
|
| 337 | + */ |
|
| 338 | + function clearAttachments() {
|
|
| 339 | + $this->responseAttachments = array(); |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + /** |
|
| 343 | + * gets the MIME attachments from the current request. |
|
| 344 | + * |
|
| 345 | + * Each array element in the return is an associative array with keys |
|
| 346 | + * data, filename, contenttype, cid. These keys correspond to the parameters |
|
| 347 | + * for addAttachment. |
|
| 348 | + * |
|
| 349 | + * @return array The attachments. |
|
| 350 | + * @access public |
|
| 351 | + */ |
|
| 352 | + function getAttachments() {
|
|
| 353 | + return $this->requestAttachments; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * gets the HTTP body for the current response. |
|
| 358 | + * |
|
| 359 | + * @param string $soapmsg The SOAP payload |
|
| 360 | + * @return string The HTTP body, which includes the SOAP payload |
|
| 361 | + * @access private |
|
| 362 | + */ |
|
| 363 | + function getHTTPBody($soapmsg) {
|
|
| 364 | + if (count($this->responseAttachments) > 0) {
|
|
| 365 | + $params['content_type'] = 'multipart/related; type="text/xml"'; |
|
| 366 | + $mimeMessage = new Mail_mimePart('', $params);
|
|
| 367 | + unset($params); |
|
| 368 | + |
|
| 369 | + $params['content_type'] = 'text/xml'; |
|
| 370 | + $params['encoding'] = '8bit'; |
|
| 371 | + $params['charset'] = $this->soap_defencoding; |
|
| 372 | + $mimeMessage->addSubpart($soapmsg, $params); |
|
| 373 | 373 | |
| 374 | - foreach ($this->responseAttachments as $att) {
|
|
| 375 | - unset($params); |
|
| 376 | - |
|
| 377 | - $params['content_type'] = $att['contenttype']; |
|
| 378 | - $params['encoding'] = 'base64'; |
|
| 379 | - $params['disposition'] = 'attachment'; |
|
| 380 | - $params['dfilename'] = $att['filename']; |
|
| 381 | - $params['cid'] = $att['cid']; |
|
| 382 | - |
|
| 383 | - if ($att['data'] == '' && $att['filename'] <> '') {
|
|
| 384 | - if ($fd = fopen($att['filename'], 'rb')) {
|
|
| 385 | - $data = fread($fd, filesize($att['filename'])); |
|
| 386 | - fclose($fd); |
|
| 387 | - } else {
|
|
| 388 | - $data = ''; |
|
| 389 | - } |
|
| 390 | - $mimeMessage->addSubpart($data, $params); |
|
| 391 | - } else {
|
|
| 392 | - $mimeMessage->addSubpart($att['data'], $params); |
|
| 393 | - } |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - $output = $mimeMessage->encode(); |
|
| 397 | - $mimeHeaders = $output['headers']; |
|
| 374 | + foreach ($this->responseAttachments as $att) {
|
|
| 375 | + unset($params); |
|
| 376 | + |
|
| 377 | + $params['content_type'] = $att['contenttype']; |
|
| 378 | + $params['encoding'] = 'base64'; |
|
| 379 | + $params['disposition'] = 'attachment'; |
|
| 380 | + $params['dfilename'] = $att['filename']; |
|
| 381 | + $params['cid'] = $att['cid']; |
|
| 382 | + |
|
| 383 | + if ($att['data'] == '' && $att['filename'] <> '') {
|
|
| 384 | + if ($fd = fopen($att['filename'], 'rb')) {
|
|
| 385 | + $data = fread($fd, filesize($att['filename'])); |
|
| 386 | + fclose($fd); |
|
| 387 | + } else {
|
|
| 388 | + $data = ''; |
|
| 389 | + } |
|
| 390 | + $mimeMessage->addSubpart($data, $params); |
|
| 391 | + } else {
|
|
| 392 | + $mimeMessage->addSubpart($att['data'], $params); |
|
| 393 | + } |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + $output = $mimeMessage->encode(); |
|
| 397 | + $mimeHeaders = $output['headers']; |
|
| 398 | 398 | |
| 399 | - foreach ($mimeHeaders as $k => $v) {
|
|
| 400 | - $this->debug("MIME header $k: $v");
|
|
| 401 | - if (strtolower($k) == 'content-type') {
|
|
| 402 | - // PHP header() seems to strip leading whitespace starting |
|
| 403 | - // the second line, so force everything to one line |
|
| 404 | - $this->mimeContentType = str_replace("\r\n", " ", $v);
|
|
| 405 | - } |
|
| 406 | - } |
|
| 399 | + foreach ($mimeHeaders as $k => $v) {
|
|
| 400 | + $this->debug("MIME header $k: $v");
|
|
| 401 | + if (strtolower($k) == 'content-type') {
|
|
| 402 | + // PHP header() seems to strip leading whitespace starting |
|
| 403 | + // the second line, so force everything to one line |
|
| 404 | + $this->mimeContentType = str_replace("\r\n", " ", $v);
|
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | 407 | |
| 408 | - return $output['body']; |
|
| 409 | - } |
|
| 408 | + return $output['body']; |
|
| 409 | + } |
|
| 410 | 410 | |
| 411 | - return parent::getHTTPBody($soapmsg); |
|
| 412 | - } |
|
| 411 | + return parent::getHTTPBody($soapmsg); |
|
| 412 | + } |
|
| 413 | 413 | |
| 414 | - /** |
|
| 415 | - * gets the HTTP content type for the current response. |
|
| 416 | - * |
|
| 417 | - * Note: getHTTPBody must be called before this. |
|
| 418 | - * |
|
| 419 | - * @return string the HTTP content type for the current response. |
|
| 420 | - * @access private |
|
| 421 | - */ |
|
| 422 | - function getHTTPContentType() {
|
|
| 423 | - if (count($this->responseAttachments) > 0) {
|
|
| 424 | - return $this->mimeContentType; |
|
| 425 | - } |
|
| 426 | - return parent::getHTTPContentType(); |
|
| 427 | - } |
|
| 414 | + /** |
|
| 415 | + * gets the HTTP content type for the current response. |
|
| 416 | + * |
|
| 417 | + * Note: getHTTPBody must be called before this. |
|
| 418 | + * |
|
| 419 | + * @return string the HTTP content type for the current response. |
|
| 420 | + * @access private |
|
| 421 | + */ |
|
| 422 | + function getHTTPContentType() {
|
|
| 423 | + if (count($this->responseAttachments) > 0) {
|
|
| 424 | + return $this->mimeContentType; |
|
| 425 | + } |
|
| 426 | + return parent::getHTTPContentType(); |
|
| 427 | + } |
|
| 428 | 428 | |
| 429 | - /** |
|
| 430 | - * gets the HTTP content type charset for the current response. |
|
| 431 | - * returns false for non-text content types. |
|
| 432 | - * |
|
| 433 | - * Note: getHTTPBody must be called before this. |
|
| 434 | - * |
|
| 435 | - * @return string the HTTP content type charset for the current response. |
|
| 436 | - * @access private |
|
| 437 | - */ |
|
| 438 | - function getHTTPContentTypeCharset() {
|
|
| 439 | - if (count($this->responseAttachments) > 0) {
|
|
| 440 | - return false; |
|
| 441 | - } |
|
| 442 | - return parent::getHTTPContentTypeCharset(); |
|
| 443 | - } |
|
| 444 | - |
|
| 445 | - /** |
|
| 446 | - * processes SOAP message received from client |
|
| 447 | - * |
|
| 448 | - * @param array $headers The HTTP headers |
|
| 449 | - * @param string $data unprocessed request data from client |
|
| 450 | - * @return mixed value of the message, decoded into a PHP type |
|
| 451 | - * @access private |
|
| 452 | - */ |
|
| 429 | + /** |
|
| 430 | + * gets the HTTP content type charset for the current response. |
|
| 431 | + * returns false for non-text content types. |
|
| 432 | + * |
|
| 433 | + * Note: getHTTPBody must be called before this. |
|
| 434 | + * |
|
| 435 | + * @return string the HTTP content type charset for the current response. |
|
| 436 | + * @access private |
|
| 437 | + */ |
|
| 438 | + function getHTTPContentTypeCharset() {
|
|
| 439 | + if (count($this->responseAttachments) > 0) {
|
|
| 440 | + return false; |
|
| 441 | + } |
|
| 442 | + return parent::getHTTPContentTypeCharset(); |
|
| 443 | + } |
|
| 444 | + |
|
| 445 | + /** |
|
| 446 | + * processes SOAP message received from client |
|
| 447 | + * |
|
| 448 | + * @param array $headers The HTTP headers |
|
| 449 | + * @param string $data unprocessed request data from client |
|
| 450 | + * @return mixed value of the message, decoded into a PHP type |
|
| 451 | + * @access private |
|
| 452 | + */ |
|
| 453 | 453 | function parseRequest($headers, $data) {
|
| 454 | - $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 455 | - $this->requestAttachments = array(); |
|
| 456 | - if (strstr($headers['content-type'], 'multipart/related')) {
|
|
| 457 | - $this->debug('Decode multipart/related');
|
|
| 458 | - $input = ''; |
|
| 459 | - foreach ($headers as $k => $v) {
|
|
| 460 | - $input .= "$k: $v\r\n"; |
|
| 461 | - } |
|
| 462 | - $params['input'] = $input . "\r\n" . $data; |
|
| 463 | - $params['include_bodies'] = true; |
|
| 464 | - $params['decode_bodies'] = true; |
|
| 465 | - $params['decode_headers'] = true; |
|
| 454 | + $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 455 | + $this->requestAttachments = array(); |
|
| 456 | + if (strstr($headers['content-type'], 'multipart/related')) {
|
|
| 457 | + $this->debug('Decode multipart/related');
|
|
| 458 | + $input = ''; |
|
| 459 | + foreach ($headers as $k => $v) {
|
|
| 460 | + $input .= "$k: $v\r\n"; |
|
| 461 | + } |
|
| 462 | + $params['input'] = $input . "\r\n" . $data; |
|
| 463 | + $params['include_bodies'] = true; |
|
| 464 | + $params['decode_bodies'] = true; |
|
| 465 | + $params['decode_headers'] = true; |
|
| 466 | 466 | |
| 467 | - $structure = Mail_mimeDecode::decode($params); |
|
| 468 | - |
|
| 469 | - foreach ($structure->parts as $part) {
|
|
| 470 | - if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
|
| 471 | - $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 472 | - $return = parent::parseRequest($part->headers, $part->body); |
|
| 473 | - } else {
|
|
| 474 | - $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 475 | - $info['data'] = $part->body; |
|
| 476 | - $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
|
| 477 | - $info['contenttype'] = $part->headers['content-type']; |
|
| 478 | - $info['cid'] = $part->headers['content-id']; |
|
| 479 | - $this->requestAttachments[] = $info; |
|
| 480 | - } |
|
| 481 | - } |
|
| 467 | + $structure = Mail_mimeDecode::decode($params); |
|
| 468 | + |
|
| 469 | + foreach ($structure->parts as $part) {
|
|
| 470 | + if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
|
| 471 | + $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 472 | + $return = parent::parseRequest($part->headers, $part->body); |
|
| 473 | + } else {
|
|
| 474 | + $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 475 | + $info['data'] = $part->body; |
|
| 476 | + $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
|
| 477 | + $info['contenttype'] = $part->headers['content-type']; |
|
| 478 | + $info['cid'] = $part->headers['content-id']; |
|
| 479 | + $this->requestAttachments[] = $info; |
|
| 480 | + } |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | - if (isset($return)) {
|
|
| 484 | - return $return; |
|
| 485 | - } |
|
| 483 | + if (isset($return)) {
|
|
| 484 | + return $return; |
|
| 485 | + } |
|
| 486 | 486 | |
| 487 | - $this->setError('No root part found in multipart/related content');
|
|
| 488 | - return; |
|
| 489 | - } |
|
| 490 | - $this->debug('Not multipart/related');
|
|
| 491 | - return parent::parseRequest($headers, $data); |
|
| 492 | - } |
|
| 487 | + $this->setError('No root part found in multipart/related content');
|
|
| 488 | + return; |
|
| 489 | + } |
|
| 490 | + $this->debug('Not multipart/related');
|
|
| 491 | + return parent::parseRequest($headers, $data); |
|
| 492 | + } |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | /* |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @access public |
| 87 | 87 | */ |
| 88 | 88 | function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
| 89 | - if (! $cid) {
|
|
| 89 | + if (!$cid) {
|
|
| 90 | 90 | $cid = md5(uniqid(time())); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @access private |
| 222 | 222 | */ |
| 223 | 223 | function parseResponse($headers, $data) {
|
| 224 | - $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 224 | + $this->debug('Entering parseResponse() for payload of length '.strlen($data).' and type of '.$headers['content-type']);
|
|
| 225 | 225 | $this->responseAttachments = array(); |
| 226 | 226 | if (strstr($headers['content-type'], 'multipart/related')) {
|
| 227 | 227 | $this->debug('Decode multipart/related');
|
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | foreach ($headers as $k => $v) {
|
| 230 | 230 | $input .= "$k: $v\r\n"; |
| 231 | 231 | } |
| 232 | - $params['input'] = $input . "\r\n" . $data; |
|
| 232 | + $params['input'] = $input."\r\n".$data; |
|
| 233 | 233 | $params['include_bodies'] = true; |
| 234 | 234 | $params['decode_bodies'] = true; |
| 235 | 235 | $params['decode_headers'] = true; |
@@ -238,11 +238,11 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | foreach ($structure->parts as $part) {
|
| 240 | 240 | if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
| 241 | - $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 241 | + $this->debug('Have root part of type '.$part->headers['content-type']);
|
|
| 242 | 242 | $root = $part->body; |
| 243 | 243 | $return = parent::parseResponse($part->headers, $part->body); |
| 244 | 244 | } else {
|
| 245 | - $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 245 | + $this->debug('Have an attachment of type '.$part->headers['content-type']);
|
|
| 246 | 246 | $info['data'] = $part->body; |
| 247 | 247 | $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
| 248 | 248 | $info['contenttype'] = $part->headers['content-type']; |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * @access public |
| 317 | 317 | */ |
| 318 | 318 | function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
|
| 319 | - if (! $cid) {
|
|
| 319 | + if (!$cid) {
|
|
| 320 | 320 | $cid = md5(uniqid(time())); |
| 321 | 321 | } |
| 322 | 322 | |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | * @access private |
| 452 | 452 | */ |
| 453 | 453 | function parseRequest($headers, $data) {
|
| 454 | - $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
|
|
| 454 | + $this->debug('Entering parseRequest() for payload of length '.strlen($data).' and type of '.$headers['content-type']);
|
|
| 455 | 455 | $this->requestAttachments = array(); |
| 456 | 456 | if (strstr($headers['content-type'], 'multipart/related')) {
|
| 457 | 457 | $this->debug('Decode multipart/related');
|
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | foreach ($headers as $k => $v) {
|
| 460 | 460 | $input .= "$k: $v\r\n"; |
| 461 | 461 | } |
| 462 | - $params['input'] = $input . "\r\n" . $data; |
|
| 462 | + $params['input'] = $input."\r\n".$data; |
|
| 463 | 463 | $params['include_bodies'] = true; |
| 464 | 464 | $params['decode_bodies'] = true; |
| 465 | 465 | $params['decode_headers'] = true; |
@@ -468,10 +468,10 @@ discard block |
||
| 468 | 468 | |
| 469 | 469 | foreach ($structure->parts as $part) {
|
| 470 | 470 | if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
|
| 471 | - $this->debug('Have root part of type ' . $part->headers['content-type']);
|
|
| 471 | + $this->debug('Have root part of type '.$part->headers['content-type']);
|
|
| 472 | 472 | $return = parent::parseRequest($part->headers, $part->body); |
| 473 | 473 | } else {
|
| 474 | - $this->debug('Have an attachment of type ' . $part->headers['content-type']);
|
|
| 474 | + $this->debug('Have an attachment of type '.$part->headers['content-type']);
|
|
| 475 | 475 | $info['data'] = $part->body; |
| 476 | 476 | $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
| 477 | 477 | $info['contenttype'] = $part->headers['content-type']; |
@@ -208,6 +208,8 @@ discard block |
||
| 208 | 208 | } |
| 209 | 209 | /** |
| 210 | 210 | * Gives a list of people online now (and in the last $valid minutes) |
| 211 | + * @param integer $from |
|
| 212 | + * @param integer $time_limit |
|
| 211 | 213 | * @return array For each line, a list of user IDs and login dates, or FALSE on error or empty results |
| 212 | 214 | */ |
| 213 | 215 | function who_is_online($from, $number_of_items, $column = null, $direction = null, $time_limit = null, $friends = false) |
@@ -424,6 +426,9 @@ discard block |
||
| 424 | 426 | } |
| 425 | 427 | } |
| 426 | 428 | |
| 429 | +/** |
|
| 430 | + * @param integer $uid |
|
| 431 | + */ |
|
| 427 | 432 | function who_is_online_in_this_course_count($uid, $time_limit, $coursecode=null) |
| 428 | 433 | { |
| 429 | 434 | if (empty($coursecode)) { |
@@ -389,7 +389,9 @@ |
||
| 389 | 389 | */ |
| 390 | 390 | function who_is_online_in_this_course($from, $number_of_items, $uid, $time_limit, $course_code) |
| 391 | 391 | { |
| 392 | - if (empty($course_code)) return false; |
|
| 392 | + if (empty($course_code)) { |
|
| 393 | + return false; |
|
| 394 | + } |
|
| 393 | 395 | |
| 394 | 396 | if (empty($time_limit)) { |
| 395 | 397 | $time_limit = api_get_setting('time_limit_whosonline'); |
@@ -165,10 +165,10 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | function LoginDelete($user_id) |
| 167 | 167 | { |
| 168 | - $online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 168 | + $online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 169 | 169 | $user_id = intval($user_id); |
| 170 | - $query = "DELETE FROM " . $online_table . " WHERE login_user_id = $user_id"; |
|
| 171 | - Database::query($query); |
|
| 170 | + $query = "DELETE FROM " . $online_table . " WHERE login_user_id = $user_id"; |
|
| 171 | + Database::query($query); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -177,17 +177,17 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | function user_is_online($user_id) |
| 179 | 179 | { |
| 180 | - $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 181 | - $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 180 | + $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 181 | + $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 182 | 182 | |
| 183 | - $access_url_id = api_get_current_access_url_id(); |
|
| 184 | - $time_limit = api_get_setting('time_limit_whosonline'); |
|
| 183 | + $access_url_id = api_get_current_access_url_id(); |
|
| 184 | + $time_limit = api_get_setting('time_limit_whosonline'); |
|
| 185 | 185 | |
| 186 | 186 | $online_time = time() - $time_limit*60; |
| 187 | 187 | $limit_date = api_get_utc_datetime($online_time); |
| 188 | 188 | $user_id = intval($user_id); |
| 189 | 189 | |
| 190 | - $query = " SELECT login_user_id,login_date |
|
| 190 | + $query = " SELECT login_user_id,login_date |
|
| 191 | 191 | FROM $track_online_table track |
| 192 | 192 | INNER JOIN $table_user u ON (u.id=track.login_user_id) |
| 193 | 193 | WHERE |
@@ -196,13 +196,13 @@ discard block |
||
| 196 | 196 | u.id = $user_id |
| 197 | 197 | LIMIT 1 "; |
| 198 | 198 | |
| 199 | - $result = Database::query($query); |
|
| 200 | - if (Database::num_rows($result)) { |
|
| 199 | + $result = Database::query($query); |
|
| 200 | + if (Database::num_rows($result)) { |
|
| 201 | 201 | |
| 202 | - return true; |
|
| 203 | - } |
|
| 202 | + return true; |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - return false; |
|
| 205 | + return false; |
|
| 206 | 206 | |
| 207 | 207 | } |
| 208 | 208 | /** |
@@ -238,13 +238,13 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | $online_time = time() - $time_limit * 60; |
| 240 | 240 | $current_date = api_get_utc_datetime($online_time); |
| 241 | - $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 242 | - $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
|
| 243 | - $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 241 | + $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 242 | + $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
|
| 243 | + $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 244 | 244 | |
| 245 | - if ($friends) { |
|
| 246 | - // who friends from social network is online |
|
| 247 | - $query = "SELECT DISTINCT login_user_id, login_date |
|
| 245 | + if ($friends) { |
|
| 246 | + // who friends from social network is online |
|
| 247 | + $query = "SELECT DISTINCT login_user_id, login_date |
|
| 248 | 248 | FROM $track_online_table INNER JOIN $friend_user_table |
| 249 | 249 | ON (friend_user_id = login_user_id) |
| 250 | 250 | WHERE |
@@ -254,21 +254,21 @@ discard block |
||
| 254 | 254 | user_id = '".api_get_user_id()."' |
| 255 | 255 | ORDER BY $column $direction |
| 256 | 256 | LIMIT $from, $number_of_items"; |
| 257 | - } else { |
|
| 258 | - $query = "SELECT DISTINCT login_user_id, login_date |
|
| 257 | + } else { |
|
| 258 | + $query = "SELECT DISTINCT login_user_id, login_date |
|
| 259 | 259 | FROM ".$track_online_table ." e |
| 260 | 260 | INNER JOIN ".$table_user ." u ON (u.id = e.login_user_id) |
| 261 | 261 | WHERE u.status != ".ANONYMOUS." AND login_date >= '".$current_date."' |
| 262 | 262 | ORDER BY $column $direction |
| 263 | 263 | LIMIT $from, $number_of_items"; |
| 264 | - } |
|
| 265 | - |
|
| 266 | - if (api_get_multiple_access_url()) { |
|
| 267 | - $access_url_id = api_get_current_access_url_id(); |
|
| 268 | - if ($access_url_id != -1) { |
|
| 269 | - if ($friends) { |
|
| 270 | - // friends from social network is online |
|
| 271 | - $query = "SELECT distinct login_user_id, login_date |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + if (api_get_multiple_access_url()) { |
|
| 267 | + $access_url_id = api_get_current_access_url_id(); |
|
| 268 | + if ($access_url_id != -1) { |
|
| 269 | + if ($friends) { |
|
| 270 | + // friends from social network is online |
|
| 271 | + $query = "SELECT distinct login_user_id, login_date |
|
| 272 | 272 | FROM $track_online_table track INNER JOIN $friend_user_table |
| 273 | 273 | ON (friend_user_id = login_user_id) |
| 274 | 274 | WHERE track.access_url_id = $access_url_id AND |
@@ -277,9 +277,9 @@ discard block |
||
| 277 | 277 | relation_type='".USER_RELATION_TYPE_FRIEND."' |
| 278 | 278 | ORDER BY $column $direction |
| 279 | 279 | LIMIT $from, $number_of_items"; |
| 280 | - } else { |
|
| 281 | - // all users online |
|
| 282 | - $query = "SELECT login_user_id, login_date |
|
| 280 | + } else { |
|
| 281 | + // all users online |
|
| 282 | + $query = "SELECT login_user_id, login_date |
|
| 283 | 283 | FROM ".$track_online_table ." track |
| 284 | 284 | INNER JOIN ".$table_user ." u |
| 285 | 285 | ON (u.id=track.login_user_id) |
@@ -287,26 +287,26 @@ discard block |
||
| 287 | 287 | login_date >= '".$current_date."' |
| 288 | 288 | ORDER BY $column $direction |
| 289 | 289 | LIMIT $from, $number_of_items"; |
| 290 | - } |
|
| 291 | - } |
|
| 292 | - } |
|
| 290 | + } |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | - //This query will show all registered users. Only for dev purposes. |
|
| 295 | - /*$query = "SELECT DISTINCT u.id as login_user_id, login_date FROM ".$track_online_table ." e , $table_user u |
|
| 294 | + //This query will show all registered users. Only for dev purposes. |
|
| 295 | + /*$query = "SELECT DISTINCT u.id as login_user_id, login_date FROM ".$track_online_table ." e , $table_user u |
|
| 296 | 296 | GROUP by u.id |
| 297 | 297 | ORDER BY $column $direction |
| 298 | 298 | LIMIT $from, $number_of_items";*/ |
| 299 | 299 | |
| 300 | - $result = Database::query($query); |
|
| 301 | - if ($result) { |
|
| 302 | - $users_online = array(); |
|
| 303 | - while (list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
| 300 | + $result = Database::query($query); |
|
| 301 | + if ($result) { |
|
| 302 | + $users_online = array(); |
|
| 303 | + while (list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
| 304 | 304 | $users_online[] = $login_user_id; |
| 305 | - } |
|
| 306 | - return $users_online; |
|
| 307 | - } else { |
|
| 308 | - return false; |
|
| 309 | - } |
|
| 305 | + } |
|
| 306 | + return $users_online; |
|
| 307 | + } else { |
|
| 308 | + return false; |
|
| 309 | + } |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | function who_is_online_count($time_limit = null, $friends = false) |
@@ -316,15 +316,15 @@ discard block |
||
| 316 | 316 | } else { |
| 317 | 317 | $time_limit = intval($time_limit); |
| 318 | 318 | } |
| 319 | - $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 320 | - $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
|
| 321 | - $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 322 | - $online_time = time() - $time_limit * 60; |
|
| 323 | - $current_date = api_get_utc_datetime($online_time); |
|
| 324 | - |
|
| 325 | - if ($friends) { |
|
| 326 | - // who friends from social network is online |
|
| 327 | - $query = "SELECT DISTINCT count(login_user_id) as count |
|
| 319 | + $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 320 | + $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
|
| 321 | + $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 322 | + $online_time = time() - $time_limit * 60; |
|
| 323 | + $current_date = api_get_utc_datetime($online_time); |
|
| 324 | + |
|
| 325 | + if ($friends) { |
|
| 326 | + // who friends from social network is online |
|
| 327 | + $query = "SELECT DISTINCT count(login_user_id) as count |
|
| 328 | 328 | FROM $track_online_table INNER JOIN $friend_user_table |
| 329 | 329 | ON (friend_user_id = login_user_id) |
| 330 | 330 | WHERE |
@@ -332,20 +332,20 @@ discard block |
||
| 332 | 332 | friend_user_id <> '".api_get_user_id()."' AND |
| 333 | 333 | relation_type='".USER_RELATION_TYPE_FRIEND."' AND |
| 334 | 334 | user_id = '".api_get_user_id()."' "; |
| 335 | - } else { |
|
| 336 | - // All users online |
|
| 337 | - $query = "SELECT count(login_id) as count |
|
| 335 | + } else { |
|
| 336 | + // All users online |
|
| 337 | + $query = "SELECT count(login_id) as count |
|
| 338 | 338 | FROM $track_online_table track INNER JOIN $table_user u |
| 339 | 339 | ON (u.id=track.login_user_id) |
| 340 | 340 | WHERE u.status != ".ANONYMOUS." AND login_date >= '$current_date' "; |
| 341 | - } |
|
| 342 | - |
|
| 343 | - if (api_get_multiple_access_url()) { |
|
| 344 | - $access_url_id = api_get_current_access_url_id(); |
|
| 345 | - if ($access_url_id != -1) { |
|
| 346 | - if ($friends) { |
|
| 347 | - // friends from social network is online |
|
| 348 | - $query = "SELECT DISTINCT count(login_user_id) as count |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + if (api_get_multiple_access_url()) { |
|
| 344 | + $access_url_id = api_get_current_access_url_id(); |
|
| 345 | + if ($access_url_id != -1) { |
|
| 346 | + if ($friends) { |
|
| 347 | + // friends from social network is online |
|
| 348 | + $query = "SELECT DISTINCT count(login_user_id) as count |
|
| 349 | 349 | FROM $track_online_table track |
| 350 | 350 | INNER JOIN $friend_user_table ON (friend_user_id = login_user_id) |
| 351 | 351 | WHERE |
@@ -353,29 +353,29 @@ discard block |
||
| 353 | 353 | login_date >= '".$current_date."' AND |
| 354 | 354 | friend_user_id <> '".api_get_user_id()."' AND |
| 355 | 355 | relation_type='".USER_RELATION_TYPE_FRIEND."' "; |
| 356 | - } else { |
|
| 357 | - // all users online |
|
| 358 | - $query = "SELECT count(login_id) as count FROM $track_online_table track |
|
| 356 | + } else { |
|
| 357 | + // all users online |
|
| 358 | + $query = "SELECT count(login_id) as count FROM $track_online_table track |
|
| 359 | 359 | INNER JOIN $table_user u ON (u.id=track.login_user_id) |
| 360 | 360 | WHERE |
| 361 | 361 | u.status != ".ANONYMOUS." AND |
| 362 | 362 | track.access_url_id = $access_url_id AND |
| 363 | 363 | login_date >= '$current_date' "; |
| 364 | - } |
|
| 365 | - } |
|
| 366 | - } |
|
| 364 | + } |
|
| 365 | + } |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | 368 | // Dev purposes show all users online |
| 369 | 369 | /*$table_user = Database::get_main_table(TABLE_MAIN_USER); |
| 370 | 370 | $query = "SELECT count(*) as count FROM ".$table_user;*/ |
| 371 | 371 | |
| 372 | - $result = Database::query($query); |
|
| 373 | - if (Database::num_rows($result) > 0) { |
|
| 374 | - $row = Database::fetch_array($result); |
|
| 375 | - return $row['count']; |
|
| 376 | - } else { |
|
| 377 | - return false; |
|
| 378 | - } |
|
| 372 | + $result = Database::query($query); |
|
| 373 | + if (Database::num_rows($result) > 0) { |
|
| 374 | + $row = Database::fetch_array($result); |
|
| 375 | + return $row['count']; |
|
| 376 | + } else { |
|
| 377 | + return false; |
|
| 378 | + } |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | */ |
| 389 | 389 | function who_is_online_in_this_course($from, $number_of_items, $uid, $time_limit, $course_code) |
| 390 | 390 | { |
| 391 | - if (empty($course_code)) return false; |
|
| 391 | + if (empty($course_code)) return false; |
|
| 392 | 392 | |
| 393 | 393 | if (empty($time_limit)) { |
| 394 | 394 | $time_limit = api_get_setting('time_limit_whosonline'); |
@@ -401,55 +401,55 @@ discard block |
||
| 401 | 401 | $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
| 402 | 402 | $course_code = Database::escape_string($course_code); |
| 403 | 403 | $courseInfo = api_get_course_info($course_code); |
| 404 | - $courseId = $courseInfo['real_id']; |
|
| 404 | + $courseId = $courseInfo['real_id']; |
|
| 405 | 405 | |
| 406 | 406 | $from = intval($from); |
| 407 | 407 | $number_of_items = intval($number_of_items); |
| 408 | 408 | |
| 409 | - $query = "SELECT login_user_id, login_date FROM $track_online_table |
|
| 409 | + $query = "SELECT login_user_id, login_date FROM $track_online_table |
|
| 410 | 410 | WHERE login_user_id <> 2 AND c_id = $courseId AND login_date >= '$current_date' |
| 411 | 411 | LIMIT $from, $number_of_items "; |
| 412 | 412 | |
| 413 | - $result = Database::query($query); |
|
| 414 | - if ($result) { |
|
| 415 | - $users_online = array(); |
|
| 413 | + $result = Database::query($query); |
|
| 414 | + if ($result) { |
|
| 415 | + $users_online = array(); |
|
| 416 | 416 | |
| 417 | - while(list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
| 417 | + while(list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
| 418 | 418 | $users_online[] = $login_user_id; |
| 419 | - } |
|
| 420 | - return $users_online; |
|
| 421 | - } else { |
|
| 422 | - return false; |
|
| 423 | - } |
|
| 419 | + } |
|
| 420 | + return $users_online; |
|
| 421 | + } else { |
|
| 422 | + return false; |
|
| 423 | + } |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | function who_is_online_in_this_course_count($uid, $time_limit, $coursecode=null) |
| 427 | 427 | { |
| 428 | - if (empty($coursecode)) { |
|
| 429 | - return false; |
|
| 430 | - } |
|
| 431 | - $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 432 | - $coursecode = Database::escape_string($coursecode); |
|
| 433 | - $time_limit = Database::escape_string($time_limit); |
|
| 428 | + if (empty($coursecode)) { |
|
| 429 | + return false; |
|
| 430 | + } |
|
| 431 | + $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
| 432 | + $coursecode = Database::escape_string($coursecode); |
|
| 433 | + $time_limit = Database::escape_string($time_limit); |
|
| 434 | 434 | |
| 435 | 435 | $online_time = time() - $time_limit * 60; |
| 436 | 436 | $current_date = api_get_utc_datetime($online_time); |
| 437 | - $courseId = api_get_course_int_id($coursecode); |
|
| 437 | + $courseId = api_get_course_int_id($coursecode); |
|
| 438 | 438 | |
| 439 | - if (empty($courseId)) { |
|
| 440 | - return false; |
|
| 441 | - } |
|
| 439 | + if (empty($courseId)) { |
|
| 440 | + return false; |
|
| 441 | + } |
|
| 442 | 442 | |
| 443 | - $query = "SELECT count(login_user_id) as count |
|
| 443 | + $query = "SELECT count(login_user_id) as count |
|
| 444 | 444 | FROM $track_online_table |
| 445 | 445 | WHERE login_user_id <> 2 AND c_id = $courseId AND login_date >= '$current_date' "; |
| 446 | - $result = Database::query($query); |
|
| 447 | - if (Database::num_rows($result) > 0) { |
|
| 448 | - $row = Database::fetch_array($result); |
|
| 449 | - return $row['count']; |
|
| 450 | - } else { |
|
| 451 | - return false; |
|
| 452 | - } |
|
| 446 | + $result = Database::query($query); |
|
| 447 | + if (Database::num_rows($result) > 0) { |
|
| 448 | + $row = Database::fetch_array($result); |
|
| 449 | + return $row['count']; |
|
| 450 | + } else { |
|
| 451 | + return false; |
|
| 452 | + } |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | /** |
@@ -459,15 +459,15 @@ discard block |
||
| 459 | 459 | * @deprecated user api_get_user_info($user_id) |
| 460 | 460 | */ |
| 461 | 461 | function GetFullUserName($uid) { |
| 462 | - $uid = (int) $uid; |
|
| 463 | - $uid = intval($uid); |
|
| 464 | - $user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
| 465 | - $query = "SELECT firstname, lastname FROM ".$user_table." WHERE id=$uid"; |
|
| 466 | - $result = @Database::query($query); |
|
| 467 | - if (count($result)>0) { |
|
| 468 | - while(list($firstname,$lastname)= Database::fetch_array($result)) { |
|
| 469 | - $str = str_replace(' ', ' ', api_get_person_name($firstname, $lastname)); |
|
| 470 | - return $str; |
|
| 471 | - } |
|
| 472 | - } |
|
| 462 | + $uid = (int) $uid; |
|
| 463 | + $uid = intval($uid); |
|
| 464 | + $user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
| 465 | + $query = "SELECT firstname, lastname FROM ".$user_table." WHERE id=$uid"; |
|
| 466 | + $result = @Database::query($query); |
|
| 467 | + if (count($result)>0) { |
|
| 468 | + while(list($firstname,$lastname)= Database::fetch_array($result)) { |
|
| 469 | + $str = str_replace(' ', ' ', api_get_person_name($firstname, $lastname)); |
|
| 470 | + return $str; |
|
| 471 | + } |
|
| 472 | + } |
|
| 473 | 473 | } |
@@ -32,17 +32,17 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | $login_date = api_get_utc_datetime(); |
| 34 | 34 | $access_url_id = 1; |
| 35 | - if (api_get_multiple_access_url() && api_get_current_access_url_id()!=-1) { |
|
| 35 | + if (api_get_multiple_access_url() && api_get_current_access_url_id() != -1) { |
|
| 36 | 36 | $access_url_id = api_get_current_access_url_id(); |
| 37 | 37 | } |
| 38 | 38 | $session_id = api_get_session_id(); |
| 39 | 39 | // if the $_course array exists this means we are in a course and we have to store this in the who's online table also |
| 40 | 40 | // to have the x users in this course feature working |
| 41 | - if (is_array($_course) && count($_course)>0 && !empty($_course['id'])) { |
|
| 42 | - $query = "REPLACE INTO ".$online_table ." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id) |
|
| 41 | + if (is_array($_course) && count($_course) > 0 && !empty($_course['id'])) { |
|
| 42 | + $query = "REPLACE INTO ".$online_table." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id) |
|
| 43 | 43 | VALUES ($uid,$uid,'$login_date','$user_ip', '".$_course['real_id']."' , '$session_id' , '$access_url_id' )"; |
| 44 | 44 | } else { |
| 45 | - $query = "REPLACE INTO ".$online_table ." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id) |
|
| 45 | + $query = "REPLACE INTO ".$online_table." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id) |
|
| 46 | 46 | VALUES ($uid,$uid,'$login_date','$user_ip', 0, '$session_id', '$access_url_id')"; |
| 47 | 47 | } |
| 48 | 48 | Database::query($query); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $isFirstLogin = Session::read('first_user_login'); |
| 64 | 64 | if (empty($isFirstLogin)) { |
| 65 | 65 | $sql = "SELECT login_id FROM $table |
| 66 | - WHERE login_user_id = " . $userId . " LIMIT 1"; |
|
| 66 | + WHERE login_user_id = ".$userId." LIMIT 1"; |
|
| 67 | 67 | |
| 68 | 68 | $result = Database::query($sql); |
| 69 | 69 | $loginData = array(); |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | ORDER BY login_date DESC |
| 118 | 118 | LIMIT 0,1"; |
| 119 | 119 | $q_last_connection = Database::query($sql); |
| 120 | - if (Database::num_rows($q_last_connection)>0) { |
|
| 121 | - $i_id_last_connection = Database::result($q_last_connection,0,"login_id"); |
|
| 120 | + if (Database::num_rows($q_last_connection) > 0) { |
|
| 121 | + $i_id_last_connection = Database::result($q_last_connection, 0, "login_id"); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | if (!isset($_SESSION['login_as'])) { |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | { |
| 168 | 168 | $online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
| 169 | 169 | $user_id = intval($user_id); |
| 170 | - $query = "DELETE FROM " . $online_table . " WHERE login_user_id = $user_id"; |
|
| 170 | + $query = "DELETE FROM ".$online_table." WHERE login_user_id = $user_id"; |
|
| 171 | 171 | Database::query($query); |
| 172 | 172 | } |
| 173 | 173 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $access_url_id = api_get_current_access_url_id(); |
| 184 | 184 | $time_limit = api_get_setting('time_limit_whosonline'); |
| 185 | 185 | |
| 186 | - $online_time = time() - $time_limit*60; |
|
| 186 | + $online_time = time() - $time_limit * 60; |
|
| 187 | 187 | $limit_date = api_get_utc_datetime($online_time); |
| 188 | 188 | $user_id = intval($user_id); |
| 189 | 189 | |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | $current_date = api_get_utc_datetime($online_time); |
| 241 | 241 | $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
| 242 | 242 | $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
| 243 | - $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 243 | + $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 244 | 244 | |
| 245 | 245 | if ($friends) { |
| 246 | 246 | // who friends from social network is online |
@@ -256,8 +256,8 @@ discard block |
||
| 256 | 256 | LIMIT $from, $number_of_items"; |
| 257 | 257 | } else { |
| 258 | 258 | $query = "SELECT DISTINCT login_user_id, login_date |
| 259 | - FROM ".$track_online_table ." e |
|
| 260 | - INNER JOIN ".$table_user ." u ON (u.id = e.login_user_id) |
|
| 259 | + FROM ".$track_online_table." e |
|
| 260 | + INNER JOIN ".$table_user." u ON (u.id = e.login_user_id) |
|
| 261 | 261 | WHERE u.status != ".ANONYMOUS." AND login_date >= '".$current_date."' |
| 262 | 262 | ORDER BY $column $direction |
| 263 | 263 | LIMIT $from, $number_of_items"; |
@@ -280,8 +280,8 @@ discard block |
||
| 280 | 280 | } else { |
| 281 | 281 | // all users online |
| 282 | 282 | $query = "SELECT login_user_id, login_date |
| 283 | - FROM ".$track_online_table ." track |
|
| 284 | - INNER JOIN ".$table_user ." u |
|
| 283 | + FROM ".$track_online_table." track |
|
| 284 | + INNER JOIN ".$table_user." u |
|
| 285 | 285 | ON (u.id=track.login_user_id) |
| 286 | 286 | WHERE u.status != ".ANONYMOUS." AND track.access_url_id = $access_url_id AND |
| 287 | 287 | login_date >= '".$current_date."' |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | if ($result) { |
| 415 | 415 | $users_online = array(); |
| 416 | 416 | |
| 417 | - while(list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
| 417 | + while (list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
| 418 | 418 | $users_online[] = $login_user_id; |
| 419 | 419 | } |
| 420 | 420 | return $users_online; |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | } |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | -function who_is_online_in_this_course_count($uid, $time_limit, $coursecode=null) |
|
| 426 | +function who_is_online_in_this_course_count($uid, $time_limit, $coursecode = null) |
|
| 427 | 427 | { |
| 428 | 428 | if (empty($coursecode)) { |
| 429 | 429 | return false; |
@@ -464,8 +464,8 @@ discard block |
||
| 464 | 464 | $user_table = Database::get_main_table(TABLE_MAIN_USER); |
| 465 | 465 | $query = "SELECT firstname, lastname FROM ".$user_table." WHERE id=$uid"; |
| 466 | 466 | $result = @Database::query($query); |
| 467 | - if (count($result)>0) { |
|
| 468 | - while(list($firstname,$lastname)= Database::fetch_array($result)) { |
|
| 467 | + if (count($result) > 0) { |
|
| 468 | + while (list($firstname, $lastname) = Database::fetch_array($result)) { |
|
| 469 | 469 | $str = str_replace(' ', ' ', api_get_person_name($firstname, $lastname)); |
| 470 | 470 | return $str; |
| 471 | 471 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | 145 | * Returns the contents of the CSS defined by the plugin |
| 146 | - * @return array |
|
| 146 | + * @return string |
|
| 147 | 147 | */ |
| 148 | 148 | public function get_css() |
| 149 | 149 | { |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | |
| 162 | 162 | /** |
| 163 | 163 | * Returns an HTML form (generated by FormValidator) of the plugin settings |
| 164 | - * @return string FormValidator-generated form |
|
| 164 | + * @return FormValidator FormValidator-generated form |
|
| 165 | 165 | */ |
| 166 | 166 | public function get_settings_form() |
| 167 | 167 | { |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | * @param boolean $add_tool_link Whether to add a tool link or not |
| 384 | 384 | * (some tools might just offer a configuration section and act on the backend) |
| 385 | 385 | * |
| 386 | - * @return boolean False on error, null otherwise |
|
| 386 | + * @return boolean|null False on error, null otherwise |
|
| 387 | 387 | */ |
| 388 | 388 | public function install_course_fields($courseId, $add_tool_link = true) |
| 389 | 389 | { |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | * tool on the course's homepage |
| 492 | 492 | * @param int $courseId |
| 493 | 493 | * |
| 494 | - * @return void |
|
| 494 | + * @return false|null |
|
| 495 | 495 | */ |
| 496 | 496 | public function uninstall_course_fields($courseId) |
| 497 | 497 | { |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | * @param string $tabName |
| 597 | 597 | * @param string $url |
| 598 | 598 | * |
| 599 | - * @return boolean |
|
| 599 | + * @return false|string |
|
| 600 | 600 | */ |
| 601 | 601 | public function addTab($tabName, $url) |
| 602 | 602 | { |
@@ -591,13 +591,13 @@ |
||
| 591 | 591 | |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | - /** |
|
| 595 | - * Add a tab to platform |
|
| 596 | - * @param string $tabName |
|
| 597 | - * @param string $url |
|
| 598 | - * |
|
| 599 | - * @return boolean |
|
| 600 | - */ |
|
| 594 | + /** |
|
| 595 | + * Add a tab to platform |
|
| 596 | + * @param string $tabName |
|
| 597 | + * @param string $url |
|
| 598 | + * |
|
| 599 | + * @return boolean |
|
| 600 | + */ |
|
| 601 | 601 | public function addTab($tabName, $url) |
| 602 | 602 | { |
| 603 | 603 | $sql = "SELECT * FROM settings_current |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $this->fields = $settings; |
| 61 | 61 | |
| 62 | 62 | global $language_files; |
| 63 | - $language_files[] = 'plugin_' . $this->get_name(); |
|
| 63 | + $language_files[] = 'plugin_'.$this->get_name(); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | { |
| 269 | 269 | $settings = $this->get_settings(); |
| 270 | 270 | foreach ($settings as $setting) { |
| 271 | - if ($setting['variable'] == $this->get_name() . '_' . $name) { |
|
| 271 | + if ($setting['variable'] == $this->get_name().'_'.$name) { |
|
| 272 | 272 | |
| 273 | 273 | return $setting['selected_value']; |
| 274 | 274 | } |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | if (!empty($this->course_settings)) { |
| 405 | 405 | foreach ($this->course_settings as $setting) { |
| 406 | 406 | $variable = $setting['name']; |
| 407 | - $value =''; |
|
| 407 | + $value = ''; |
|
| 408 | 408 | if (isset($setting['init_value'])) { |
| 409 | 409 | $value = $setting['init_value']; |
| 410 | 410 | } |
@@ -618,7 +618,7 @@ discard block |
||
| 618 | 618 | |
| 619 | 619 | // Avoid Tab Name Spaces |
| 620 | 620 | $tabNameNoSpaces = preg_replace('/\s+/', '', $tabName); |
| 621 | - $subkeytext = "Tabs" . $tabNameNoSpaces; |
|
| 621 | + $subkeytext = "Tabs".$tabNameNoSpaces; |
|
| 622 | 622 | |
| 623 | 623 | // Check if it is already added |
| 624 | 624 | $checkCondition = array( |
@@ -637,7 +637,7 @@ discard block |
||
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | // End Check |
| 640 | - $subkey = 'custom_tab_' . $tabNum; |
|
| 640 | + $subkey = 'custom_tab_'.$tabNum; |
|
| 641 | 641 | $attributes = array( |
| 642 | 642 | 'variable' => 'show_tabs', |
| 643 | 643 | 'subkey' => $subkey, |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | |
| 656 | 656 | // Save the id |
| 657 | 657 | $settings = $this->get_settings(); |
| 658 | - $setData = array ( |
|
| 658 | + $setData = array( |
|
| 659 | 659 | 'comment' => $subkey |
| 660 | 660 | ); |
| 661 | 661 | $whereCondition = array( |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | $i = 1; |
| 697 | 697 | foreach ($tabs as $row) { |
| 698 | 698 | $attributes = array( |
| 699 | - 'subkey' => 'custom_tab_' . $i |
|
| 699 | + 'subkey' => 'custom_tab_'.$i |
|
| 700 | 700 | ); |
| 701 | 701 | $this->updateTab($row['subkey'], $attributes); |
| 702 | 702 | $i++; |
@@ -126,6 +126,7 @@ discard block |
||
| 126 | 126 | * Returns a temporary url to download files and/or folders. |
| 127 | 127 | * |
| 128 | 128 | * @param string|array $ids |
| 129 | + * @param string $tool |
|
| 129 | 130 | * @return string |
| 130 | 131 | */ |
| 131 | 132 | public static function download_url($ids, $tool) |
@@ -293,7 +294,7 @@ discard block |
||
| 293 | 294 | /** |
| 294 | 295 | * The name of the porfolio where to send. |
| 295 | 296 | * |
| 296 | - * @return type |
|
| 297 | + * @return string |
|
| 297 | 298 | */ |
| 298 | 299 | function get_portfolio() |
| 299 | 300 | { |
@@ -391,7 +392,6 @@ discard block |
||
| 391 | 392 | * Create a "send to portfolio" button |
| 392 | 393 | * |
| 393 | 394 | * @param string $tool The name of the tool: document, work. |
| 394 | - * @param int $c_id The id of the course |
|
| 395 | 395 | * @param int $id The id of the object |
| 396 | 396 | * @param array $attributes Html attributes |
| 397 | 397 | * @return \PortfolioShare |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | /** |
| 406 | 406 | * Returns the current secuirty token. Used to avoid see surfing attacks. |
| 407 | 407 | * |
| 408 | - * @return type |
|
| 408 | + * @return string |
|
| 409 | 409 | */ |
| 410 | 410 | static function security_token() |
| 411 | 411 | { |
@@ -420,6 +420,10 @@ discard block |
||
| 420 | 420 | protected $attributes = array(); |
| 421 | 421 | protected $tool = ''; |
| 422 | 422 | |
| 423 | + /** |
|
| 424 | + * @param string $tool |
|
| 425 | + * @param integer $id |
|
| 426 | + */ |
|
| 423 | 427 | function __construct($tool, $id, $attributes = array()) |
| 424 | 428 | { |
| 425 | 429 | $this->tool = $tool; |
@@ -482,14 +482,14 @@ discard block |
||
| 482 | 482 | $attributes['z-index'] = 100000; |
| 483 | 483 | $s = ' '; |
| 484 | 484 | foreach ($attributes as $key => $value) { |
| 485 | - $s .= $key . '="' . $value . '" '; |
|
| 485 | + $s .= $key.'="'.$value.'" '; |
|
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | $result = array(); |
| 489 | - $result[] = '<span ' . $s . ' >'; |
|
| 489 | + $result[] = '<span '.$s.' >'; |
|
| 490 | 490 | $result[] = '<span class="dropdown" >'; |
| 491 | 491 | $result[] = '<a href="#" data-toggle="dropdown" class="dropdown-toggle">'; |
| 492 | - $result[] = Display::return_icon('document_send.png', get_lang('Send'), array(), ICON_SIZE_SMALL) . '<b class="caret"></b>'; |
|
| 492 | + $result[] = Display::return_icon('document_send.png', get_lang('Send'), array(), ICON_SIZE_SMALL).'<b class="caret"></b>'; |
|
| 493 | 493 | $result[] = '</a>'; |
| 494 | 494 | $result[] = '<ul class="dropdown-menu">'; |
| 495 | 495 | |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | $parameters[PortfolioController::PARAM_TOOL] = $tool; |
| 506 | 506 | $url = api_get_path(WEB_CODE_PATH).'portfolio/share.php?'; |
| 507 | 507 | $result[] = '<li>'; |
| 508 | - $result[] = '<a href="' . $url . '">' . $portfolio->get_title() . '</a>'; |
|
| 508 | + $result[] = '<a href="'.$url.'">'.$portfolio->get_title().'</a>'; |
|
| 509 | 509 | $result[] = '</li>'; |
| 510 | 510 | } |
| 511 | 511 | $result[] = '</ul>'; |
@@ -564,8 +564,8 @@ discard block |
||
| 564 | 564 | */ |
| 565 | 565 | public function __construct($portfolio) |
| 566 | 566 | { |
| 567 | - $this->name = md5(__CLASS__) . '_' . $portfolio->get_name(); |
|
| 568 | - $this->title = $portfolio->get_title() ? $portfolio->get_title() : get_lang('SendTo') . ' ' . $portfolio->get_name(); |
|
| 567 | + $this->name = md5(__CLASS__).'_'.$portfolio->get_name(); |
|
| 568 | + $this->title = $portfolio->get_title() ? $portfolio->get_title() : get_lang('SendTo').' '.$portfolio->get_name(); |
|
| 569 | 569 | $this->portfolio = $portfolio; |
| 570 | 570 | } |
| 571 | 571 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
| 132 | - * @return array |
|
| 132 | + * @return string[] |
|
| 133 | 133 | */ |
| 134 | 134 | public function get_status_list() |
| 135 | 135 | { |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | /** |
| 273 | 273 | * @param int $id |
| 274 | 274 | * |
| 275 | - * @return bool |
|
| 275 | + * @return null|false |
|
| 276 | 276 | */ |
| 277 | 277 | public function delete($id) |
| 278 | 278 | { |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | case 'updated_at': |
| 58 | 58 | break; |
| 59 | 59 | case 'name': |
| 60 | - $val .= ' ' . get_lang('CopyLabelSuffix'); |
|
| 60 | + $val .= ' '.get_lang('CopyLabelSuffix'); |
|
| 61 | 61 | $new[$key] = $val; |
| 62 | 62 | break; |
| 63 | 63 | case 'created_at': |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | break; |
| 67 | 67 | case 'career_id': |
| 68 | 68 | if (!empty($career_id)) { |
| 69 | - $val = (int)$career_id; |
|
| 69 | + $val = (int) $career_id; |
|
| 70 | 70 | } |
| 71 | 71 | $new[$key] = $val; |
| 72 | 72 | break; |
@@ -147,12 +147,12 @@ discard block |
||
| 147 | 147 | { |
| 148 | 148 | // Action links |
| 149 | 149 | echo '<div class="actions" style="margin-bottom:20px">'; |
| 150 | - echo '<a href="career_dashboard.php">' . Display::return_icon('back.png', |
|
| 151 | - get_lang('Back'), '', '32') . '</a>'; |
|
| 152 | - echo '<a href="' . api_get_self() . '?action=add">' . Display::return_icon('new_promotion.png', |
|
| 153 | - get_lang('Add'), '', '32') . '</a>'; |
|
| 154 | - echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'session/session_add.php">' . Display::return_icon('new_session.png', |
|
| 155 | - get_lang('AddSession'), '', '32') . '</a>'; |
|
| 150 | + echo '<a href="career_dashboard.php">'.Display::return_icon('back.png', |
|
| 151 | + get_lang('Back'), '', '32').'</a>'; |
|
| 152 | + echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('new_promotion.png', |
|
| 153 | + get_lang('Add'), '', '32').'</a>'; |
|
| 154 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'session/session_add.php">'.Display::return_icon('new_session.png', |
|
| 155 | + get_lang('AddSession'), '', '32').'</a>'; |
|
| 156 | 156 | echo '</div>'; |
| 157 | 157 | echo Display::grid_html('promotions'); |
| 158 | 158 | } |