Lines Matching refs:this

419 				$atts .= " $k=\"".$this->expandEntities($v).'"';
437 if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){
445 $val = $this->expandEntities($val);
483 $val = $this->expandEntities($val);
493 $this->debug("In serialize_val, used class name $name as element name");
495 …$this->debug("In serialize_val, do not override name $name for element name for class " . get_clas…
498 …$pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->ser…
505 $valueType = $this->isArraySimpleOrStruct($val);
514 $tt = $this->isArraySimpleOrStruct($v);
520 $xml .= $this->serialize_val($v,'item',false,false,false,false,$use);
525 } elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
536 if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){
645 '<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">".
706 if(isset($this->namespaces[$prefix])){
707 return $this->namespaces[$prefix].':'.$name;
757 if (isset($this->namespaces[$prefix])) {
758 return $this->namespaces[$prefix];
773 foreach ($this->namespaces as $p => $n) {
775 $this->usedNamespaces[$p] = $n;
952 $this->faultcode = $faultcode;
953 $this->faultactor = $faultactor;
954 $this->faultstring = $faultstring;
955 $this->faultdetail = $faultdetail;
966 foreach($this->namespaces as $k => $v){
970 '<?xml version="1.0" encoding="'.$this->soap_defencoding.'"?>'.
974 $this->serialize_val($this->faultcode, 'faultcode').
975 $this->serialize_val($this->faultactor, 'faultactor').
976 $this->serialize_val($this->faultstring, 'faultstring').
977 $this->serialize_val($this->faultdetail, 'detail').
1043 $this->debug('xmlschema class instantiated, inside constructor');
1045 $this->schema = $schema;
1046 $this->xml = $xml;
1049 $this->enclosingNamespaces = $namespaces;
1050 $this->namespaces = array_merge($this->namespaces, $namespaces);
1054 $this->debug('initial schema file: '.$schema);
1055 $this->parseFile($schema, 'schema');
1060 $this->debug('initial xml file: '.$xml);
1061 $this->parseFile($xml, 'xml');
1080 $this->setError($msg);
1081 $this->debug($msg);
1084 $this->debug("parsing $xml");
1085 $this->parseString($xmlStr,$type);
1086 $this->debug("done parsing $xml");
1105 $this->parser = xml_parser_create();
1107 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
1110 xml_set_object($this->parser, $this);
1114 xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement');
1115 xml_set_character_data_handler($this->parser,'schemaCharacterData');
1117 xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement');
1118 xml_set_character_data_handler($this->parser,'xmlCharacterData');
1122 if(!xml_parse($this->parser,$xml,true)){
1125 xml_get_current_line_number($this->parser),
1126 xml_error_string(xml_get_error_code($this->parser))
1128 $this->debug($errstr);
1129 $this->debug("XML payload:\n" . $xml);
1130 $this->setError($errstr);
1133 xml_parser_free($this->parser);
1135 $this->debug('no xml passed to parseString()!!');
1136 $this->setError('no xml passed to parseString()!!');
1151 $pos = $this->position++;
1152 $depth = $this->depth++;
1154 $this->depth_array[$depth] = $pos;
1155 $this->message[$pos] = array('cdata' => '');
1157 $this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]];
1159 $this->defaultNamespace[$pos] = false;
1163 if($prefix = $this->getPrefix($name)){
1165 $name = $this->getLocalPart($name);
1179 $this->namespaces[$ns_prefix] = $v;
1181 $this->defaultNamespace[$pos] = $v;
1182 if (! $this->getPrefixFromNamespace($v)) {
1183 $this->namespaces['ns'.(count($this->namespaces)+1)] = $v;
1187 $this->XMLSchemaVersion = $v;
1188 $this->namespaces['xsi'] = $v.'-instance';
1194 $k = strpos($k,':') ? $this->expandQname($k) : $k;
1195 $v = strpos($v,':') ? $this->expandQname($v) : $v;
1209 $this->complexTypes[$this->currentComplexType]['compositor'] = $name;
1216 $this->xdebug("parsing attribute:");
1217 $this->appendDebug($this->varDump($attrs));
1219 $attrs['form'] = $this->schemaInfo['attributeFormDefault'];
1225 if ($this->defaultNamespace[$pos]) {
1232 $this->attributes[$attrs['name']] = $attrs;
1250 $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
1251 $prefix = $this->getPrefix($aname);
1258 $this->complexTypes[$this->currentComplexType]['multidimensional'] = true;
1261 if(!strpos($v,':') && isset($this->typemap[$this->XMLSchemaVersion][$v])){
1262 $v = $this->XMLSchemaVersion.':'.$v;
1264 $this->complexTypes[$this->currentComplexType]['arrayType'] = $v;
1270 array_push($this->complexTypeStack, $this->currentComplexType);
1272 $this->xdebug('processing named complexType '.$attrs['name']);
1274 $this->currentComplexType = $attrs['name'];
1275 $this->complexTypes[$this->currentComplexType] = $attrs;
1276 $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
1285 $this->xdebug('complexType is unusual array');
1286 $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
1288 $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
1291 $this->xdebug('processing unnamed complexType for element '.$this->currentElement);
1292 $this->currentComplexType = $this->currentElement . '_ContainedType';
1294 $this->complexTypes[$this->currentComplexType] = $attrs;
1295 $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
1304 $this->xdebug('complexType is unusual array');
1305 $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
1307 $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
1312 array_push($this->elementStack, $this->currentElement);
1317 $attrs['form'] = $this->schemaInfo['elementFormDefault'];
1320 $this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']);
1321 if (! $this->getPrefix($attrs['type'])) {
1322 if ($this->defaultNamespace[$pos]) {
1323 $attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type'];
1324 $this->xdebug('used default namespace to make type ' . $attrs['type']);
1334 …if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'arr…
1335 $this->xdebug('arrayType for unusual array is ' . $attrs['type']);
1336 $this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type'];
1338 $this->currentElement = $attrs['name'];
1339 $this->elements[ $attrs['name'] ] = $attrs;
1340 $this->elements[ $attrs['name'] ]['typeClass'] = 'element';
1343 $this->xdebug("processing element as ref to ".$attrs['ref']);
1344 $this->currentElement = "ref to ".$attrs['ref'];
1345 $ename = $this->getLocalPart($attrs['ref']);
1347 $this->xdebug("processing untyped element ".$attrs['name']);
1348 $this->currentElement = $attrs['name'];
1349 $this->elements[ $attrs['name'] ] = $attrs;
1350 $this->elements[ $attrs['name'] ]['typeClass'] = 'element';
1351 $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['name'] . '_ContainedType';
1352 $this->elements[ $attrs['name'] ]['type'] = $attrs['type'];
1355 if(isset($ename) && $this->currentComplexType){
1356 $this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs;
1360 $this->xdebug('enumeration ' . $attrs['value']);
1361 if ($this->currentSimpleType) {
1362 $this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value'];
1363 } elseif ($this->currentComplexType) {
1364 $this->complexTypes[$this->currentComplexType]['enumeration'][] = $attrs['value'];
1368 $this->xdebug('extension ' . $attrs['base']);
1369 if ($this->currentComplexType) {
1370 $this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base'];
1376 …$this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => …
1379 … $this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
1380 if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
1381 $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
1388 $this->xdebug('restriction ' . $attrs['base']);
1389 if($this->currentSimpleType){
1390 $this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base'];
1391 } elseif($this->currentComplexType){
1392 $this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base'];
1394 $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
1399 $this->schemaInfo = $attrs;
1400 $this->schemaInfo['schemaVersion'] = $this->getNamespaceFromPrefix($prefix);
1402 $this->schemaTargetNamespace = $attrs['targetNamespace'];
1405 $this->schemaInfo['elementFormDefault'] = 'unqualified';
1408 $this->schemaInfo['attributeFormDefault'] = 'unqualified';
1414 array_push($this->simpleTypeStack, $this->currentSimpleType);
1416 $this->xdebug("processing simpleType for name " . $attrs['name']);
1417 $this->currentSimpleType = $attrs['name'];
1418 $this->simpleTypes[ $attrs['name'] ] = $attrs;
1419 $this->simpleTypes[ $attrs['name'] ]['typeClass'] = 'simpleType';
1420 $this->simpleTypes[ $attrs['name'] ]['phpType'] = 'scalar';
1422 $this->xdebug('processing unnamed simpleType for element '.$this->currentElement);
1423 $this->currentSimpleType = $this->currentElement . '_ContainedType';
1425 $this->simpleTypes[$this->currentSimpleType] = $attrs;
1426 $this->simpleTypes[$this->currentSimpleType]['phpType'] = 'scalar';
1445 $this->depth--;
1447 if(isset($this->depth_array[$this->depth])){
1448 $pos = $this->depth_array[$this->depth];
1451 if ($prefix = $this->getPrefix($name)){
1453 $name = $this->getLocalPart($name);
1459 …$this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexT…
1460 $this->currentComplexType = array_pop($this->complexTypeStack);
1464 …$this->xdebug('done processing element ' . ($this->currentElement ? $this->currentElement : '(unkn…
1465 $this->currentElement = array_pop($this->elementStack);
1468 …$this->xdebug('done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType…
1469 $this->currentSimpleType = array_pop($this->simpleTypeStack);
1481 $pos = $this->depth_array[$this->depth - 1];
1482 $this->message[$pos]['cdata'] .= $data;
1492 $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion);
1495 if (sizeof($this->imports) > 0) {
1496 foreach($this->imports as $ns => $list) {
1507 foreach($this->complexTypes as $typeName => $attrs){
1515 …$contentStr .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($ePart…
1536 $contentStr .= " $a=\"".$this->contractQName($v).'"';
1539 $contentStr .= ' wsdl:arrayType="'.$this->contractQName($v).'"';
1588 $el = "<$schemaPrefix:schema targetNamespace=\"$this->schemaTargetNamespace\"\n";
1589 foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
1603 $this->debug('<' . $this->schemaTargetNamespace . '> '.$string);
1619 if(isset($this->typemap[$ns][$type])){
1621 return $this->typemap[$ns][$type];
1622 } elseif(isset($this->complexTypes[$type])){
1624 return $this->complexTypes[$type]['phpType'];
1653 if(isset($this->complexTypes[$type])){
1654 $this->xdebug("in getTypeDef, found complexType $type");
1655 return $this->complexTypes[$type];
1656 } elseif(isset($this->simpleTypes[$type])){
1657 $this->xdebug("in getTypeDef, found simpleType $type");
1658 if (!isset($this->simpleTypes[$type]['phpType'])) {
1661 …$uqType = substr($this->simpleTypes[$type]['type'], strrpos($this->simpleTypes[$type]['type'], ':'…
1662 …$ns = substr($this->simpleTypes[$type]['type'], 0, strrpos($this->simpleTypes[$type]['type'], ':')…
1663 $etype = $this->getTypeDef($uqType);
1665 $this->xdebug("in getTypeDef, found type for simpleType $type:");
1666 $this->xdebug($this->varDump($etype));
1668 $this->simpleTypes[$type]['phpType'] = $etype['phpType'];
1671 $this->simpleTypes[$type]['elements'] = $etype['elements'];
1675 return $this->simpleTypes[$type];
1676 } elseif(isset($this->elements[$type])){
1677 $this->xdebug("in getTypeDef, found element $type");
1678 if (!isset($this->elements[$type]['phpType'])) {
1680 …$uqType = substr($this->elements[$type]['type'], strrpos($this->elements[$type]['type'], ':') + 1);
1681 $ns = substr($this->elements[$type]['type'], 0, strrpos($this->elements[$type]['type'], ':'));
1682 $etype = $this->getTypeDef($uqType);
1684 $this->xdebug("in getTypeDef, found type for element $type:");
1685 $this->xdebug($this->varDump($etype));
1687 $this->elements[$type]['phpType'] = $etype['phpType'];
1690 $this->elements[$type]['elements'] = $etype['elements'];
1708 $this->xdebug("in getTypeDef, did not find $type");
1722 if($typeDef = $this->getTypeDef($type)){
1729 $str .= " xmlns=\"".$this->schema['targetNamespace']."\"";
1733 $str .= $this->serializeTypeDef($element);
1758 if($typeDef = $this->getTypeDef($type)){
1764 <tr><td align='right'>$childDef[name] (type: ".$this->getLocalPart($childDef['type'])."):</td>
1829 $this->complexTypes[$name] = array(
1840 $this->xdebug("addComplexType $name:");
1841 $this->appendDebug($this->varDump($this->complexTypes[$name]));
1857 $this->simpleTypes[$name] = array(
1865 $this->xdebug("addSimpleType $name:");
1866 $this->appendDebug($this->varDump($this->simpleTypes[$name]));
1877 if (! $this->getPrefix($attrs['type'])) {
1878 $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type'];
1880 $this->elements[ $attrs['name'] ] = $attrs;
1881 $this->elements[ $attrs['name'] ]['typeClass'] = 'element';
1883 $this->xdebug("addElement " . $attrs['name']);
1884 $this->appendDebug($this->varDump($this->elements[ $attrs['name'] ]));
1962 $this->name = $name;
1963 $this->type = $type;
1964 $this->value = $value;
1965 $this->element_ns = $element_ns;
1966 $this->type_ns = $type_ns;
1967 $this->attributes = $attributes;
1978 …return $this->serialize_val($this->value,$this->name,$this->type,$this->element_ns,$this->type_ns,…
1988 return $this->value;
2043 $this->setURL($url);
2044 ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev);
2045 $this->outgoing_headers['User-Agent'] = $this->title.'/'.$this->version.' ('.$rev[1].')';
2046 $this->debug('set User-Agent: ' . $this->outgoing_headers['User-Agent']);
2050 $this->url = $url;
2054 $this->debug("$k = $v");
2055 $this->$k = $v;
2060 $this->path .= '?' . $u['query'];
2066 $this->port = 443;
2068 $this->port = 80;
2072 $this->uri = $this->path;
2073 $this->digest_uri = $this->uri;
2077 $this->outgoing_headers['Host'] = $this->host;
2079 $this->outgoing_headers['Host'] = $this->host.':'.$this->port;
2081 $this->debug('set Host: ' . $this->outgoing_headers['Host']);
2084 $this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : '');
2101 …$this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, …
2102 if ($this->scheme == 'http' || $this->scheme == 'ssl') {
2104 if($this->persistentConnection && isset($this->fp) && is_resource($this->fp)){
2105 if (!feof($this->fp)) {
2106 $this->debug('Re-use persistent connection');
2109 fclose($this->fp);
2110 $this->debug('Closed persistent connection at EOF');
2114 if ($this->scheme == 'ssl') {
2115 $host = 'ssl://' . $this->host;
2117 $host = $this->host;
2119 …$this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout…
2123 $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str, $connection_timeout);
2125 $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str);
2129 if(!$this->fp) {
2130 $msg = 'Couldn\'t open socket connection to server ' . $this->url;
2131 if ($this->errno) {
2132 $msg .= ', Error ('.$this->errno.'): '.$this->error_str;
2136 $this->debug($msg);
2137 $this->setError($msg);
2142 $this->debug('set response timeout to ' . $response_timeout);
2143 socket_set_timeout( $this->fp, $response_timeout);
2145 $this->debug('socket connected');
2147 } else if ($this->scheme == 'https') {
2149 …$this->setError('CURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS'…
2152 $this->debug('connect using https');
2154 $this->ch = curl_init();
2156 $hostURL = ($this->port != '') ? "https://$this->host:$this->port" : "https://$this->host";
2158 $hostURL .= $this->path;
2159 curl_setopt($this->ch, CURLOPT_URL, $hostURL);
2161 curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1);
2163 curl_setopt($this->ch, CURLOPT_HEADER, 1);
2165 curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1);
2172 if ($this->persistentConnection) {
2176 $this->persistentConnection = false;
2177 $this->outgoing_headers['Connection'] = 'close';
2178 $this->debug('set Connection: ' . $this->outgoing_headers['Connection']);
2182 curl_setopt($this->ch, CURLOPT_TIMEOUT, $connection_timeout);
2196 curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, 0);
2197 curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 0);
2200 if ($this->authtype == 'certificate') {
2201 if (isset($this->certRequest['cainfofile'])) {
2202 curl_setopt($this->ch, CURLOPT_CAINFO, $this->certRequest['cainfofile']);
2204 if (isset($this->certRequest['verifypeer'])) {
2205 curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, $this->certRequest['verifypeer']);
2207 curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, 1);
2209 if (isset($this->certRequest['verifyhost'])) {
2210 curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, $this->certRequest['verifyhost']);
2212 curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 1);
2214 if (isset($this->certRequest['sslcertfile'])) {
2215 curl_setopt($this->ch, CURLOPT_SSLCERT, $this->certRequest['sslcertfile']);
2217 if (isset($this->certRequest['sslkeyfile'])) {
2218 curl_setopt($this->ch, CURLOPT_SSLKEY, $this->certRequest['sslkeyfile']);
2220 if (isset($this->certRequest['passphrase'])) {
2221 curl_setopt($this->ch, CURLOPT_SSLKEYPASSWD , $this->certRequest['passphrase']);
2224 $this->debug('cURL connection set up');
2227 $this->setError('Unknown scheme ' . $this->scheme);
2228 $this->debug('Unknown scheme ' . $this->scheme);
2245 $this->debug('entered send() with data of length: '.strlen($data));
2247 $this->tryagain = true;
2249 while ($this->tryagain) {
2250 $this->tryagain = false;
2253 if (!$this->connect($timeout, $response_timeout)){
2258 if (!$this->sendRequest($data, $cookies)){
2263 $respdata = $this->getResponse();
2265 $this->setError('Too many tries to get an OK response');
2268 $this->debug('end of send()');
2284 return $this->send($data, $timeout, $response_timeout, $cookies);
2298 $this->debug("Set credentials for authtype $authtype");
2301 …$this->outgoing_headers['Authorization'] = 'Basic '.base64_encode(str_replace(':','',$username).':…
2315 $A2 = 'POST:' . $this->digest_uri;
2342this->outgoing_headers['Authorization'] = 'Digest username="' . $username . '", realm="' . $digest…
2345 $this->certRequest = $certRequest;
2347 $this->username = $username;
2348 $this->password = $password;
2349 $this->authtype = $authtype;
2350 $this->digestRequest = $digestRequest;
2352 if (isset($this->outgoing_headers['Authorization'])) {
2353 …$this->debug('set Authorization: ' . substr($this->outgoing_headers['Authorization'], 0, 12) . '..…
2355 $this->debug('Authorization header not set');
2366 $this->outgoing_headers['SOAPAction'] = '"' . $soapaction . '"';
2367 $this->debug('set SOAPAction: ' . $this->outgoing_headers['SOAPAction']);
2378 $this->protocol_version = '1.1';
2379 $this->outgoing_headers['Accept-Encoding'] = $enc;
2380 $this->debug('set Accept-Encoding: ' . $this->outgoing_headers['Accept-Encoding']);
2381 if (!isset($this->outgoing_headers['Connection'])) {
2382 $this->outgoing_headers['Connection'] = 'close';
2383 $this->persistentConnection = false;
2384 $this->debug('set Connection: ' . $this->outgoing_headers['Connection']);
2388 $this->encoding = $enc;
2402 $this->uri = $this->url;
2403 $this->host = $proxyhost;
2404 $this->port = $proxyport;
2406 …$this->outgoing_headers['Proxy-Authorization'] = ' Basic '.base64_encode($proxyusername.':'.$proxy…
2407 $this->debug('set Proxy-Authorization: ' . $this->outgoing_headers['Proxy-Authorization']);
2430 $this->debug('no linebreak found in decodeChunked');
2438 $this->debug("chunkstart: $chunkstart chunk_size: $chunk_size");
2475 $this->outgoing_headers['Content-Length'] = strlen($data);
2476 $this->debug('set Content-Length: ' . $this->outgoing_headers['Content-Length']);
2479 $req = "$this->request_method $this->uri HTTP/$this->protocol_version";
2480 $this->debug("HTTP request: $req");
2481 $this->outgoing_payload = "$req\r\n";
2484 foreach($this->outgoing_headers as $k => $v){
2486 $this->debug("HTTP header: $hdr");
2487 $this->outgoing_payload .= "$hdr\r\n";
2493 $this->debug("HTTP header: $hdr");
2494 $this->outgoing_payload .= "$hdr\r\n";
2498 $this->outgoing_payload .= "\r\n";
2501 $this->outgoing_payload .= $data;
2506 …$cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme ==…
2509 $this->buildPayload($data, $cookie_str);
2511 if ($this->scheme == 'http' || $this->scheme == 'ssl') {
2513 if(!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
2514 $this->setError('couldn\'t write message data to socket');
2515 $this->debug('couldn\'t write message data to socket');
2518 $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
2520 } else if ($this->scheme == 'https') {
2526 foreach($this->outgoing_headers as $k => $v){
2532 curl_setopt($this->ch, CURLOPT_HTTPHEADER, $curl_headers);
2533 if ($this->request_method == "POST") {
2534 curl_setopt($this->ch, CURLOPT_POST, 1);
2535 curl_setopt($this->ch, CURLOPT_POSTFIELDS, $data);
2538 $this->debug('set cURL payload');
2544 $this->incoming_payload = '';
2546 if ($this->scheme == 'http' || $this->scheme == 'ssl') {
2552 if(feof($this->fp)) {
2553 $this->incoming_payload = $data;
2554 $this->debug('found no headers before EOF after length ' . strlen($data));
2555 $this->debug("received before EOF:\n" . $data);
2556 $this->setError('server failed to send headers');
2560 $tmp = fgets($this->fp, 256);
2562 $this->debug("read line of $tmplen bytes: " . trim($tmp));
2565 $this->incoming_payload = $data;
2566 $this->debug('socket read of headers timed out after length ' . strlen($data));
2567 $this->debug("read before timeout: " . $data);
2568 $this->setError('socket read of headers timed out');
2589 $this->incoming_payload .= $data;
2590 $this->debug('found end of headers after length ' . strlen($data));
2594 $this->incoming_headers = array();
2595 $this->incoming_cookies = array();
2600 $this->incoming_headers[$header_name] = trim($arr[1]);
2603 $cookie = $this->parseCookie(trim($arr[1]));
2605 $this->incoming_cookies[] = $cookie;
2606 $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
2608 $this->debug('did not find cookie in ' . trim($arr[1]));
2613 $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
2618 …if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['tra…
2621 $this->debug("want to read chunked content");
2622 } elseif (isset($this->incoming_headers['content-length'])) {
2623 $content_length = $this->incoming_headers['content-length'];
2625 $this->debug("want to read content of length $content_length");
2629 $this->debug("want to read content to EOF");
2634 $tmp = fgets($this->fp, 256);
2636 $this->debug("read chunk line of $tmplen bytes");
2638 $this->incoming_payload = $data;
2639 $this->debug('socket read of chunk length timed out after length ' . strlen($data));
2640 $this->debug("read before timeout:\n" . $data);
2641 $this->setError('socket read of chunk length timed out');
2645 $this->debug("chunk length $content_length");
2648 while (($strlen < $content_length) && (!feof($this->fp))) {
2650 $tmp = fread($this->fp, $readlen);
2652 $this->debug("read buffer of $tmplen bytes");
2653 if (($tmplen == 0) && (!feof($this->fp))) {
2654 $this->incoming_payload = $data;
2655 $this->debug('socket read of body timed out after length ' . strlen($data));
2656 $this->debug("read before timeout:\n" . $data);
2657 $this->setError('socket read of body timed out');
2664 $tmp = fgets($this->fp, 256);
2666 $this->debug("read chunk terminator of $tmplen bytes");
2668 $this->incoming_payload = $data;
2669 $this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
2670 $this->debug("read before timeout:\n" . $data);
2671 $this->setError('socket read of chunk terminator timed out');
2675 } while ($chunked && ($content_length > 0) && (!feof($this->fp)));
2676 if (feof($this->fp)) {
2677 $this->debug('read to EOF');
2679 $this->debug('read body of length ' . strlen($data));
2680 $this->incoming_payload .= $data;
2681 $this->debug('received a total of '.strlen($this->incoming_payload).' bytes of data from server');
2685 …(isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection'])…
2686 (! $this->persistentConnection) || feof($this->fp)){
2687 fclose($this->fp);
2688 $this->fp = false;
2689 $this->debug('closed socket');
2693 if($this->incoming_payload == ''){
2694 $this->setError('no response from server');
2709 } else if ($this->scheme == 'https') {
2711 $this->debug('send and receive with cURL');
2712 $this->incoming_payload = curl_exec($this->ch);
2713 $data = $this->incoming_payload;
2715 $cErr = curl_error($this->ch);
2717 $err = 'cURL ERROR: '.curl_errno($this->ch).': '.$cErr.'<br>';
2719 foreach(curl_getinfo($this->ch) as $k => $v){
2722 $this->debug($err);
2723 $this->setError($err);
2724 curl_close($this->ch);
2732 $this->debug('No cURL error, closing cURL');
2733 curl_close($this->ch);
2750 $this->debug('no proper separation of headers and document');
2751 $this->setError('no proper separation of headers and document');
2757 $this->debug('found proper separation of headers and document');
2758 $this->debug('cleaned data, stringlen: '.strlen($data));
2764 $this->incoming_headers[$header_name] = trim($arr[1]);
2767 $cookie = $this->parseCookie(trim($arr[1]));
2769 $this->incoming_cookies[] = $cookie;
2770 $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
2772 $this->debug('did not find cookie in ' . trim($arr[1]));
2777 $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
2788 if (isset($this->incoming_headers['location']) && $http_status == 301) {
2789 $this->debug("Got 301 $http_reason with Location: " . $this->incoming_headers['location']);
2790 $this->setURL($this->incoming_headers['location']);
2791 $this->tryagain = true;
2796 if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
2797 …$this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authent…
2798 if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
2799 $this->debug('Server wants digest authentication');
2801 $digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']);
2812 $this->setCredentials($this->username, $this->password, 'digest', $digestRequest);
2813 $this->tryagain = true;
2817 $this->debug('HTTP authentication failed');
2818 $this->setError('HTTP authentication failed');
2827 …$this->setError("Unsupported HTTP response status $http_status $http_reason (soapclient->response …
2832 …if(isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding…
2833 …if(strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incom…
2839 $this->debug('The gzinflate function exists');
2841 if ($this->incoming_headers['content-encoding'] == 'deflate') {
2844 $this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
2847 $this->debug('The inflated payload is smaller than the gzipped one; try again');
2850 $this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
2854 $this->debug('Error using gzinflate to inflate the payload');
2855 $this->setError('Error using gzinflate to inflate the payload');
2857 } elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
2860 $this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
2863 $this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
2866 $this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
2870 $this->debug('Error using gzinflate to un-gzip the payload');
2871 $this->setError('Error using gzinflate to un-gzip the payload');
2877 $this->incoming_payload = $header_data.$lb.$lb.$data;
2879 …$this->debug('The server sent compressed data. Your php install must have the Zlib extension compi…
2880 …$this->setError('The server sent compressed data. Your php install must have the Zlib extension co…
2883 $this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
2884 $this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
2887 $this->debug('No Content-Encoding header');
2891 $this->debug('no data after headers!');
2892 $this->setError('no data present after HTTP headers');
2900 $this->outgoing_headers['Content-Type'] = $type . ($charset ? '; charset=' . $charset : '');
2901 $this->debug('set Content-Type: ' . $this->outgoing_headers['Content-Type']);
2905 if (isset($this->outgoing_headers['Accept-Encoding'])) {
2908 $this->protocol_version = '1.1';
2909 $this->persistentConnection = true;
2910 $this->outgoing_headers['Connection'] = 'Keep-Alive';
2911 $this->debug('set Connection: ' . $this->outgoing_headers['Connection']);
2996 $this->debug("check cookie for validity: ".$cookie['name'].'='.$cookie['value']);
2999 $this->debug('cookie has expired');
3005 if (! preg_match("'.*$domain$'i", $this->host)) {
3006 $this->debug('cookie has different domain');
3012 if (! preg_match("'^$path.*'i", $this->path)) {
3013 $this->debug('cookie is for a different path');
3018 $this->debug('cookie is secure, transport is not');
3022 $this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
3202 $this->debug("_SERVER is defined:");
3203 $this->appendDebug($this->varDump($_SERVER));
3205 $this->debug("HTTP_SERVER_VARS is defined:");
3206 $this->appendDebug($this->varDump($HTTP_SERVER_VARS));
3208 $this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined.");
3212 $this->debug("In soap_server, set debug_flag=$debug based on global flag");
3213 $this->debug_flag = $debug;
3218 $this->debug("In soap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
3219 $this->debug_flag = substr($v, 6);
3226 $this->debug("In soap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
3227 $this->debug_flag = substr($v, 6);
3234 $this->debug("In soap_server, WSDL is specified");
3236 $this->wsdl = $wsdl;
3237 $this->externalWSDLURL = $this->wsdl->wsdl;
3238 $this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
3240 $this->debug('Create wsdl from ' . $wsdl);
3241 $this->wsdl = new wsdl($wsdl);
3242 $this->externalWSDLURL = $wsdl;
3244 $this->appendDebug($this->wsdl->getDebug());
3245 $this->wsdl->clearDebug();
3246 if($err = $this->wsdl->getError()){
3268 $this->debug("In service, query string=$qs");
3271 $this->debug("In service, this is a request for WSDL");
3272 if($this->externalWSDLURL){
3273 if (strpos($this->externalWSDLURL,"://")!==false) { // assume URL
3274 header('Location: '.$this->externalWSDLURL);
3277 $fp = fopen($this->externalWSDLURL, 'r');
3280 } elseif ($this->wsdl) {
3282 print $this->wsdl->serialize($this->debug_flag);
3283 if ($this->debug_flag) {
3284 $this->debug('wsdl:');
3285 $this->appendDebug($this->varDump($this->wsdl));
3286 print $this->getDebugAsXMLComment();
3292 } elseif ($data == '' && $this->wsdl) {
3293 $this->debug("In service, there is no data, so return Web description");
3294 print $this->wsdl->webDescription();
3296 $this->debug("In service, invoke the request");
3297 $this->parse_request($data);
3298 if (! $this->fault) {
3299 $this->invoke_method();
3301 if (! $this->fault) {
3302 $this->serialize_return();
3304 $this->send_response();
3323 $this->request = '';
3324 $this->SOAPAction = '';
3326 $this->debug("In parse_http_headers, use getallheaders");
3330 $this->headers[$k] = $v;
3331 $this->request .= "$k: $v\r\n";
3332 $this->debug("$k: $v");
3335 if(isset($this->headers['soapaction'])){
3336 $this->SOAPAction = str_replace('"','',$this->headers['soapaction']);
3339 if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
3340 $enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
3342 $this->xml_encoding = strtoupper($enc);
3344 $this->xml_encoding = 'US-ASCII';
3348 $this->xml_encoding = 'ISO-8859-1';
3351 $this->debug("In parse_http_headers, use _SERVER");
3363 $this->SOAPAction = $v;
3371 $this->xml_encoding = strtoupper($enc);
3373 $this->xml_encoding = 'US-ASCII';
3377 $this->xml_encoding = 'ISO-8859-1';
3380 $this->headers[$k] = $v;
3381 $this->request .= "$k: $v\r\n";
3382 $this->debug("$k: $v");
3385 $this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
3397 $this->SOAPAction = $v;
3405 $this->xml_encoding = strtoupper($enc);
3407 $this->xml_encoding = 'US-ASCII';
3411 $this->xml_encoding = 'ISO-8859-1';
3414 $this->headers[$k] = $v;
3415 $this->request .= "$k: $v\r\n";
3416 $this->debug("$k: $v");
3419 $this->debug("In parse_http_headers, HTTP headers not accessible");
3420 $this->setError("HTTP headers not accessible");
3447 $this->debug('entering parse_request()');
3448 $this->parse_http_headers();
3449 $this->debug('got character encoding: '.$this->xml_encoding);
3451 if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
3452 $this->debug('got content encoding: ' . $this->headers['content-encoding']);
3453 …if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip…
3456 if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
3458 …} elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))…
3461 $this->fault('Client', 'Errors occurred when trying to decode the data');
3465 $this->fault('Client', 'This Server does not support compressed data');
3470 $this->request .= "\r\n".$data;
3471 $data = $this->parseRequest($this->headers, $data);
3472 $this->requestSOAP = $data;
3473 $this->debug('leaving parse_request');
3494 …$this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodUR…
3496 if ($this->wsdl) {
3497 if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
3498 $this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
3499 $this->appendDebug('opData=' . $this->varDump($this->opData));
3500 } elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
3502 …$this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . …
3503 $this->appendDebug('opData=' . $this->varDump($this->opData));
3504 $this->methodname = $this->opData['name'];
3506 $this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
3507 …$this->fault('Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this …
3511 $this->debug('in invoke_method, no WSDL to validate method');
3519 if (strpos($this->methodname, '..') > 0) {
3521 } else if (strpos($this->methodname, '.') > 0) {
3527 if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1 &&
3528 class_exists(substr($this->methodname, 0, strpos($this->methodname, $delim)))) {
3530 $class = substr($this->methodname, 0, strpos($this->methodname, $delim));
3531 $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
3532 $this->debug("in invoke_method, class=$class method=$method delim=$delim");
3537 if (!function_exists($this->methodname)) {
3538 $this->debug("in invoke_method, function '$this->methodname' not found!");
3539 $this->result = 'fault: method not found';
3540 $this->fault('Client',"method '$this->methodname' not defined in service");
3546 $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
3547 $this->result = 'fault: method not found';
3548 $this->fault('Client',"method '$this->methodname' not defined in service");
3555 if(! $this->verify_method($this->methodname,$this->methodparams)){
3557 $this->debug('ERROR: request not verified against method signature');
3558 $this->result = 'fault: request failed validation against method signature';
3560 $this->fault('Client',"Operation '$this->methodname' not defined in service.");
3565 $this->debug('in invoke_method, params:');
3566 $this->appendDebug($this->varDump($this->methodparams));
3567 $this->debug("in invoke_method, calling '$this->methodname'");
3570 $this->debug('in invoke_method, calling function using eval()');
3571 $funcCall = "\$this->methodreturn = $this->methodname(";
3574 $this->debug('in invoke_method, calling class method using eval()');
3577 $this->debug('in invoke_method, calling instance method using eval()');
3584 if ($this->methodparams) {
3585 foreach ($this->methodparams as $param) {
3587 …$this->fault('Client', 'NuSOAP does not handle complexType parameters correctly when using eval; c…
3595 $this->debug('in invoke_method, function call: '.$funcCall);
3599 $this->debug('in invoke_method, calling function using call_user_func_array()');
3600 …$call_arg = "$this->methodname"; // straight assignment changes $this->methodname to lower case af…
3602 $this->debug('in invoke_method, calling class method using call_user_func_array()');
3605 $this->debug('in invoke_method, calling instance method using call_user_func_array()');
3609 $this->methodreturn = call_user_func_array($call_arg, $this->methodparams);
3611 $this->debug('in invoke_method, methodreturn:');
3612 $this->appendDebug($this->varDump($this->methodreturn));
3613 …$this->debug("in invoke_method, called method $this->methodname, received $this->methodreturn of t…
3628 …$this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this
3630 if (isset($this->methodreturn) && (get_class($this->methodreturn) == 'soap_fault')) {
3631 $this->debug('got a fault object from method');
3632 $this->fault = $this->methodreturn;
3634 } elseif ($this->methodreturnisliteralxml) {
3635 $return_val = $this->methodreturn;
3638 $this->debug('got a(n) '.gettype($this->methodreturn).' from method');
3639 $this->debug('serializing return value');
3640 if($this->wsdl){
3642 if(sizeof($this->opData['output']['parts']) > 1){
3643 $opParams = $this->methodreturn;
3646 $opParams = array($this->methodreturn);
3648 $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams);
3649 $this->appendDebug($this->wsdl->getDebug());
3650 $this->wsdl->clearDebug();
3651 if($errstr = $this->wsdl->getError()){
3652 $this->debug('got wsdl error: '.$errstr);
3653 $this->fault('Server', 'unable to serialize result');
3657 if (isset($this->methodreturn)) {
3658 $return_val = $this->serialize_val($this->methodreturn, 'return');
3661 $this->debug('in absence of WSDL, assume void return for backward compatibility');
3665 $this->debug('return value:');
3666 $this->appendDebug($this->varDump($return_val));
3668 $this->debug('serializing response');
3669 if ($this->wsdl) {
3670 $this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
3671 if ($this->opData['style'] == 'rpc') {
3672 $this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
3673 if ($this->opData['output']['use'] == 'literal') {
3674 …$payload = '<'.$this->methodname.'Response xmlns="'.$this->methodURI.'">'.$return_val.'</'.$this->…
3676 …$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</n…
3679 $this->debug('style is not rpc for serialization: assume document');
3683 $this->debug('do not have WSDL for serialization: assume rpc/encoded');
3684 …$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</n…
3686 $this->result = 'successful';
3687 if($this->wsdl){
3689 $this->appendDebug($this->wsdl->getDebug());
3697 …$this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNa…
3699 $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders);
3701 $this->debug("Leaving serialize_return");
3715 $this->debug('Enter send_response');
3716 if ($this->fault) {
3717 $payload = $this->fault->serialize();
3718 $this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error";
3719 $this->outgoing_headers[] = "Status: 500 Internal Server Error";
3721 $payload = $this->responseSOAP;
3729 if(isset($this->debug_flag) && $this->debug_flag){
3730 $payload .= $this->getDebugAsXMLComment();
3732 $this->outgoing_headers[] = "Server: $this->title Server v$this->version";
3733 ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev);
3734 $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
3737 $payload = $this->getHTTPBody($payload);
3738 $type = $this->getHTTPContentType();
3739 $charset = $this->getHTTPContentTypeCharset();
3740 $this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
3744 …if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) …
3745 if (strstr($this->headers['accept-encoding'], 'gzip')) {
3747 if (isset($this->debug_flag) && $this->debug_flag) {
3750 $this->outgoing_headers[] = "Content-Encoding: gzip";
3753 if (isset($this->debug_flag) && $this->debug_flag) {
3757 } elseif (strstr($this->headers['accept-encoding'], 'deflate')) {
3762 if (isset($this->debug_flag) && $this->debug_flag) {
3765 $this->outgoing_headers[] = "Content-Encoding: deflate";
3768 if (isset($this->debug_flag) && $this->debug_flag) {
3775 $this->outgoing_headers[] = "Content-Length: ".strlen($payload);
3776 reset($this->outgoing_headers);
3777 foreach($this->outgoing_headers as $hdr){
3781 $this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
3794 if(isset($this->wsdl) && is_object($this->wsdl)){
3795 if($this->wsdl->getOperationData($operation)){
3798 } elseif(isset($this->operations[$operation])){
3813 …$this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' and type ' . $heade…
3815 $this->setError('Request not of type text/xml');
3820 $this->debug('Got response encoding: ' . $enc);
3822 $this->xml_encoding = strtoupper($enc);
3824 $this->xml_encoding = 'US-ASCII';
3828 $this->xml_encoding = 'ISO-8859-1';
3830 $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating soap_parser');
3832 $parser = new soap_parser($data,$this->xml_encoding,'',$this->decode_utf8);
3834 $this->debug("parser debug: \n".$parser->getDebug());
3837 $this->result = 'fault: error in msg parsing: '.$err;
3838 $this->fault('Client',"error in msg parsing:\n".$err);
3842 $this->methodURI = $parser->root_struct_namespace;
3843 $this->methodname = $parser->root_struct_name;
3844 $this->debug('methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
3845 $this->debug('calling parser->get_response()');
3846 $this->methodparams = $parser->get_response();
3848 $this->requestHeaders = $parser->getHeaders();
3850 $this->document = $parser->document;
3887 return $this->soap_defencoding;
3900 $this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
3920 if($this->externalWSDLURL){
3942 $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
4013 $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
4037 $this->wsdl = new wsdl;
4038 $this->wsdl->serviceName = $serviceName;
4039 $this->wsdl->endpoint = $endpoint;
4040 $this->wsdl->namespaces['tns'] = $namespace;
4041 $this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/';
4044 $this->wsdl->namespaces['types'] = $schemaTargetNamespace;
4046 … $this->wsdl->schemas[$schemaTargetNamespace][0] = new xmlschema('', '', $this->wsdl->namespaces);
4047 … $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace;
4048 …$this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/soap/encoding…
4050 $this->wsdl->bindings[$serviceName.'Binding'] = array(
4055 $this->wsdl->ports[$serviceName.'Port'] = array(
4125 $this->wsdl = $wsdl;
4126 $this->proxyhost = $proxyhost;
4127 $this->proxyport = $proxyport;
4128 $this->proxyusername = $proxyusername;
4129 $this->proxypassword = $proxypassword;
4130 $this->timeout = $timeout;
4131 $this->response_timeout = $response_timeout;
4135 $this->debug('initial wsdl URL: ' . $wsdl);
4136 $this->parseWSDL($wsdl);
4145 foreach ($this->schemas as $ns => $list) {
4147 $wsdlparts = parse_url($this->wsdl); // this is bogusly simple!
4151 $this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true;
4160 $this->parseWSDL($url);
4165 $this->debug("Unexpected scenario: empty URL for unloaded import");
4173 $wsdlparts = parse_url($this->wsdl); // this is bogusly simple!
4174 foreach ($this->import as $ns => $list) {
4177 $this->import[$ns][$ii]['loaded'] = true;
4186 $this->parseWSDL($url);
4191 $this->debug("Unexpected scenario: empty URL for unloaded import");
4198 foreach($this->bindings as $binding => $bindingData) {
4201 $this->debug('post-parse data gathering for ' . $operation);
4202 $this->bindings[$binding]['operations'][$operation]['input'] =
4203 isset($this->bindings[$binding]['operations'][$operation]['input']) ?
4204 …array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindi…
4205 $this->portTypes[ $bindingData['portType'] ][$operation]['input'];
4206 $this->bindings[$binding]['operations'][$operation]['output'] =
4207 isset($this->bindings[$binding]['operations'][$operation]['output']) ?
4208 …array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bind…
4209 $this->portTypes[ $bindingData['portType'] ][$operation]['output'];
4210 …if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] …
4211 …$this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bi…
4213 …if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message']…
4214 …$this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->b…
4217 … $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style'];
4219 …$this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']…
4220this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[ $bin…
4221 …$this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) …
4236 $this->debug('no wsdl passed to parseWSDL()!!');
4237 $this->setError('no wsdl passed to parseWSDL()!!');
4245 $this->debug('getting WSDL http(s) URL ' . $wsdl);
4250 if($this->proxyhost && $this->proxyport){
4251 $tr->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
4254 $wsdl_string = $tr->send('', $this->timeout, $this->response_timeout);
4257 $this->appendDebug($tr->getDebug());
4261 $this->debug($errstr);
4262 $this->setError($errstr);
4267 $this->debug("got WSDL URL");
4275 $this->debug('getting WSDL file ' . $path);
4284 $this->debug($errstr);
4285 $this->setError($errstr);
4289 $this->debug('Parse WSDL');
4292 $this->parser = xml_parser_create();
4295 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
4297 xml_set_object($this->parser, $this);
4299 xml_set_element_handler($this->parser, 'start_element', 'end_element');
4300 xml_set_character_data_handler($this->parser, 'character_data');
4302 if (!xml_parse($this->parser, $wsdl_string, true)) {
4307 xml_get_current_line_number($this->parser),
4308 xml_error_string(xml_get_error_code($this->parser))
4310 $this->debug($errstr);
4311 $this->debug("XML payload:\n" . $wsdl_string);
4312 $this->setError($errstr);
4316 xml_parser_free($this->parser);
4317 $this->debug('Parsing WSDL done');
4319 if($this->getError()){
4335 if ($this->status == 'schema') {
4336 $this->currentSchema->schemaStartElement($parser, $name, $attrs);
4337 $this->appendDebug($this->currentSchema->getDebug());
4338 $this->currentSchema->clearDebug();
4340 $this->debug('Parsing WSDL schema');
4342 $this->status = 'schema';
4343 $this->currentSchema = new xmlschema('', '', $this->namespaces);
4344 $this->currentSchema->schemaStartElement($parser, $name, $attrs);
4345 $this->appendDebug($this->currentSchema->getDebug());
4346 $this->currentSchema->clearDebug();
4349 $pos = $this->position++;
4350 $depth = $this->depth++;
4352 $this->depth_array[$depth] = $pos;
4353 $this->message[$pos] = array('cdata' => '');
4360 $this->namespaces[$ns_prefix] = $v;
4362 $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v;
4365 $this->XMLSchemaVersion = $v;
4366 $this->namespaces['xsi'] = $v . '-instance';
4372 $k = strpos($k, ':') ? $this->expandQname($k) : $k;
4374 $v = strpos($v, ':') ? $this->expandQname($v) : $v;
4387 $namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] : '';
4393 switch ($this->status) {
4397 …$this->debug("msg " . $this->currentMessage . ": found part $attrs[name]: " . implode(',', $attrs)…
4398 $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
4401 …$this->debug("msg " . $this->currentMessage . ": found part $attrs[name]: " . implode(',', $attrs)…
4402 $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'];
4409 $this->currentPortOperation = $attrs['name'];
4410 … $this->debug("portType $this->currentPortType operation: $this->currentPortOperation");
4412 …$this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrde…
4416 $this->documentation = true;
4420 $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : '';
4421 … $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m;
4430 $this->bindings[$this->currentBinding]['prefix'] = $prefix;
4432 …$this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attr…
4435 …$this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['he…
4439 …$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $att…
4442 …$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['s…
4445 $this->currentOperation = $attrs['name'];
4446 $this->debug("current binding operation: $this->currentOperation");
4447 …$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['na…
4448 …$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->…
4449this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($
4453 $this->opStatus = 'input';
4456 $this->opStatus = 'output';
4459 …if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opS…
4460this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = ar…
4462 …$this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $…
4470 $this->currentPort = $attrs['name'];
4471 $this->debug('current port: ' . $this->currentPort);
4472 $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']);
4476 $this->ports[$this->currentPort]['location'] = $attrs['location'];
4477 $this->ports[$this->currentPort]['bindingType'] = $namespace;
4478 … $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace;
4479 … $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location'];
4488 … $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false);
4489 …$this->debug('parsing import ' . $attrs['namespace']. ' - ' . $attrs['location'] . ' (' . count($t…
4491 … $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
4492 if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
4493 $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
4495 …$this->debug('parsing import ' . $attrs['namespace']. ' - [no location] (' . count($this->import[$…
4503 $this->status = 'message';
4504 $this->messages[$attrs['name']] = array();
4505 $this->currentMessage = $attrs['name'];
4508 $this->status = 'portType';
4509 $this->portTypes[$attrs['name']] = array();
4510 $this->currentPortType = $attrs['name'];
4516 $this->currentBinding = $this->getLocalPart($attrs['name']);
4518 $this->currentBinding = $attrs['name'];
4520 $this->status = 'binding';
4521 $this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']);
4522 $this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
4526 $this->serviceName = $attrs['name'];
4527 $this->status = 'service';
4528 $this->debug('current service: ' . $this->serviceName);
4532 $this->wsdl_info[$name] = $value;
4549 $this->status = "";
4550 $this->appendDebug($this->currentSchema->getDebug());
4551 $this->currentSchema->clearDebug();
4552 $this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema;
4553 $this->debug('Parsing WSDL schema done');
4555 if ($this->status == 'schema') {
4556 $this->currentSchema->schemaEndElement($parser, $name);
4559 $this->depth--;
4562 if ($this->documentation) {
4565 $this->documentation = false;
4578 $pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0;
4579 if (isset($this->message[$pos]['cdata'])) {
4580 $this->message[$pos]['cdata'] .= $data;
4582 if ($this->documentation) {
4583 $this->documentation .= $data;
4589 if (is_array($this->bindings[$binding])) {
4590 return $this->bindings[$binding];
4637 foreach($this->ports as $port => $portData) {
4642 foreach(array_keys($this->bindings[ $portData['binding'] ]['operations']) as $bOperation) {
4645 $opData = $this->bindings[ $portData['binding'] ]['operations'][$operation];
4786 this.ver=navigator.appVersion
4787 this.agent=navigator.userAgent
4788 this.dom=document.getElementById?1:0
4789 this.opera5=this.agent.indexOf("Opera 5")>-1
4790 this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
4791 this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
4792 this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
4793 this.ie=this.ie4||this.ie5||this.ie6
4794 this.mac=this.agent.indexOf("Mac")>-1
4795 this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
4796 this.ns4=(document.layers && !this.dom)?1:0;
4797 this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
4798 return this
4803this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?document.layers[obj…
4804 if(!this.evnt) return false
4805 this.css=bw.dom||bw.ie4?this.evnt.style:bw.ns4?this.evnt:0;
4806 this.wref=bw.dom||bw.ie4?this.evnt:bw.ns4?this.css.document:0;
4807 this.writeIt=b_writeIt;
4808 return this
4813 if (bw.ns4){this.wref.write(text);this.wref.close()}
4814 else this.wref.innerHTML = text
4881 foreach($this->namespaces as $k => $v) {
4885 if (isset($this->namespaces['wsdl'])) {
4886 $xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\"";
4888 if (isset($this->namespaces['tns'])) {
4889 $xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\"";
4893 if (sizeof($this->import) > 0) {
4894 foreach($this->import as $ns => $list) {
4905 if (count($this->schemas)>=1) {
4907 foreach ($this->schemas as $ns => $list) {
4915 if (count($this->messages) >= 1) {
4916 foreach($this->messages as $msgName => $msgParts) {
4922 $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType));
4923 } elseif (isset($this->typemap[$this->namespaces['xsd']][$partType])) {
4927 foreach($this->typemap as $ns => $types) {
4929 $typePrefix = $this->getPrefixFromNamespace($ns);
4936 $ns = $this->getNamespaceFromPrefix($typePrefix);
4937 $typeDef = $this->getTypeDef($this->getLocalPart($partType), $ns);
4943 …$xml .= '<part name="' . $partName . '" ' . $elementortype . '="' . $typePrefix . ':' . $this->get…
4950 if (count($this->bindings) >= 1) {
4953 foreach($this->bindings as $bindingName => $attrs) {
4991 $xml .= "\n<service name=\"" . $this->serviceName . '">';
4992 if (count($this->ports) >= 1) {
4993 foreach($this->ports as $pName => $attrs) {
5018 …$this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVers…
5019 $this->appendDebug('parameters=' . $this->varDump($parameters));
5022 $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
5023 $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
5026 if (!$opData = $this->getOperationData($operation)) {
5027 $this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
5028 $this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
5031 $this->debug('opData:');
5032 $this->appendDebug($this->varDump($opData));
5097 …$this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion…
5098 $this->appendDebug('parameters=' . $this->varDump($parameters));
5101 $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
5102 $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
5105 if (!$opData = $this->getOperationData($operation)) {
5106 $this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
5107 $this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
5110 $this->debug('opData:');
5111 $this->appendDebug($this->varDump($opData));
5223 $this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
5235 …$xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$u…
5237 $this->debug("in serializeType: returning: $xml");
5248 $value = $this->expandEntities($value);
5256 if (!$this->getTypeDef($uqType, $ns)) {
5259 …$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$…
5264 …$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingS…
5266 $this->debug("in serializeType: returning: $xml");
5269 $this->debug('custom type extends XML Schema or SOAP Encoding namespace (yuck)');
5275 $this->debug('in serializeType: Add namespace for Apache SOAP type');
5277 $this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap';
5283 $this->debug("serializing map element: key $k, value $v");
5285 $contents .= $this->serialize_val($k,'key',false,false,false,false,$use);
5286 $contents .= $this->serialize_val($v,'value',false,false,false,false,$use);
5298 $this->debug("in serializeType: returning: $xml");
5301 $this->debug('in serializeType: Apache SOAP type, but only support Map');
5306 $this->debug("in serializeType: No namespace for type $type");
5310 if(!$typeDef = $this->getTypeDef($uqType, $ns)){
5311 $this->setError("$type ($uqType) is not a supported type.");
5312 $this->debug("in serializeType: $type ($uqType) is not a supported type.");
5315 $this->debug("in serializeType: found typeDef");
5316 $this->appendDebug('typeDef=' . $this->varDump($typeDef));
5319 …$this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset…
5342 …$xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns)…
5344 $this->debug("in serializeType: returning: $xml");
5351 $elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
5354 …$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . "…
5359 …$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . "…
5362 … $xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle);
5365 $this->debug("in serializeType: phpType is struct, but value is not an array");
5366 $this->setError("phpType is struct, but value is not an array: see debug output for details");
5385 $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
5389 $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) .
5391 $this->getLocalPart($typeDef['arrayType'])."[0]\"/>";
5393 $this->debug("in serializeType: returning: $xml");
5410 $this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
5412 if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) {
5430 $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/')
5432 .$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType']))
5433 .":".$this->getLocalPart($typeDef['arrayType'])."[$rows$cols]\">"
5449 …$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$…
5454 …$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingS…
5457 $this->debug("in serializeType: returning: $xml");
5474 $this->debug("serialize attributes for XML Schema type $ns:$uqType");
5480 $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
5486 $this->debug("value provided for attribute $aName with key $xname");
5489 $this->debug("value provided for attribute $aName with key $xname");
5493 $this->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName);
5496 $this->debug("no value provided for attribute $aName");
5499 $xml .= " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\"";
5503 $this->debug("no attributes to serialize for XML Schema type $ns:$uqType");
5506 $ns = $this->getPrefix($typeDef['extensionBase']);
5507 $uqType = $this->getLocalPart($typeDef['extensionBase']);
5508 if ($this->getNamespaceFromPrefix($ns)) {
5509 $ns = $this->getNamespaceFromPrefix($ns);
5511 if ($typeDef = $this->getTypeDef($uqType, $ns)) {
5512 $this->debug("serialize attributes for extension base $ns:$uqType");
5513 $xml .= $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
5515 $this->debug("extension base $ns:$uqType is not a supported type");
5536 …$this->debug("in serializeComplexTypeElements, serialize elements for XML Schema type $ns:$uqType"…
5542 $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
5553 $this->debug('use default value of ' . $xvalue[$eName] . ' for element ' . $eName);
5562 …$this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minO…
5565 …$this->debug("no value provided for complexType element $eName and element is not nillable, so ser…
5578 … 'unbounded' || $attrs['maxOccurs'] > 1) && isset($v) && is_array($v) && $this->isArraySimpleOrStr…
5583 …$xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $…
5586 $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
5587 $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
5593 …$xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $…
5596 $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
5597 $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
5603 $this->debug("no elements to serialize for XML Schema type $ns:$uqType");
5606 $ns = $this->getPrefix($typeDef['extensionBase']);
5607 $uqType = $this->getLocalPart($typeDef['extensionBase']);
5608 if ($this->getNamespaceFromPrefix($ns)) {
5609 $ns = $this->getNamespaceFromPrefix($ns);
5611 if ($typeDef = $this->getTypeDef($uqType, $ns)) {
5612 $this->debug("serialize elements for extension base $ns:$uqType");
5613 … $xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle);
5615 $this->debug("extension base $ns:$uqType is not a supported type");
5640 $k = strpos($k,':') ? $this->expandQname($k) : $k;
5641 $v = strpos($v,':') ? $this->expandQname($v) : $v;
5653 $k = strpos($k,':') ? $this->expandQname($k) : $k;
5654 $v = strpos($v,':') ? $this->expandQname($v) : $v;
5662 …$restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrict…
5663 $arrayType = strpos($arrayType,':') ? $this->expandQname($arrayType) : $arrayType;
5665 …$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'…
5666 …$this->schemas[$typens][0]->addComplexType($name,$typeClass,$phpType,$compositor,$restrictionBase,…
5681 …$restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrict…
5683 …$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'…
5684 …$this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumerat…
5695 …$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'…
5696 $this->schemas[$typens][0]->addElement($attrs);
5766 … $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
5768 $this->messages[$name.'Request'][$pName] = $pType;
5771 $this->messages[$name.'Request']= '0';
5778 … $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
5780 $this->messages[$name.'Response'][$pName] = $pType;
5783 $this->messages[$name.'Response']= '0';
5846 $this->xml = $xml;
5847 $this->xml_encoding = $encoding;
5848 $this->method = $method;
5849 $this->decode_utf8 = $decode_utf8;
5861 $this->debug($err);
5863 $this->setError($err);
5868 $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration');
5871 $this->debug('No encoding specified in XML declaration');
5874 $this->debug('No XML declaration');
5876 $this->debug('Entering soap_parser(), length='.strlen($xml).', encoding='.$encoding);
5878 $this->parser = xml_parser_create($this->xml_encoding);
5881 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
5882 xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding);
5884 xml_set_object($this->parser, $this);
5886 xml_set_element_handler($this->parser, 'start_element','end_element');
5887 xml_set_character_data_handler($this->parser,'character_data');
5890 if(!xml_parse($this->parser,$xml,true)){
5893 xml_get_current_line_number($this->parser),
5894 xml_error_string(xml_get_error_code($this->parser)));
5895 $this->debug($err);
5896 $this->debug("XML payload:\n" . $xml);
5897 $this->setError($err);
5899 …$this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root…
5901 $this->soapresponse = $this->message[$this->root_struct]['result'];
5907 if(sizeof($this->multirefs) > 0){
5908 foreach($this->multirefs as $id => $hrefs){
5909 $this->debug('resolving multirefs for id: '.$id);
5910 $idVal = $this->buildVal($this->ids[$id]);
5915 $this->debug('resolving href at pos '.$refPos);
5916 $this->multirefs[$id][$refPos] = $idVal;
5921 xml_parser_free($this->parser);
5923 $this->debug('xml was empty, didn\'t parse!');
5924 $this->setError('xml was empty, didn\'t parse!');
5939 $pos = $this->position++;
5941 $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>'');
5944 $this->message[$pos]['depth'] = $this->depth++;
5948 $this->message[$this->parent]['children'] .= '|'.$pos;
5951 $this->message[$pos]['parent'] = $this->parent;
5953 $this->parent = $pos;
5955 $this->depth_array[$this->depth] = $pos;
5965 $this->status = 'envelope';
5967 $this->root_header = $pos;
5968 $this->status = 'header';
5970 $this->status = 'body';
5971 $this->body_position = $pos;
5973 } elseif($this->status == 'body' && $pos == ($this->body_position+1)){
5974 $this->status = 'method';
5975 $this->root_struct_name = $name;
5976 $this->root_struct = $pos;
5977 $this->message[$pos]['type'] = 'struct';
5978 $this->debug("found root struct $this->root_struct_name, pos $this->root_struct");
5981 $this->message[$pos]['status'] = $this->status;
5983 $this->message[$pos]['name'] = htmlspecialchars($name);
5985 $this->message[$pos]['attrs'] = $attrs;
5990 $key_prefix = $this->getPrefix($key);
5991 $key_localpart = $this->getLocalPart($key);
5995 $this->XMLSchemaVersion = $value;
5996 $this->namespaces['xsd'] = $this->XMLSchemaVersion;
5997 $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance';
5999 $this->namespaces[$key_localpart] = $value;
6001 if($name == $this->root_struct_name){
6002 $this->methodNamespace = $value;
6006 $value_prefix = $this->getPrefix($value);
6007 $value_localpart = $this->getLocalPart($value);
6008 $this->message[$pos]['type'] = $value_localpart;
6009 $this->message[$pos]['typePrefix'] = $value_prefix;
6010 if(isset($this->namespaces[$value_prefix])){
6011 $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix];
6013 $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix];
6017 $this->message[$pos]['type'] = 'array';
6028 $this->message[$pos]['typePrefix'] = $regs[1];
6029 $this->message[$pos]['arrayTypePrefix'] = $regs[1];
6030 if (isset($this->namespaces[$regs[1]])) {
6031 $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]];
6033 $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]];
6035 $this->message[$pos]['arrayType'] = $regs[2];
6036 $this->message[$pos]['arraySize'] = $regs[3];
6037 $this->message[$pos]['arrayCols'] = $regs[4];
6041 $this->message[$pos]['nil'] = ($value == 'true' || $value == '1');
6044 $this->message[$pos]['xattrs']['!' . $key] = $value;
6048 $this->default_namespace = $value;
6052 $this->ids[$value] = $pos;
6056 $this->status = 'method';
6057 $this->root_struct_name = $name;
6058 $this->root_struct = $pos;
6059 $this->debug("found root struct $this->root_struct_name, pos $pos");
6066 $this->message[$pos]['namespace'] = $this->namespaces[$prefix];
6067 $this->default_namespace = $this->namespaces[$prefix];
6069 $this->message[$pos]['namespace'] = $this->default_namespace;
6071 if($this->status == 'header'){
6072 if ($this->root_header != $pos) {
6073 $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
6075 } elseif($this->root_struct_name != ''){
6076 $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
6089 $pos = $this->depth_array[$this->depth--];
6100 if(isset($this->body_position) && $pos > $this->body_position){
6102 if(isset($this->message[$pos]['attrs']['href'])){
6104 $id = substr($this->message[$pos]['attrs']['href'],1);
6106 $this->multirefs[$id][$pos] = 'placeholder';
6108 $this->message[$pos]['result'] =& $this->multirefs[$id][$pos];
6110 } elseif($this->message[$pos]['children'] != ''){
6112 if(!isset($this->message[$pos]['result'])){
6113 $this->message[$pos]['result'] = $this->buildVal($pos);
6116 } elseif (isset($this->message[$pos]['xattrs'])) {
6117 if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
6118 $this->message[$pos]['xattrs']['!'] = null;
6119 } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
6120 if (isset($this->message[$pos]['type'])) {
6121this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->mes…
6123 $parent = $this->message[$pos]['parent'];
6124 …if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isse…
6125this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->mes…
6127 $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata'];
6131 $this->message[$pos]['result'] = $this->message[$pos]['xattrs'];
6135 if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
6136 $this->message[$pos]['xattrs']['!'] = null;
6137 } elseif (isset($this->message[$pos]['type'])) {
6138this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[…
6140 $parent = $this->message[$pos]['parent'];
6141 …if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isse…
6142this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[…
6144 $this->message[$pos]['result'] = $this->message[$pos]['cdata'];
6162 if($this->status == 'header'){
6163 if ($this->root_header != $pos) {
6164 $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
6166 } elseif($pos >= $this->root_struct){
6167 $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
6170 if($pos == $this->root_struct){
6171 $this->status = 'body';
6172 $this->root_struct_namespace = $this->message[$pos]['namespace'];
6174 $this->status = 'envelope';
6176 $this->status = 'envelope';
6181 $this->parent = $this->message[$pos]['parent'];
6192 $pos = $this->depth_array[$this->depth];
6193 if ($this->xml_encoding=='UTF-8'){
6197 if($this->decode_utf8){
6201 $this->message[$pos]['cdata'] .= $data;
6203 if($this->status == 'header'){
6204 $this->responseHeaders .= $data;
6206 $this->document .= $data;
6217 return $this->soapresponse;
6227 return $this->responseHeaders;
6257 $this->debug('Decode base64 value');
6284 if(!isset($this->message[$pos]['type'])){
6285 $this->message[$pos]['type'] = '';
6287 …$this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->messag…
6289 if($this->message[$pos]['children'] != ''){
6290 $this->debug('in buildVal, there are children');
6291 $children = explode('|',$this->message[$pos]['children']);
6294 if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){
6298 $this->debug("in buildVal, got an MD array element: $r, $c");
6299 $params[$r][] = $this->message[$child_pos]['result'];
6301 if($c == $this->message[$pos]['arrayCols']){
6307 } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){
6308 $this->debug('in buildVal, adding array '.$this->message[$pos]['name']);
6310 $params[] = &$this->message[$child_pos]['result'];
6313 …} elseif($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http:…
6332 $params[] = &$this->message[$child_pos]['result'];
6334 if (isset($params[$this->message[$child_pos]['name']])) {
6336 …if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$ch…
6337 … $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]);
6339 … $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result'];
6341 $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result'];
6346 if (isset($this->message[$pos]['xattrs'])) {
6347 $this->debug('in buildVal, handling attributes');
6348 foreach ($this->message[$pos]['xattrs'] as $n => $v) {
6353 if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
6354 $this->debug('in buildVal, handling simpleContent');
6355 if (isset($this->message[$pos]['type'])) {
6356 …s['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($t…
6358 $parent = $this->message[$pos]['parent'];
6359 …if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isse…
6360 … $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($t…
6362 $params['!'] = $this->message[$pos]['cdata'];
6368 $this->debug('in buildVal, no children, building scalar');
6369 $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : '';
6370 if (isset($this->message[$pos]['type'])) {
6371 …return $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_…
6373 $parent = $this->message[$pos]['parent'];
6374 …if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isse…
6375 …return $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$par…
6377 return $this->message[$pos]['cdata'];
6476 $this->endpoint = $endpoint;
6477 $this->proxyhost = $proxyhost;
6478 $this->proxyport = $proxyport;
6479 $this->proxyusername = $proxyusername;
6480 $this->proxypassword = $proxypassword;
6481 $this->timeout = $timeout;
6482 $this->response_timeout = $response_timeout;
6487 $this->wsdl = $endpoint;
6488 $this->endpoint = $this->wsdl->wsdl;
6489 $this->wsdlFile = $this->endpoint;
6490 $this->debug('existing wsdl instance created from ' . $this->endpoint);
6492 $this->wsdlFile = $this->endpoint;
6495 $this->debug('instantiating wsdl class with doc: '.$endpoint);
6496 …$this->wsdl =& new wsdl($this->wsdlFile,$this->proxyhost,$this->proxyport,$this->proxyusername,$th…
6498 $this->appendDebug($this->wsdl->getDebug());
6499 $this->wsdl->clearDebug();
6501 if($errstr = $this->wsdl->getError()){
6502 $this->debug('got wsdl error: '.$errstr);
6503 $this->setError('wsdl error: '.$errstr);
6504 } elseif($this->operations = $this->wsdl->getOperations()){
6505 $this->debug( 'got '.count($this->operations).' operations from wsdl '.$this->wsdlFile);
6506 $this->endpointType = 'wsdl';
6508 $this->debug( 'getOperations returned false');
6509 $this->setError('no operations defined in the WSDL document!');
6512 $this->debug("instantiate SOAP with endpoint at $endpoint");
6513 $this->endpointType = 'soap';
6643 $this->debug("wrapping RPC request with literal method element");
6650 $this->debug("wrapping RPC request with encoded method element");
6663 …$soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders,$usedNamespaces,$style,$use,$en…
6664 …$this->debug("endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style…
6665 …$this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($s…
6667 …$return = $this->send($this->getHTTPBody($soapmsg),$soapAction,$this->timeout,$this->response_time…
6668 if($errstr = $this->getError()){
6669 $this->debug('Error: '.$errstr);
6672 $this->return = $return;
6673 $this->debug('sent message successfully and got a(n) '.gettype($return));
6674 $this->appendDebug('return=' . $this->varDump($return));
6678 $this->debug('got fault');
6679 $this->setError($return['faultcode'].': '.$return['faultstring']);
6680 $this->fault = true;
6682 $this->$k = $v;
6683 $this->debug("$k = $v<br>");
6700 $this->debug('return shifted value: ');
6701 $this->appendDebug($this->varDump($return));
6719 if(isset($this->operations[$operation])){
6720 return $this->operations[$operation];
6722 $this->debug("No data for operation: $operation");
6740 $this->checkCookies();
6744 case ereg('^http',$this->endpoint):
6745 $this->debug('transporting via HTTP');
6746 if($this->persistentConnection == true && is_object($this->persistentConnection)){
6747 $http =& $this->persistentConnection;
6749 $http = new soap_transport_http($this->endpoint);
6750 if ($this->persistentConnection) {
6754 $http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset());
6756 if($this->proxyhost && $this->proxyport){
6757 $http->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
6759 if($this->authtype != '') {
6760 …$http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certReque…
6762 if($this->http_encoding != ''){
6763 $http->setEncoding($this->http_encoding);
6765 $this->debug('sending message, length='.strlen($msg));
6766 if(ereg('^http:',$this->endpoint)){
6768 $this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies);
6769 } elseif(ereg('^https',$this->endpoint)){
6776 $this->responseData = $http->sendHTTPS($msg,$timeout,$response_timeout,$this->cookies);
6778 $this->setError('no http/s in endpoint url');
6780 $this->request = $http->outgoing_payload;
6781 $this->response = $http->incoming_payload;
6782 $this->appendDebug($http->getDebug());
6783 $this->UpdateCookies($http->incoming_cookies);
6786 if ($this->persistentConnection) {
6788 if (!is_object($this->persistentConnection)) {
6789 $this->persistentConnection = $http;
6794 $this->setError('HTTP Error: '.$err);
6796 } elseif($this->getError()){
6799 …$this->debug('got response, length='. strlen($this->responseData).' type='.$http->incoming_headers…
6800 return $this->parseResponse($http->incoming_headers, $this->responseData);
6804 $this->setError('no transport found, or selected transport is not yet supported!');
6819 …$this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' and type ' . $head…
6821 $this->setError('Response not of type text/xml');
6826 $this->debug('Got response encoding: ' . $enc);
6828 $this->xml_encoding = strtoupper($enc);
6830 $this->xml_encoding = 'US-ASCII';
6834 $this->xml_encoding = 'ISO-8859-1';
6836 $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating soap_parser');
6837 $parser = new soap_parser($data,$this->xml_encoding,$this->operation,$this->decode_utf8);
6839 $this->appendDebug($parser->getDebug());
6842 $this->setError( $errstr);
6848 $this->responseHeaders = $parser->getHeaders();
6852 $this->document = $parser->document;
6867 $this->forceEndpoint = $endpoint;
6877 $this->requestHeaders = $headers;
6887 return $this->responseHeaders;
6900 $this->proxyhost = $proxyhost;
6901 $this->proxyport = $proxyport;
6902 $this->proxyusername = $proxyusername;
6903 $this->proxypassword = $proxypassword;
6916 $this->username = $username;
6917 $this->password = $password;
6918 $this->authtype = $authtype;
6919 $this->certRequest = $certRequest;
6929 $this->http_encoding = $enc;
6938 $this->persistentConnection = true;
6953 return $this->defaultRpcParams;
6968 $this->defaultRpcParams = $rpcParams;
6980 $evalStr = $this->_getProxyClassCode($r);
6988 $proxy->wsdlFile = $this->wsdlFile;
6989 $proxy->wsdl = $this->wsdl;
6990 $proxy->operations = $this->operations;
6991 $proxy->defaultRpcParams = $this->defaultRpcParams;
6993 $proxy->username = $this->username;
6994 $proxy->password = $this->password;
6995 $proxy->authtype = $this->authtype;
6996 $proxy->proxyhost = $this->proxyhost;
6997 $proxy->proxyport = $this->proxyport;
6998 $proxy->proxyusername = $this->proxyusername;
6999 $proxy->proxypassword = $this->proxypassword;
7000 $proxy->timeout = $this->timeout;
7001 $proxy->response_timeout = $this->response_timeout;
7002 $proxy->http_encoding = $this->http_encoding;
7003 $proxy->persistentConnection = $this->persistentConnection;
7004 $proxy->requestHeaders = $this->requestHeaders;
7005 $proxy->soap_defencoding = $this->soap_defencoding;
7006 $proxy->endpoint = $this->endpoint;
7007 $proxy->forceEndpoint = $this->forceEndpoint;
7018 if ($this->endpointType != 'wsdl') {
7020 $this->setError($evalStr);
7024 foreach ($this->operations as $operation => $opData) {
7207 for ($i = 0; $i < count($this->cookies); $i++) {
7208 $cookie = $this->cookies[$i];
7228 $this->cookies[$i] = $newCookie;
7230 $this->debug('Update cookie ' . $newName . '=' . $newCookie['value']);
7234 $this->debug('Add cookie ' . $newName . '=' . $newCookie['value']);
7235 $this->cookies[] = $newCookie;