75 $GLOBALS[
'_transient'][
'static'][
'nusoap_base']->globalDebugLevel = 0;
164 'SOAP-ENV' =>
'http://schemas.xmlsoap.org/soap/envelope/',
165 'xsd' =>
'http://www.w3.org/2001/XMLSchema',
166 'xsi' =>
'http://www.w3.org/2001/XMLSchema-instance',
167 'SOAP-ENC' =>
'http://schemas.xmlsoap.org/soap/encoding/'
186 'http://www.w3.org/2001/XMLSchema' => array(
187 'string'=>
'string',
'boolean'=>
'boolean',
'float'=>
'double',
'double'=>
'double',
'decimal'=>
'double',
188 'duration'=>
'',
'dateTime'=>
'string',
'time'=>
'string',
'date'=>
'string',
'gYearMonth'=>
'',
189 'gYear'=>
'',
'gMonthDay'=>
'',
'gDay'=>
'',
'gMonth'=>
'',
'hexBinary'=>
'string',
'base64Binary'=>
'string',
191 'anyType'=>
'string',
'anySimpleType'=>
'string',
193 'normalizedString'=>
'string',
'token'=>
'string',
'language'=>
'',
'NMTOKEN'=>
'',
'NMTOKENS'=>
'',
'Name'=>
'',
'NCName'=>
'',
'ID'=>
'',
194 'IDREF'=>
'',
'IDREFS'=>
'',
'ENTITY'=>
'',
'ENTITIES'=>
'',
'integer'=>
'integer',
'nonPositiveInteger'=>
'integer',
195 'negativeInteger'=>
'integer',
'long'=>
'integer',
'int'=>
'integer',
'short'=>
'integer',
'byte'=>
'integer',
'nonNegativeInteger'=>
'integer',
196 'unsignedLong'=>
'',
'unsignedInt'=>
'',
'unsignedShort'=>
'',
'unsignedByte'=>
'',
'positiveInteger'=>
''),
197 'http://www.w3.org/2000/10/XMLSchema' => array(
198 'i4'=>
'',
'int'=>
'integer',
'boolean'=>
'boolean',
'string'=>
'string',
'double'=>
'double',
199 'float'=>
'double',
'dateTime'=>
'string',
200 'timeInstant'=>
'string',
'base64Binary'=>
'string',
'base64'=>
'string',
'ur-type'=>
'array'),
201 'http://www.w3.org/1999/XMLSchema' => array(
202 'i4'=>
'',
'int'=>
'integer',
'boolean'=>
'boolean',
'string'=>
'string',
'double'=>
'double',
203 'float'=>
'double',
'dateTime'=>
'string',
204 'timeInstant'=>
'string',
'base64Binary'=>
'string',
'base64'=>
'string',
'ur-type'=>
'array'),
205 'http://soapinterop.org/xsd' => array(
'SOAPStruct'=>
'struct'),
206 'http://schemas.xmlsoap.org/soap/encoding/' => array(
'base64'=>
'string',
'array'=>
'array',
'Array'=>
'array'),
207 'http://xml.apache.org/xml-soap' => array(
'Map')
219 'lt' =>
'<',
'gt' =>
'>',
'apos' =>
"'");
227 $this->debugLevel =
$GLOBALS[
'_transient'][
'static'][
'nusoap_base']->globalDebugLevel;
237 return $GLOBALS[
'_transient'][
'static'][
'nusoap_base']->globalDebugLevel;
247 $GLOBALS[
'_transient'][
'static'][
'nusoap_base']->globalDebugLevel = $level;
267 $this->debugLevel = $level;
277 if ($this->debugLevel > 0) {
289 if ($this->debugLevel > 0) {
292 $this->debug_str .= $string;
304 $this->debug_str =
'';
329 while (strpos($this->debug_str,
'--')) {
330 $this->debug_str = str_replace(
'--',
'- -', $this->debug_str);
332 $ret =
"<!--\n" . $this->debug_str .
"\n-->";
343 if ($this->charencoding) {
344 $val = str_replace(
'&',
'&', $val);
345 $val = str_replace(
"'",
''', $val);
346 $val = str_replace(
'"',
'"', $val);
347 $val = str_replace(
'<',
'<', $val);
348 $val = str_replace(
'>',
'>', $val);
360 if($this->error_str !=
''){
373 $this->error_str = $str;
384 $keyList = array_keys($val);
385 foreach ($keyList as $keyListValue) {
386 if (!is_int($keyListValue)) {
387 return 'arrayStruct';
390 return 'arraySimple';
408 function serialize_val($val,
$name=
false,
$type=
false,$name_ns=
false,$type_ns=
false,$attributes=
false,$use=
'encoded',$soapval=
false) {
409 $this->
debug(
"in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
413 if (is_object($val) && get_class($val) ==
'soapval' && (! $soapval)) {
414 $this->
debug(
"serialize_val: serialize soapval");
415 $xml = $val->serialize($use);
418 $this->
debug(
"serialize_val of soapval returning $xml");
422 if (is_numeric(
$name)) {
430 $prefix =
'nu'.rand(1000,9999);
432 $xmlns .=
" xmlns:$prefix=\"$name_ns\"";
435 if($type_ns !=
'' && $type_ns == $this->namespaces[
'xsd']){
438 $type_prefix =
'xsd';
440 $type_prefix =
'ns'.rand(1000,9999);
441 $xmlns .=
" xmlns:$type_prefix=\"$type_ns\"";
446 foreach($attributes as $k => $v){
447 $atts .=
" $k=\"".$this->expandEntities($v).
'"';
452 $this->
debug(
"serialize_val: serialize null");
453 if ($use ==
'literal') {
455 $xml =
"<$name$xmlns$atts/>";
456 $this->
debug(
"serialize_val returning $xml");
459 if (isset(
$type) && isset($type_prefix)) {
460 $type_str =
" xsi:type=\"$type_prefix:$type\"";
464 $xml =
"<$name$xmlns$type_str$atts xsi:nil=\"true\"/>";
465 $this->
debug(
"serialize_val returning $xml");
470 if(
$type !=
'' && isset($this->typemap[$this->XMLSchemaVersion][
$type])){
471 $this->
debug(
"serialize_val: serialize xsd built-in primitive type");
473 if ($type ==
'boolean') {
474 $val = $val ?
'true' :
'false';
478 }
else if (is_string($val)) {
481 if ($use ==
'literal') {
482 $xml =
"<$name$xmlns$atts>$val</$name>";
483 $this->
debug(
"serialize_val returning $xml");
486 $xml =
"<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>";
487 $this->
debug(
"serialize_val returning $xml");
494 case (is_bool($val) || $type ==
'boolean'):
495 $this->
debug(
"serialize_val: serialize boolean");
496 if ($type ==
'boolean') {
497 $val = $val ?
'true' :
'false';
501 if ($use ==
'literal') {
502 $xml .=
"<$name$xmlns$atts>$val</$name>";
504 $xml .=
"<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>";
507 case (is_int($val) || is_long($val) || $type ==
'int'):
508 $this->
debug(
"serialize_val: serialize int");
509 if ($use ==
'literal') {
510 $xml .=
"<$name$xmlns$atts>$val</$name>";
512 $xml .=
"<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>";
515 case (is_float($val)|| is_double($val) || $type ==
'float'):
516 $this->
debug(
"serialize_val: serialize float");
517 if ($use ==
'literal') {
518 $xml .=
"<$name$xmlns$atts>$val</$name>";
520 $xml .=
"<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>";
523 case (is_string($val) || $type ==
'string'):
524 $this->
debug(
"serialize_val: serialize string");
526 if ($use ==
'literal') {
527 $xml .=
"<$name$xmlns$atts>$val</$name>";
529 $xml .=
"<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>";
532 case is_object($val):
533 $this->
debug(
"serialize_val: serialize object");
534 if (get_class($val) ==
'soapval') {
535 $this->
debug(
"serialize_val: serialize soapval object");
536 $pXml = $val->serialize($use);
541 $name = get_class($val);
542 $this->
debug(
"In serialize_val, used class name $name as element name");
544 $this->
debug(
"In serialize_val, do not override name $name for element name for class " . get_class($val));
546 foreach(get_object_vars($val) as $k => $v){
547 $pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,
false,
false,
false,
false,$use) : $this->
serialize_val($v,$k,
false,
false,
false,
false,$use);
550 if(isset($type) && isset($type_prefix)){
551 $type_str =
" xsi:type=\"$type_prefix:$type\"";
555 if ($use ==
'literal') {
556 $xml .=
"<$name$xmlns$atts>$pXml</$name>";
558 $xml .=
"<$name$xmlns$type_str$atts>$pXml</$name>";
562 case (is_array($val) || $type):
565 if($valueType==
'arraySimple' || preg_match(
'/^ArrayOf/',$type)){
566 $this->
debug(
"serialize_val: serialize array");
568 if(is_array($val) && count($val)> 0){
570 if(is_object($v) && get_class($v) ==
'soapval'){
571 $tt_ns = $v->type_ns;
573 } elseif (is_array($v)) {
578 $array_types[$tt] = 1;
580 $xml .= $this->
serialize_val($v,
'item',
false,
false,
false,
false,$use);
583 if(count($array_types) > 1){
584 $array_typename =
'xsd:anyType';
585 } elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
586 if ($tt ==
'integer') {
589 $array_typename =
'xsd:'.$tt;
590 } elseif(isset($tt) && $tt ==
'arraySimple'){
591 $array_typename =
'SOAP-ENC:Array';
592 } elseif(isset($tt) && $tt ==
'arrayStruct'){
593 $array_typename =
'unnamed_struct_use_soapval';
596 if ($tt_ns !=
'' && $tt_ns == $this->namespaces[
'xsd']){
597 $array_typename =
'xsd:' . $tt;
599 $tt_prefix =
'ns' . rand(1000, 9999);
600 $array_typename =
"$tt_prefix:$tt";
601 $xmlns .=
" xmlns:$tt_prefix=\"$tt_ns\"";
603 $array_typename = $tt;
607 if ($use ==
'literal') {
609 }
else if (isset($type) && isset($type_prefix)) {
610 $type_str =
" xsi:type=\"$type_prefix:$type\"";
612 $type_str =
" xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename.
"[$array_type]\"";
616 if ($use ==
'literal') {
618 }
else if (isset($type) && isset($type_prefix)) {
619 $type_str =
" xsi:type=\"$type_prefix:$type\"";
621 $type_str =
" xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\"";
625 $xml =
"<$name$xmlns$type_str$atts>".$xml.
"</$name>";
628 $this->
debug(
"serialize_val: serialize struct");
629 if(isset($type) && isset($type_prefix)){
630 $type_str =
" xsi:type=\"$type_prefix:$type\"";
634 if ($use ==
'literal') {
635 $xml .=
"<$name$xmlns$atts>";
637 $xml .=
"<$name$xmlns$type_str$atts>";
639 foreach($val as $k => $v){
641 if ($type ==
'Map' && $type_ns ==
'http://xml.apache.org/xml-soap') {
643 $xml .= $this->
serialize_val($k,
'key',
false,
false,
false,
false,$use);
644 $xml .= $this->
serialize_val($v,
'value',
false,
false,
false,
false,$use);
647 $xml .= $this->
serialize_val($v,$k,
false,
false,
false,
false,$use);
654 $this->
debug(
"serialize_val: serialize unknown");
655 $xml .=
'not detected, got '.gettype($val).
' for '.$val;
658 $this->
debug(
"serialize_val returning $xml");
674 function serializeEnvelope($body,$headers=
false,
$namespaces=array(),$style=
'rpc',$use=
'encoded',$encodingStyle=
'http://schemas.xmlsoap.org/soap/encoding/'){
679 $this->
debug(
"In serializeEnvelope length=" . strlen($body) .
" body (max 1000 characters)=" . substr($body, 0, 1000) .
" style=$style use=$use encodingStyle=$encodingStyle");
680 $this->
debug(
"headers:");
682 $this->
debug(
"namespaces:");
687 foreach(array_merge($this->namespaces,
$namespaces) as $k => $v){
688 $ns_string .=
" xmlns:$k=\"$v\"";
691 $ns_string =
" SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string";
696 if (is_array($headers)) {
698 foreach ($headers as $k => $v) {
699 if (is_object($v) && get_class($v) ==
'soapval') {
700 $xml .= $this->
serialize_val($v,
false,
false,
false,
false,
false, $use);
702 $xml .= $this->
serialize_val($v, $k,
false,
false,
false,
false, $use);
706 $this->
debug(
"In serializeEnvelope, serialized array of headers to $headers");
708 $headers =
"<SOAP-ENV:Header>".$headers.
"</SOAP-ENV:Header>";
712 '<?xml version="1.0" encoding="'.$this->soap_defencoding .
'"?'.
">".
713 '<SOAP-ENV:Envelope'.$ns_string.
">".
718 "</SOAP-ENV:Envelope>";
730 $str = htmlspecialchars($str);
744 if (strrpos($qname,
':')) {
746 $name = substr($qname, strrpos($qname,
':') + 1);
748 $ns = substr($qname, 0, strrpos($qname,
':'));
751 return $p .
':' .
$name;
768 if(strpos($qname,
':') && !preg_match(
'/^http:\/\//',$qname)){
770 $name = substr(strstr($qname,
':'),1);
772 $prefix = substr($qname,0,strpos($qname,
':'));
773 if(isset($this->namespaces[$prefix])){
774 return $this->namespaces[$prefix].
':'.
$name;
792 if($sstr = strrchr($str,
':')){
794 return substr( $sstr, 1 );
809 if(
$pos = strrpos($str,
':')){
811 return substr($str,0,
$pos);
824 if (isset($this->namespaces[$prefix])) {
825 return $this->namespaces[$prefix];
840 foreach ($this->namespaces as $p => $n) {
841 if ($ns == $n || $ns == $p) {
842 $this->usedNamespaces[$p] = $n;
856 if (function_exists(
'gettimeofday')) {
857 $tod = gettimeofday();
859 $usec = $tod[
'usec'];
864 return strftime(
'%Y-%m-%d %H:%M:%S', $sec) .
'.' . sprintf(
'%06d', $usec);
877 $ret_val = ob_get_contents();
914 '([0-9]{2})(\.[0-9]*)?'.
915 '(Z|[+\-][0-9]{2}:?[0-9]{2})?'.
918 if(preg_match($pattern,$datestr,$regs)){
919 return sprintf(
'%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
941 '([0-9]{2})(\.[0-9]+)?'.
942 '(Z|[+\-][0-9]{2}:?[0-9]{2})?'.
945 if(preg_match($pattern,$datestr,$regs)){
948 $op = substr($regs[8],0,1);
949 $h = substr($regs[8],1,2);
950 $m = substr($regs[8],strlen($regs[8])-2,2);
952 $regs[4] = $regs[4] + $h;
953 $regs[5] = $regs[5] + $m;
954 } elseif($op ==
'+'){
955 $regs[4] = $regs[4] - $h;
956 $regs[5] = $regs[5] - $m;
959 return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
975 $start = gettimeofday();
979 $stop = gettimeofday();
980 $timePassed = 1000000 * ($stop[
'sec'] - $start[
'sec'])
981 + $stop[
'usec'] - $start[
'usec'];
983 while ($timePassed < $usec);
1048 foreach($this->namespaces as $k => $v){
1049 $ns_string .=
"\n xmlns:$k=\"$v\"";
1052 '<?xml version="1.0" encoding="'.$this->soap_defencoding.
'"?>'.
1053 '<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"'.$ns_string.
">\n".
1060 '</SOAP-ENV:Fault>'.
1062 '</SOAP-ENV:Envelope>';
1127 $this->
debug(
'nusoap_xmlschema class instantiated, inside constructor');
1134 $this->namespaces = array_merge($this->namespaces,
$namespaces);
1144 $this->
debug(
'initial xml file: '.
$xml);
1161 $xmlStr = @join(
"",@file(
$xml));
1163 $msg =
'Error reading XML from '.$xml;
1168 $this->
debug(
"parsing $xml");
1170 $this->
debug(
"done parsing $xml");
1189 $this->parser = xml_parser_create();
1191 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
1194 xml_set_object($this->parser, $this);
1197 if(
$type ==
"schema"){
1198 xml_set_element_handler($this->parser,
'schemaStartElement',
'schemaEndElement');
1199 xml_set_character_data_handler($this->parser,
'schemaCharacterData');
1200 } elseif(
$type ==
"xml"){
1201 xml_set_element_handler($this->parser,
'xmlStartElement',
'xmlEndElement');
1202 xml_set_character_data_handler($this->parser,
'xmlCharacterData');
1206 if(!xml_parse($this->parser,
$xml,
true)){
1208 $errstr = sprintf(
'XML error parsing XML schema on line %d: %s',
1209 xml_get_current_line_number($this->parser),
1210 xml_error_string(xml_get_error_code($this->parser))
1212 $this->
debug($errstr);
1217 xml_parser_free($this->parser);
1219 $this->
debug(
'no xml passed to parseString()!!');
1220 $this->
setError(
'no xml passed to parseString()!!');
1233 for ($i = 0; $i < count($this->complexTypeStack); $i++) {
1234 $scope .= $this->complexTypeStack[$i] .
'_';
1236 return $scope . $ename .
'_ContainedType';
1250 $pos = $this->position++;
1254 $this->message[
$pos] = array(
'cdata' =>
'');
1256 $this->defaultNamespace[
$pos] = $this->defaultNamespace[$this->depth_array[
$depth - 1]];
1258 $this->defaultNamespace[
$pos] =
false;
1270 if(count($attrs) > 0){
1271 foreach($attrs as $k => $v){
1273 if(preg_match(
'/^xmlns/',$k)){
1276 if($ns_prefix = substr(strrchr($k,
':'),1)){
1278 $this->namespaces[$ns_prefix] = $v;
1280 $this->defaultNamespace[
$pos] = $v;
1282 $this->namespaces[
'ns'.(count($this->namespaces)+1)] = $v;
1285 if($v ==
'http://www.w3.org/2001/XMLSchema' || $v ==
'http://www.w3.org/1999/XMLSchema' || $v ==
'http://www.w3.org/2000/10/XMLSchema'){
1286 $this->XMLSchemaVersion = $v;
1287 $this->namespaces[
'xsi'] = $v.
'-instance';
1291 foreach($attrs as $k => $v){
1293 $k = strpos($k,
':') ? $this->
expandQname($k) : $k;
1294 $v = strpos($v,
':') ? $this->
expandQname($v) : $v;
1315 $this->
xdebug(
"parsing attribute:");
1317 if (!isset($attrs[
'form'])) {
1318 $attrs[
'form'] = $this->schemaInfo[
'attributeFormDefault'];
1320 if (isset($attrs[
'http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
1321 $v = $attrs[
'http://schemas.xmlsoap.org/wsdl/:arrayType'];
1322 if (!strpos($v,
':')) {
1324 if ($this->defaultNamespace[
$pos]) {
1326 $attrs[
'http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[
$pos] .
':' . $attrs[
'http://schemas.xmlsoap.org/wsdl/:arrayType'];
1330 if(isset($attrs[
'name'])){
1331 $this->attributes[$attrs[
'name']] = $attrs;
1332 $aname = $attrs[
'name'];
1333 } elseif(isset($attrs[
'ref']) && $attrs[
'ref'] ==
'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){
1334 if (isset($attrs[
'http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
1335 $aname = $attrs[
'http://schemas.xmlsoap.org/wsdl/:arrayType'];
1339 } elseif(isset($attrs[
'ref'])){
1340 $aname = $attrs[
'ref'];
1341 $this->attributes[$attrs[
'ref']] = $attrs;
1344 if($this->currentComplexType){
1348 if(isset($attrs[
'http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->
getLocalPart($aname) ==
'arrayType'){
1351 if(isset($attrs[
'http://schemas.xmlsoap.org/wsdl/:arrayType'])){
1352 $v = $attrs[
'http://schemas.xmlsoap.org/wsdl/:arrayType'];
1356 if(strpos($v,
'[,]')){
1359 $v = substr($v,0,strpos($v,
'['));
1360 if(!strpos($v,
':') && isset($this->typemap[$this->XMLSchemaVersion][$v])){
1361 $v = $this->XMLSchemaVersion.
':'.$v;
1366 case 'complexContent':
1369 array_push($this->complexTypeStack, $this->currentComplexType);
1370 if(isset($attrs[
'name'])){
1373 $this->
xdebug(
'processing named complexType '.$attrs[
'name']);
1375 $this->currentComplexType = $attrs[
'name'];
1385 if(isset($attrs[
'base']) && preg_match(
'/:Array$/',$attrs[
'base'])){
1386 $this->
xdebug(
'complexType is unusual array');
1393 $this->
xdebug(
'processing unnamed complexType for element ' . $this->currentElement .
' named ' .
$name);
1394 $this->currentComplexType =
$name;
1405 if(isset($attrs[
'base']) && preg_match(
'/:Array$/',$attrs[
'base'])){
1406 $this->
xdebug(
'complexType is unusual array');
1414 array_push($this->elementStack, $this->currentElement);
1415 if (!isset($attrs[
'form'])) {
1416 $attrs[
'form'] = $this->schemaInfo[
'elementFormDefault'];
1418 if(isset($attrs[
'type'])){
1419 $this->
xdebug(
"processing typed element ".$attrs[
'name'].
" of type ".$attrs[
'type']);
1420 if (! $this->
getPrefix($attrs[
'type'])) {
1421 if ($this->defaultNamespace[
$pos]) {
1422 $attrs[
'type'] = $this->defaultNamespace[
$pos] .
':' . $attrs[
'type'];
1423 $this->
xdebug(
'used default namespace to make type ' . $attrs[
'type']);
1433 if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType][
'phpType'] ==
'array') {
1434 $this->
xdebug(
'arrayType for unusual array is ' . $attrs[
'type']);
1437 $this->currentElement = $attrs[
'name'];
1438 $ename = $attrs[
'name'];
1439 } elseif(isset($attrs[
'ref'])){
1440 $this->
xdebug(
"processing element as ref to ".$attrs[
'ref']);
1441 $this->currentElement =
"ref to ".$attrs[
'ref'];
1445 $this->
xdebug(
"processing untyped element " . $attrs[
'name'] .
' type ' .
$type);
1446 $this->currentElement = $attrs[
'name'];
1447 $attrs[
'type'] = $this->schemaTargetNamespace .
':' .
$type;
1448 $ename = $attrs[
'name'];
1450 if (isset($ename) && $this->currentComplexType) {
1451 $this->
xdebug(
"add element $ename to complexType $this->currentComplexType");
1453 } elseif (!isset($attrs[
'ref'])) {
1454 $this->
xdebug(
"add element $ename to elements array");
1455 $this->elements[ $attrs[
'name'] ] = $attrs;
1456 $this->elements[ $attrs[
'name'] ][
'typeClass'] =
'element';
1460 $this->
xdebug(
'enumeration ' . $attrs[
'value']);
1461 if ($this->currentSimpleType) {
1463 } elseif ($this->currentComplexType) {
1468 $this->
xdebug(
'extension ' . $attrs[
'base']);
1469 if ($this->currentComplexType) {
1474 if (isset($attrs[
'schemaLocation'])) {
1476 $this->imports[$attrs[
'namespace']][] = array(
'location' => $attrs[
'schemaLocation'],
'loaded' =>
false);
1479 $this->imports[$attrs[
'namespace']][] = array(
'location' =>
'',
'loaded' =>
true);
1481 $this->namespaces[
'ns'.(count($this->namespaces)+1)] = $attrs[
'namespace'];
1488 $this->
xdebug(
'restriction ' . $attrs[
'base']);
1489 if($this->currentSimpleType){
1491 } elseif($this->currentComplexType){
1493 if(strstr($attrs[
'base'],
':') ==
':Array'){
1499 $this->schemaInfo = $attrs;
1501 if (isset($attrs[
'targetNamespace'])) {
1502 $this->schemaTargetNamespace = $attrs[
'targetNamespace'];
1504 if (!isset($attrs[
'elementFormDefault'])) {
1505 $this->schemaInfo[
'elementFormDefault'] =
'unqualified';
1507 if (!isset($attrs[
'attributeFormDefault'])) {
1508 $this->schemaInfo[
'attributeFormDefault'] =
'unqualified';
1511 case 'simpleContent':
1514 array_push($this->simpleTypeStack, $this->currentSimpleType);
1515 if(isset($attrs[
'name'])){
1516 $this->
xdebug(
"processing simpleType for name " . $attrs[
'name']);
1517 $this->currentSimpleType = $attrs[
'name'];
1518 $this->simpleTypes[ $attrs[
'name'] ] = $attrs;
1519 $this->simpleTypes[ $attrs[
'name'] ][
'typeClass'] =
'simpleType';
1520 $this->simpleTypes[ $attrs[
'name'] ][
'phpType'] =
'scalar';
1523 $this->
xdebug(
'processing unnamed simpleType for element ' . $this->currentElement .
' named ' .
$name);
1524 $this->currentSimpleType =
$name;
1548 if(isset($this->depth_array[$this->depth])){
1559 if(
$name ==
'complexType'){
1560 $this->
xdebug(
'done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType :
'(unknown)'));
1561 $this->currentComplexType = array_pop($this->complexTypeStack);
1564 if(
$name ==
'element'){
1565 $this->
xdebug(
'done processing element ' . ($this->currentElement ? $this->currentElement :
'(unknown)'));
1566 $this->currentElement = array_pop($this->elementStack);
1568 if(
$name ==
'simpleType'){
1569 $this->
xdebug(
'done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType :
'(unknown)'));
1570 $this->currentSimpleType = array_pop($this->simpleTypeStack);
1582 $pos = $this->depth_array[$this->depth - 1];
1596 if (
sizeof($this->imports) > 0) {
1597 foreach($this->imports as $ns => $list) {
1598 foreach ($list as $ii) {
1599 if ($ii[
'location'] !=
'') {
1600 $xml .=
" <$schemaPrefix:import location=\"" . $ii[
'location'] .
'" namespace="' . $ns .
"\" />\n";
1602 $xml .=
" <$schemaPrefix:import namespace=\"" . $ns .
"\" />\n";
1608 foreach($this->complexTypes as $typeName => $attrs){
1611 if(isset($attrs[
'elements']) && (count($attrs[
'elements']) > 0)){
1612 foreach($attrs[
'elements'] as $element => $eParts){
1613 if(isset($eParts[
'ref'])){
1614 $contentStr .=
" <$schemaPrefix:element ref=\"$element\"/>\n";
1616 $contentStr .=
" <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts[
'type']) .
"\"";
1617 foreach ($eParts as $aName => $aValue) {
1619 if ($aName !=
'name' && $aName !=
'type') {
1620 $contentStr .=
" $aName=\"$aValue\"";
1623 $contentStr .=
"/>\n";
1627 if (isset($attrs[
'compositor']) && ($attrs[
'compositor'] !=
'')) {
1628 $contentStr =
" <$schemaPrefix:$attrs[compositor]>\n".$contentStr.
" </$schemaPrefix:$attrs[compositor]>\n";
1632 if(isset($attrs[
'attrs']) && (count($attrs[
'attrs']) >= 1)){
1633 foreach($attrs[
'attrs'] as $attr => $aParts){
1634 $contentStr .=
" <$schemaPrefix:attribute";
1635 foreach ($aParts as $a => $v) {
1636 if ($a ==
'ref' || $a ==
'type') {
1637 $contentStr .=
" $a=\"".$this->contractQName($v).
'"';
1638 } elseif ($a ==
'http://schemas.xmlsoap.org/wsdl/:arrayType') {
1639 $this->usedNamespaces[
'wsdl'] = $this->namespaces[
'wsdl'];
1640 $contentStr .=
' wsdl:arrayType="'.$this->contractQName($v).
'"';
1642 $contentStr .=
" $a=\"$v\"";
1645 $contentStr .=
"/>\n";
1649 if (isset($attrs[
'restrictionBase']) && $attrs[
'restrictionBase'] !=
''){
1650 $contentStr =
" <$schemaPrefix:restriction base=\"".$this->contractQName($attrs[
'restrictionBase']).
"\">\n".$contentStr.
" </$schemaPrefix:restriction>\n";
1652 if ((isset($attrs[
'elements']) && count($attrs[
'elements']) > 0) || (isset($attrs[
'attrs']) && count($attrs[
'attrs']) > 0)){
1653 $contentStr =
" <$schemaPrefix:complexContent>\n".$contentStr.
" </$schemaPrefix:complexContent>\n";
1657 if($contentStr !=
''){
1658 $contentStr =
" <$schemaPrefix:complexType name=\"$typeName\">\n".$contentStr.
" </$schemaPrefix:complexType>\n";
1660 $contentStr =
" <$schemaPrefix:complexType name=\"$typeName\"/>\n";
1662 $xml .= $contentStr;
1665 if(isset($this->simpleTypes) && count($this->simpleTypes) > 0){
1666 foreach($this->simpleTypes as $typeName => $eParts){
1667 $xml .=
" <$schemaPrefix:simpleType name=\"$typeName\">\n <$schemaPrefix:restriction base=\"".$this->contractQName($eParts[
'type']).
"\">\n";
1668 if (isset($eParts[
'enumeration'])) {
1669 foreach ($eParts[
'enumeration'] as $e) {
1670 $xml .=
" <$schemaPrefix:enumeration value=\"$e\"/>\n";
1673 $xml .=
" </$schemaPrefix:restriction>\n </$schemaPrefix:simpleType>";
1677 if(isset($this->elements) && count($this->elements) > 0){
1678 foreach($this->elements as $element => $eParts){
1679 $xml .=
" <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts[
'type']).
"\"/>\n";
1683 if(isset($this->attributes) && count($this->attributes) > 0){
1684 foreach($this->attributes as $attr => $aParts){
1685 $xml .=
" <$schemaPrefix:attribute name=\"$attr\" type=\"".$this->contractQName($aParts[
'type']).
"\"\n/>";
1690 foreach ($this->schemaInfo as $k => $v) {
1691 if ($k ==
'elementFormDefault' || $k ==
'attributeFormDefault') {
1692 $attr .=
" $k=\"$v\"";
1695 $el =
"<$schemaPrefix:schema$attr targetNamespace=\"$this->schemaTargetNamespace\"\n";
1696 foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
1697 $el .=
" xmlns:$nsp=\"$ns\"";
1699 $xml = $el .
">\n".$xml.
"</$schemaPrefix:schema>\n";
1710 $this->
debug(
'<' . $this->schemaTargetNamespace .
'> '.$string);
1726 if(isset($this->typemap[$ns][
$type])){
1728 return $this->typemap[$ns][
$type];
1729 } elseif(isset($this->complexTypes[$type])){
1731 return $this->complexTypes[
$type][
'phpType'];
1760 if (substr(
$type, -1) ==
'^') {
1767 if((! $is_element) && isset($this->complexTypes[
$type])){
1768 $this->
xdebug(
"in getTypeDef, found complexType $type");
1769 return $this->complexTypes[
$type];
1770 } elseif((! $is_element) && isset($this->simpleTypes[$type])){
1771 $this->
xdebug(
"in getTypeDef, found simpleType $type");
1772 if (!isset($this->simpleTypes[$type][
'phpType'])) {
1775 $uqType = substr($this->simpleTypes[$type][
'type'], strrpos($this->simpleTypes[$type][
'type'],
':') + 1);
1776 $ns = substr($this->simpleTypes[$type][
'type'], 0, strrpos($this->simpleTypes[$type][
'type'],
':'));
1779 $this->
xdebug(
"in getTypeDef, found type for simpleType $type:");
1781 if (isset($etype[
'phpType'])) {
1782 $this->simpleTypes[
$type][
'phpType'] = $etype[
'phpType'];
1784 if (isset($etype[
'elements'])) {
1785 $this->simpleTypes[
$type][
'elements'] = $etype[
'elements'];
1789 return $this->simpleTypes[
$type];
1790 } elseif(isset($this->elements[$type])){
1791 $this->
xdebug(
"in getTypeDef, found element $type");
1792 if (!isset($this->elements[$type][
'phpType'])) {
1794 $uqType = substr($this->elements[$type][
'type'], strrpos($this->elements[$type][
'type'],
':') + 1);
1795 $ns = substr($this->elements[$type][
'type'], 0, strrpos($this->elements[$type][
'type'],
':'));
1798 $this->
xdebug(
"in getTypeDef, found type for element $type:");
1800 if (isset($etype[
'phpType'])) {
1801 $this->elements[
$type][
'phpType'] = $etype[
'phpType'];
1803 if (isset($etype[
'elements'])) {
1804 $this->elements[
$type][
'elements'] = $etype[
'elements'];
1806 } elseif ($ns ==
'http://www.w3.org/2001/XMLSchema') {
1807 $this->
xdebug(
"in getTypeDef, element $type is an XSD type");
1808 $this->elements[
$type][
'phpType'] =
'scalar';
1811 return $this->elements[
$type];
1812 } elseif(isset($this->attributes[$type])){
1813 $this->
xdebug(
"in getTypeDef, found attribute $type");
1814 return $this->attributes[
$type];
1815 } elseif (preg_match(
'/_ContainedType$/', $type)) {
1816 $this->
xdebug(
"in getTypeDef, have an untyped element $type");
1817 $typeDef[
'typeClass'] =
'simpleType';
1818 $typeDef[
'phpType'] =
'scalar';
1819 $typeDef[
'type'] =
'http://www.w3.org/2001/XMLSchema:string';
1822 $this->
xdebug(
"in getTypeDef, did not find $type");
1838 if(is_array($typeDef[
'attrs'])){
1839 foreach($typeDef[
'attrs'] as $attName =>
$data){
1840 $str .=
" $attName=\"{type = ".$data[
'type'].
"}\"";
1843 $str .=
" xmlns=\"".$this->schema[
'targetNamespace'].
"\"";
1844 if(count($typeDef[
'elements']) > 0){
1846 foreach($typeDef[
'elements'] as $element => $eData){
1850 } elseif($typeDef[
'typeClass'] ==
'element') {
1851 $str .=
"></$type>";
1874 if($typeDef[
'phpType'] ==
'struct'){
1875 $buffer .=
'<table>';
1876 foreach($typeDef[
'elements'] as $child => $childDef){
1878 <tr><td align='right'>$childDef[name] (type: ".$this->getLocalPart($childDef[
'type']).
"):</td>
1879 <td><input type='text' name='parameters[".
$name.
"][$childDef[name]]'></td></tr>";
1881 $buffer .=
'</table>';
1883 } elseif($typeDef[
'phpType'] ==
'array'){
1884 $buffer .=
'<table>';
1885 for($i=0;$i < 3; $i++){
1887 <tr><td align='right'>array item (type: $typeDef[arrayType]):</td>
1888 <td><input type='text' name='parameters[".$name.
"][]'></td></tr>";
1890 $buffer .=
'</table>';
1893 $buffer .=
"<input type='text' name='parameters[$name]'>";
1896 $buffer .=
"<input type='text' name='parameters[$name]'>";
1942 function addComplexType(
$name,$typeClass=
'complexType',$phpType=
'array',$compositor=
'',$restrictionBase=
'',
$elements=array(),$attrs=array(),$arrayType=
''){
1943 $this->complexTypes[
$name] = array(
1945 'typeClass' => $typeClass,
1946 'phpType' => $phpType,
1947 'compositor'=> $compositor,
1948 'restrictionBase' => $restrictionBase,
1951 'arrayType' => $arrayType
1954 $this->
xdebug(
"addComplexType $name:");
1970 function addSimpleType(
$name, $restrictionBase=
'', $typeClass=
'simpleType', $phpType=
'scalar', $enumeration=array()) {
1971 $this->simpleTypes[
$name] = array(
1973 'typeClass' => $typeClass,
1974 'phpType' => $phpType,
1975 'type' => $restrictionBase,
1976 'enumeration' => $enumeration
1979 $this->
xdebug(
"addSimpleType $name:");
1991 if (! $this->
getPrefix($attrs[
'type'])) {
1992 $attrs[
'type'] = $this->schemaTargetNamespace .
':' . $attrs[
'type'];
1994 $this->elements[ $attrs[
'name'] ] = $attrs;
1995 $this->elements[ $attrs[
'name'] ][
'typeClass'] =
'element';
1997 $this->
xdebug(
"addElement " . $attrs[
'name']);
2080 $this->name =
$name;
2081 $this->type =
$type;
2096 return $this->
serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use,
true);
2172 $this->
debug(
"ctor url=$url use_curl=$use_curl curl_options:");
2175 if (is_array($curl_options)) {
2176 $this->ch_options = $curl_options;
2179 preg_match(
'/\$Revisio' .
'n: ([^ ]+)/', $this->revision, $rev);
2180 $this->
setHeader(
'User-Agent', $this->title.
'/'.$this->version.
' ('.$rev[1].
')');
2191 $this->
debug(
"setCurlOption option=$option, value=");
2193 curl_setopt($this->ch, $option, $value);
2204 $this->outgoing_headers[
$name] = $value;
2205 $this->
debug(
"set header $name: $value");
2215 if (isset($this->outgoing_headers[
$name])) {
2216 $this->
debug(
"unset header $name");
2217 unset($this->outgoing_headers[$name]);
2230 $u = parse_url(
$url);
2231 foreach($u as $k => $v){
2232 $this->
debug(
"parsed URL $k = $v");
2237 if(isset($u[
'query']) && $u[
'query'] !=
''){
2238 $this->path .=
'?' . $u[
'query'];
2242 if(!isset($u[
'port'])){
2243 if($u[
'scheme'] ==
'https'){
2254 if (!isset($u[
'port'])) {
2257 $this->
setHeader(
'Host', $this->host.
':'.$this->port);
2260 if (isset($u[
'user']) && $u[
'user'] !=
'') {
2261 $this->
setCredentials(urldecode($u[
'user']), isset($u[
'pass']) ? urldecode($u[
'pass']) :
'');
2272 if ($this->use_curl || ($this->scheme ==
'https') || ($this->scheme ==
'http' && $this->authtype ==
'ntlm') || ($this->scheme ==
'http' && is_array($this->proxy) && $this->proxy[
'authtype'] ==
'ntlm'))
2274 if (($this->scheme ==
'http' || $this->scheme ==
'ssl') && $this->authtype !=
'ntlm' && (!is_array($this->proxy) || $this->proxy[
'authtype'] !=
'ntlm'))
2287 function connect($connection_timeout=0,$response_timeout=30){
2300 $this->
debug(
"connect connection_timeout $connection_timeout, response_timeout $response_timeout, scheme $this->scheme, host $this->host, port $this->port");
2302 if (!is_array($this->proxy)) {
2306 $host = $this->proxy[
'host'];
2307 $port = $this->proxy[
'port'];
2311 if($this->persistentConnection && isset($this->fp) && is_resource($this->fp)){
2312 if (!feof($this->fp)) {
2313 $this->
debug(
'Re-use persistent connection');
2317 $this->
debug(
'Closed persistent connection at EOF');
2321 if ($this->scheme ==
'ssl') {
2324 $this->
debug(
'calling fsockopen with host ' .
$host .
' connection_timeout ' . $connection_timeout);
2327 if($connection_timeout > 0){
2328 $this->fp = @fsockopen(
$host, $this->port, $this->errno, $this->error_str, $connection_timeout);
2330 $this->fp = @fsockopen(
$host, $this->port, $this->errno, $this->error_str);
2335 $msg =
'Couldn\'t open socket connection to server ' .
$this->url;
2339 $msg .=
' prior to connect(). This is often a problem looking up the host name.';
2347 $this->
debug(
'set response timeout to ' . $response_timeout);
2348 socket_set_timeout( $this->fp, $response_timeout);
2350 $this->
debug(
'socket connected');
2352 }
else if ($this->
io_method() ==
'curl') {
2353 if (!extension_loaded(
'curl')) {
2355 $this->
setError(
'The PHP cURL Extension is required for HTTPS or NLTM. You will need to re-build or update your PHP to included cURL.');
2359 if (defined(
'CURLOPT_CONNECTIONTIMEOUT'))
2360 $CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT;
2362 $CURLOPT_CONNECTIONTIMEOUT = 78;
2363 if (defined(
'CURLOPT_HTTPAUTH'))
2364 $CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH;
2366 $CURLOPT_HTTPAUTH = 107;
2367 if (defined(
'CURLOPT_PROXYAUTH'))
2368 $CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH;
2370 $CURLOPT_PROXYAUTH = 111;
2371 if (defined(
'CURLAUTH_BASIC'))
2372 $CURLAUTH_BASIC = CURLAUTH_BASIC;
2374 $CURLAUTH_BASIC = 1;
2375 if (defined(
'CURLAUTH_DIGEST'))
2376 $CURLAUTH_DIGEST = CURLAUTH_DIGEST;
2378 $CURLAUTH_DIGEST = 2;
2379 if (defined(
'CURLAUTH_NTLM'))
2380 $CURLAUTH_NTLM = CURLAUTH_NTLM;
2384 $this->
debug(
'connect using cURL');
2386 $this->ch = curl_init();
2388 $hostURL = ($this->port !=
'') ?
"$this->scheme://$this->host:$this->port" :
"$this->scheme://$this->host";
2393 if (ini_get(
'safe_mode') || ini_get(
'open_basedir')) {
2394 $this->
debug(
'safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION');
2395 $this->
debug(
'safe_mode = ');
2397 $this->
debug(
'open_basedir = ');
2412 if ($this->persistentConnection) {
2418 $this->persistentConnection =
false;
2419 $this->
setHeader(
'Connection',
'close');
2422 if ($connection_timeout != 0) {
2423 $this->
setCurlOption($CURLOPT_CONNECTIONTIMEOUT, $connection_timeout);
2425 if ($response_timeout != 0) {
2429 if ($this->scheme ==
'https') {
2430 $this->
debug(
'set cURL SSL verify options');
2439 if ($this->authtype ==
'certificate') {
2440 $this->
debug(
'set cURL certificate options');
2441 if (isset($this->certRequest[
'cainfofile'])) {
2442 $this->
setCurlOption(CURLOPT_CAINFO, $this->certRequest[
'cainfofile']);
2444 if (isset($this->certRequest[
'verifypeer'])) {
2445 $this->
setCurlOption(CURLOPT_SSL_VERIFYPEER, $this->certRequest[
'verifypeer']);
2449 if (isset($this->certRequest[
'verifyhost'])) {
2450 $this->
setCurlOption(CURLOPT_SSL_VERIFYHOST, $this->certRequest[
'verifyhost']);
2454 if (isset($this->certRequest[
'sslcertfile'])) {
2455 $this->
setCurlOption(CURLOPT_SSLCERT, $this->certRequest[
'sslcertfile']);
2457 if (isset($this->certRequest[
'sslkeyfile'])) {
2458 $this->
setCurlOption(CURLOPT_SSLKEY, $this->certRequest[
'sslkeyfile']);
2460 if (isset($this->certRequest[
'passphrase'])) {
2461 $this->
setCurlOption(CURLOPT_SSLKEYPASSWD, $this->certRequest[
'passphrase']);
2463 if (isset($this->certRequest[
'certpassword'])) {
2464 $this->
setCurlOption(CURLOPT_SSLCERTPASSWD, $this->certRequest[
'certpassword']);
2468 if ($this->authtype && ($this->authtype !=
'certificate')) {
2469 if ($this->username) {
2470 $this->
debug(
'set cURL username/password');
2471 $this->
setCurlOption(CURLOPT_USERPWD,
"$this->username:$this->password");
2473 if ($this->authtype ==
'basic') {
2474 $this->
debug(
'set cURL for Basic authentication');
2477 if ($this->authtype ==
'digest') {
2478 $this->
debug(
'set cURL for digest authentication');
2481 if ($this->authtype ==
'ntlm') {
2482 $this->
debug(
'set cURL for NTLM authentication');
2486 if (is_array($this->proxy)) {
2487 $this->
debug(
'set cURL proxy options');
2488 if ($this->proxy[
'port'] !=
'') {
2489 $this->
setCurlOption(CURLOPT_PROXY, $this->proxy[
'host'].
':'.$this->proxy[
'port']);
2493 if ($this->proxy[
'username'] || $this->proxy[
'password']) {
2494 $this->
debug(
'set cURL proxy authentication options');
2495 $this->
setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy[
'username'].
':'.$this->proxy[
'password']);
2496 if ($this->proxy[
'authtype'] ==
'basic') {
2499 if ($this->proxy[
'authtype'] ==
'ntlm') {
2504 $this->
debug(
'cURL connection set up');
2507 $this->
setError(
'Unknown scheme ' . $this->scheme);
2508 $this->
debug(
'Unknown scheme ' . $this->scheme);
2523 function send(
$data, $timeout=0, $response_timeout=30, $cookies=NULL) {
2525 $this->
debug(
'entered send() with data of length: '.strlen(
$data));
2527 $this->tryagain =
true;
2529 while ($this->tryagain) {
2530 $this->tryagain =
false;
2533 if (!$this->
connect($timeout, $response_timeout)){
2545 $this->
setError(
"Too many tries to get an OK response ($this->response_status_line)");
2548 $this->
debug(
'end of send()');
2565 return $this->
send(
$data, $timeout, $response_timeout, $cookies);
2579 $this->
debug(
"setCredentials username=$username authtype=$authtype digestRequest=");
2581 $this->
debug(
"certRequest=");
2615 $unhashedDigest =
'';
2619 $unhashedDigest = $HA1 .
':' . $nonce .
':' . sprintf(
"%08d",
$digestRequest[
'nc']) .
':' . $cnonce .
':' .
$digestRequest[
'qop'] .
':' . $HA2;
2621 $unhashedDigest = $HA1 .
':' . $nonce .
':' . $HA2;
2624 $hashedDigest = md5($unhashedDigest);
2631 $this->
setHeader(
'Authorization',
'Digest username="' .
$username .
'", realm="' .
$digestRequest[
'realm'] .
'", nonce="' . $nonce .
'", uri="' . $this->digest_uri . $opaque .
'", cnonce="' . $cnonce .
'", nc=' . sprintf(
"%08x",
$digestRequest[
'nc']) .
', qop="' .
$digestRequest[
'qop'] .
'", response="' . $hashedDigest .
'"');
2635 $this->
debug(
'Authorization header not set for certificate');
2638 $this->
debug(
'Authorization header not set for ntlm');
2653 $this->
setHeader(
'SOAPAction',
'"' . $soapaction .
'"');
2663 if (function_exists(
'gzdeflate')) {
2664 $this->protocol_version =
'1.1';
2666 if (!isset($this->outgoing_headers[
'Connection'])) {
2667 $this->
setHeader(
'Connection',
'close');
2668 $this->persistentConnection =
false;
2670 set_magic_quotes_runtime(0);
2672 $this->encoding =
$enc;
2686 function setProxy($proxyhost, $proxyport, $proxyusername =
'', $proxypassword =
'', $proxyauthtype =
'basic') {
2688 $this->proxy = array(
2689 'host' => $proxyhost,
2690 'port' => $proxyport,
2691 'username' => $proxyusername,
2692 'password' => $proxypassword,
2693 'authtype' => $proxyauthtype
2695 if ($proxyusername !=
'' && $proxypassword !=
'' && $proxyauthtype =
'basic') {
2696 $this->
setHeader(
'Proxy-Authorization',
' Basic '.base64_encode($proxyusername.
':'.$proxypassword));
2699 $this->
debug(
'remove proxy');
2715 $skipHeaders = array(
'HTTP/1.1 100',
2722 'HTTP/1.0 200 Connection established');
2723 foreach ($skipHeaders as $hd) {
2724 $prefix = substr(
$data, 0, strlen($hd));
2725 if ($prefix == $hd)
return true;
2748 $chunkend = strpos($buffer, $lb);
2749 if ($chunkend == FALSE) {
2750 $this->
debug(
'no linebreak found in decodeChunked');
2753 $temp = substr($buffer,0,$chunkend);
2754 $chunk_size = hexdec( trim($temp) );
2755 $chunkstart = $chunkend + strlen($lb);
2757 while ($chunk_size > 0) {
2758 $this->
debug(
"chunkstart: $chunkstart chunk_size: $chunk_size");
2759 $chunkend = strpos( $buffer, $lb, $chunkstart + $chunk_size);
2762 if ($chunkend == FALSE) {
2763 $chunk = substr($buffer,$chunkstart);
2766 $length += strlen($chunk);
2771 $chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart);
2775 $length += strlen($chunk);
2777 $chunkstart = $chunkend + strlen($lb);
2779 $chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb);
2780 if ($chunkend == FALSE) {
2783 $temp = substr($buffer,$chunkstart,$chunkend-$chunkstart);
2784 $chunk_size = hexdec( trim($temp) );
2785 $chunkstart = $chunkend;
2812 $req =
"$this->request_method $uri HTTP/$this->protocol_version";
2813 $this->
debug(
"HTTP request: $req");
2814 $this->outgoing_payload =
"$req\r\n";
2817 foreach($this->outgoing_headers as $k => $v){
2819 $this->
debug(
"HTTP header: $hdr");
2820 $this->outgoing_payload .=
"$hdr\r\n";
2824 if ($cookie_str !=
'') {
2825 $hdr =
'Cookie: '.$cookie_str;
2826 $this->
debug(
"HTTP header: $hdr");
2827 $this->outgoing_payload .=
"$hdr\r\n";
2831 $this->outgoing_payload .=
"\r\n";
2834 $this->outgoing_payload .=
$data;
2847 $cookie_str = $this->
getCookiesForRequest($cookies, (($this->scheme ==
'ssl') || ($this->scheme ==
'https')));
2854 if(!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
2855 $this->
setError(
'couldn\'t write message data to socket');
2856 $this->
debug(
'couldn\'t write message data to socket');
2859 $this->
debug(
'wrote data to socket, length = ' . strlen($this->outgoing_payload));
2861 }
else if ($this->
io_method() ==
'curl') {
2867 $curl_headers = array();
2868 foreach($this->outgoing_headers as $k => $v){
2869 if ($k ==
'Connection' || $k ==
'Content-Length' || $k ==
'Host' || $k ==
'Authorization' || $k ==
'Proxy-Authorization') {
2870 $this->
debug(
"Skip cURL header $k: $v");
2872 $curl_headers[] =
"$k: $v";
2875 if ($cookie_str !=
'') {
2876 $curl_headers[] =
'Cookie: ' . $cookie_str;
2879 $this->
debug(
'set cURL HTTP headers');
2880 if ($this->request_method ==
"POST") {
2883 $this->
debug(
'set cURL POST data');
2887 foreach ($this->ch_options as $key => $val) {
2891 $this->
debug(
'set cURL payload');
2903 $this->incoming_payload =
'';
2908 while (!isset($lb)){
2911 if(feof($this->fp)) {
2912 $this->incoming_payload =
$data;
2913 $this->
debug(
'found no headers before EOF after length ' . strlen(
$data));
2914 $this->
debug(
"received before EOF:\n" .
$data);
2915 $this->
setError(
'server failed to send headers');
2919 $tmp = fgets($this->fp, 256);
2920 $tmplen = strlen($tmp);
2921 $this->
debug(
"read line of $tmplen bytes: " . trim($tmp));
2924 $this->incoming_payload =
$data;
2925 $this->
debug(
'socket read of headers timed out after length ' . strlen(
$data));
2926 $this->
debug(
"read before timeout: " .
$data);
2927 $this->
setError(
'socket read of headers timed out');
2942 if (isset($lb) && preg_match(
'/^HTTP\/1.1 100/',
$data)) {
2948 $this->incoming_payload .=
$data;
2949 $this->
debug(
'found end of headers after length ' . strlen(
$data));
2951 $header_data = trim(substr(
$data,0,
$pos));
2952 $header_array = explode($lb,$header_data);
2953 $this->incoming_headers = array();
2954 $this->incoming_cookies = array();
2955 foreach($header_array as $header_line){
2956 $arr = explode(
':',$header_line, 2);
2957 if(count($arr) > 1){
2958 $header_name = strtolower(trim($arr[0]));
2959 $this->incoming_headers[$header_name] = trim($arr[1]);
2960 if ($header_name ==
'set-cookie') {
2964 $this->incoming_cookies[] = $cookie;
2965 $this->
debug(
'found cookie: ' . $cookie[
'name'] .
' = ' . $cookie[
'value']);
2967 $this->
debug(
'did not find cookie in ' . trim($arr[1]));
2970 }
else if (isset($header_name)) {
2972 $this->incoming_headers[$header_name] .= $lb .
' ' . $header_line;
2977 if (isset($this->incoming_headers[
'transfer-encoding']) && strtolower($this->incoming_headers[
'transfer-encoding']) ==
'chunked') {
2978 $content_length = 2147483647;
2980 $this->
debug(
"want to read chunked content");
2981 } elseif (isset($this->incoming_headers[
'content-length'])) {
2982 $content_length = $this->incoming_headers[
'content-length'];
2984 $this->
debug(
"want to read content of length $content_length");
2986 $content_length = 2147483647;
2988 $this->
debug(
"want to read content to EOF");
2993 $tmp = fgets($this->fp, 256);
2994 $tmplen = strlen($tmp);
2995 $this->
debug(
"read chunk line of $tmplen bytes");
2997 $this->incoming_payload =
$data;
2998 $this->
debug(
'socket read of chunk length timed out after length ' . strlen(
$data));
2999 $this->
debug(
"read before timeout:\n" .
$data);
3000 $this->
setError(
'socket read of chunk length timed out');
3003 $content_length = hexdec(trim($tmp));
3004 $this->
debug(
"chunk length $content_length");
3007 while (($strlen < $content_length) && (!feof($this->fp))) {
3008 $readlen = min(8192, $content_length - $strlen);
3009 $tmp = fread($this->fp, $readlen);
3010 $tmplen = strlen($tmp);
3011 $this->
debug(
"read buffer of $tmplen bytes");
3012 if (($tmplen == 0) && (!feof($this->fp))) {
3013 $this->incoming_payload =
$data;
3014 $this->
debug(
'socket read of body timed out after length ' . strlen(
$data));
3015 $this->
debug(
"read before timeout:\n" .
$data);
3016 $this->
setError(
'socket read of body timed out');
3022 if ($chunked && ($content_length > 0)) {
3023 $tmp = fgets($this->fp, 256);
3024 $tmplen = strlen($tmp);
3025 $this->
debug(
"read chunk terminator of $tmplen bytes");
3027 $this->incoming_payload =
$data;
3028 $this->
debug(
'socket read of chunk terminator timed out after length ' . strlen(
$data));
3029 $this->
debug(
"read before timeout:\n" .
$data);
3030 $this->
setError(
'socket read of chunk terminator timed out');
3034 }
while ($chunked && ($content_length > 0) && (!feof($this->fp)));
3035 if (feof($this->fp)) {
3036 $this->
debug(
'read to EOF');
3038 $this->
debug(
'read body of length ' . strlen(
$data));
3039 $this->incoming_payload .=
$data;
3040 $this->
debug(
'received a total of '.strlen($this->incoming_payload).
' bytes of data from server');
3044 (isset($this->incoming_headers[
'connection']) && strtolower($this->incoming_headers[
'connection']) ==
'close') ||
3045 (! $this->persistentConnection) || feof($this->fp)){
3048 $this->
debug(
'closed socket');
3052 if($this->incoming_payload ==
''){
3053 $this->
setError(
'no response from server');
3068 }
else if ($this->
io_method() ==
'curl') {
3070 $this->
debug(
'send and receive with cURL');
3071 $this->incoming_payload = curl_exec($this->ch);
3074 $cErr = curl_error($this->ch);
3076 $err =
'cURL ERROR: '.curl_errno($this->ch).
': '.$cErr.
'<br>';
3078 foreach(curl_getinfo($this->ch) as $k => $v){
3079 $err .=
"$k: $v<br>";
3083 curl_close($this->ch);
3091 $this->
debug(
'No cURL error, closing cURL');
3092 curl_close($this->ch);
3097 $this->
debug(
"Found HTTP header to skip");
3100 } elseif(
$pos = strpos(
$data,
"\n\n") ) {
3108 while (preg_match(
'/^HTTP\/1.1 100/',
$data)) {
3111 } elseif(
$pos = strpos(
$data,
"\n\n") ) {
3120 } elseif(
$pos = strpos(
$data,
"\n\n")) {
3123 $this->
debug(
'no proper separation of headers and document');
3124 $this->
setError(
'no proper separation of headers and document');
3127 $header_data = trim(substr(
$data,0,
$pos));
3128 $header_array = explode($lb,$header_data);
3130 $this->
debug(
'found proper separation of headers and document');
3131 $this->
debug(
'cleaned data, stringlen: '.strlen(
$data));
3133 foreach ($header_array as $header_line) {
3134 $arr = explode(
':',$header_line,2);
3135 if(count($arr) > 1){
3136 $header_name = strtolower(trim($arr[0]));
3137 $this->incoming_headers[$header_name] = trim($arr[1]);
3138 if ($header_name ==
'set-cookie') {
3142 $this->incoming_cookies[] = $cookie;
3143 $this->
debug(
'found cookie: ' . $cookie[
'name'] .
' = ' . $cookie[
'value']);
3145 $this->
debug(
'did not find cookie in ' . trim($arr[1]));
3148 }
else if (isset($header_name)) {
3150 $this->incoming_headers[$header_name] .= $lb .
' ' . $header_line;
3155 $this->response_status_line = $header_array[0];
3156 $arr = explode(
' ', $this->response_status_line, 3);
3157 $http_version = $arr[0];
3158 $http_status = intval($arr[1]);
3159 $http_reason = count($arr) > 2 ? $arr[2] :
'';
3162 if (isset($this->incoming_headers[
'location']) && ($http_status == 301 || $http_status == 302)) {
3163 $this->
debug(
"Got $http_status $http_reason with Location: " . $this->incoming_headers[
'location']);
3164 $this->
setURL($this->incoming_headers[
'location']);
3165 $this->tryagain =
true;
3170 if (isset($this->incoming_headers[
'www-authenticate']) && $http_status == 401) {
3171 $this->
debug(
"Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers[
'www-authenticate']);
3172 if (strstr($this->incoming_headers[
'www-authenticate'],
"Digest ")) {
3173 $this->
debug(
'Server wants digest authentication');
3175 $digestString = str_replace(
'Digest ',
'', $this->incoming_headers[
'www-authenticate']);
3178 $digestElements = explode(
',', $digestString);
3179 foreach ($digestElements as $val) {
3180 $tempElement = explode(
'=', trim($val), 2);
3181 $digestRequest[$tempElement[0]] = str_replace(
"\"",
'', $tempElement[1]);
3187 $this->tryagain =
true;
3191 $this->
debug(
'HTTP authentication failed');
3192 $this->
setError(
'HTTP authentication failed');
3197 ($http_status >= 300 && $http_status <= 307) ||
3198 ($http_status >= 400 && $http_status <= 417) ||
3199 ($http_status >= 501 && $http_status <= 505)
3201 $this->
setError(
"Unsupported HTTP response status $http_status $http_reason (soapclient->response has contents of the response)");
3206 if(isset($this->incoming_headers[
'content-encoding']) && $this->incoming_headers[
'content-encoding'] !=
''){
3207 if(strtolower($this->incoming_headers[
'content-encoding']) ==
'deflate' || strtolower($this->incoming_headers[
'content-encoding']) ==
'gzip'){
3209 if(function_exists(
'gzinflate')){
3213 $this->
debug(
'The gzinflate function exists');
3214 $datalen = strlen(
$data);
3215 if ($this->incoming_headers[
'content-encoding'] ==
'deflate') {
3216 if ($degzdata = @gzinflate(
$data)) {
3218 $this->
debug(
'The payload has been inflated to ' . strlen(
$data) .
' bytes');
3219 if (strlen(
$data) < $datalen) {
3221 $this->
debug(
'The inflated payload is smaller than the gzipped one; try again');
3222 if ($degzdata = @gzinflate(
$data)) {
3224 $this->
debug(
'The payload has been inflated again to ' . strlen(
$data) .
' bytes');
3228 $this->
debug(
'Error using gzinflate to inflate the payload');
3229 $this->
setError(
'Error using gzinflate to inflate the payload');
3231 } elseif ($this->incoming_headers[
'content-encoding'] ==
'gzip') {
3232 if ($degzdata = @gzinflate(substr(
$data, 10))) {
3234 $this->
debug(
'The payload has been un-gzipped to ' . strlen(
$data) .
' bytes');
3235 if (strlen(
$data) < $datalen) {
3237 $this->
debug(
'The un-gzipped payload is smaller than the gzipped one; try again');
3238 if ($degzdata = @gzinflate(substr(
$data, 10))) {
3240 $this->
debug(
'The payload has been un-gzipped again to ' . strlen(
$data) .
' bytes');
3244 $this->
debug(
'Error using gzinflate to un-gzip the payload');
3245 $this->
setError(
'Error using gzinflate to un-gzip the payload');
3251 $this->incoming_payload = $header_data.$lb.$lb.$data;
3253 $this->
debug(
'The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
3254 $this->
setError(
'The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
3257 $this->
debug(
'Unsupported Content-Encoding ' . $this->incoming_headers[
'content-encoding']);
3258 $this->
setError(
'Unsupported Content-Encoding ' . $this->incoming_headers[
'content-encoding']);
3261 $this->
debug(
'No Content-Encoding header');
3264 if(strlen(
$data) == 0){
3265 $this->
debug(
'no data after headers!');
3266 $this->
setError(
'no data present after HTTP headers');
3281 $this->
setHeader(
'Content-Type',
$type . ($charset ?
'; charset=' . $charset :
''));
3291 if (isset($this->outgoing_headers[
'Accept-Encoding'])) {
3294 $this->protocol_version =
'1.1';
3295 $this->persistentConnection =
true;
3296 $this->
setHeader(
'Connection',
'Keep-Alive');
3311 $cookie_str = str_replace(
'; ',
';', $cookie_str) .
';';
3312 $data = split(
';', $cookie_str);
3313 $value_str =
$data[0];
3315 $cookie_param =
'domain=';
3316 $start = strpos($cookie_str, $cookie_param);
3318 $domain = substr($cookie_str, $start + strlen($cookie_param));
3319 $domain = substr($domain, 0, strpos($domain,
';'));
3324 $cookie_param =
'expires=';
3325 $start = strpos($cookie_str, $cookie_param);
3327 $expires = substr($cookie_str, $start + strlen($cookie_param));
3328 $expires = substr($expires, 0, strpos($expires,
';'));
3333 $cookie_param =
'path=';
3334 $start = strpos($cookie_str, $cookie_param);
3336 $path = substr($cookie_str, $start + strlen($cookie_param));
3342 $cookie_param =
';secure;';
3343 if (strpos($cookie_str, $cookie_param) !== FALSE) {
3349 $sep_pos = strpos($value_str,
'=');
3352 $name = substr($value_str, 0, $sep_pos);
3353 $value = substr($value_str, $sep_pos + 1);
3354 $cookie= array(
'name' =>
$name,
3356 'domain' => $domain,
3358 'expires' => $expires,
3376 if ((! is_null($cookies)) && (is_array($cookies))) {
3377 foreach ($cookies as $cookie) {
3378 if (! is_array($cookie)) {
3381 $this->
debug(
"check cookie for validity: ".$cookie[
'name'].
'='.$cookie[
'value']);
3382 if ((isset($cookie[
'expires'])) && (! empty($cookie[
'expires']))) {
3383 if (strtotime($cookie[
'expires']) <= time()) {
3384 $this->
debug(
'cookie has expired');
3388 if ((isset($cookie[
'domain'])) && (! empty($cookie[
'domain']))) {
3389 $domain = preg_quote($cookie[
'domain']);
3390 if (! preg_match(
"'.*$domain$'i", $this->host)) {
3391 $this->
debug(
'cookie has different domain');
3395 if ((isset($cookie[
'path'])) && (! empty($cookie[
'path']))) {
3396 $path = preg_quote($cookie[
'path']);
3397 if (! preg_match(
"'^$path.*'i", $this->path)) {
3398 $this->
debug(
'cookie is for a different path');
3402 if ((! $secure) && (isset($cookie[
'secure'])) && ($cookie[
'secure'])) {
3403 $this->
debug(
'cookie is secure, transport is not');
3406 $cookie_str .= $cookie[
'name'] .
'=' . $cookie[
'value'] .
'; ';
3407 $this->
debug(
'add cookie to Cookie-String: ' . $cookie[
'name'] .
'=' . $cookie[
'value']);
3589 global $HTTP_SERVER_VARS;
3591 if (isset($_SERVER)) {
3592 $this->
debug(
"_SERVER is defined:");
3594 } elseif (isset($HTTP_SERVER_VARS)) {
3595 $this->
debug(
"HTTP_SERVER_VARS is defined:");
3598 $this->
debug(
"Neither _SERVER nor HTTP_SERVER_VARS is defined.");
3601 if (isset($debug)) {
3602 $this->
debug(
"In nusoap_server, set debug_flag=$debug based on global flag");
3603 $this->debug_flag = $debug;
3604 } elseif (isset($_SERVER[
'QUERY_STRING'])) {
3605 $qs = explode(
'&', $_SERVER[
'QUERY_STRING']);
3606 foreach ($qs as $v) {
3607 if (substr($v, 0, 6) ==
'debug=') {
3608 $this->
debug(
"In nusoap_server, set debug_flag=" . substr($v, 6) .
" based on query string #1");
3609 $this->debug_flag = substr($v, 6);
3612 } elseif (isset($HTTP_SERVER_VARS[
'QUERY_STRING'])) {
3613 $qs = explode(
'&', $HTTP_SERVER_VARS[
'QUERY_STRING']);
3614 foreach ($qs as $v) {
3615 if (substr($v, 0, 6) ==
'debug=') {
3616 $this->
debug(
"In nusoap_server, set debug_flag=" . substr($v, 6) .
" based on query string #2");
3617 $this->debug_flag = substr($v, 6);
3624 $this->
debug(
"In nusoap_server, WSDL is specified");
3625 if (is_object(
$wsdl) && (get_class(
$wsdl) ==
'wsdl')) {
3627 $this->externalWSDLURL = $this->
wsdl->
wsdl;
3628 $this->
debug(
'Use existing wsdl instance from ' . $this->externalWSDLURL);
3632 $this->externalWSDLURL =
$wsdl;
3637 die(
'WSDL ERROR: '.$err);
3649 global $HTTP_SERVER_VARS;
3651 if (isset($_SERVER[
'QUERY_STRING'])) {
3652 $qs = $_SERVER[
'QUERY_STRING'];
3653 } elseif (isset($HTTP_SERVER_VARS[
'QUERY_STRING'])) {
3654 $qs = $HTTP_SERVER_VARS[
'QUERY_STRING'];
3658 $this->
debug(
"In service, query string=$qs");
3660 if (preg_match(
'/wsdl/', $qs) ){
3661 $this->
debug(
"In service, this is a request for WSDL");
3662 if($this->externalWSDLURL){
3663 if (strpos($this->externalWSDLURL,
"://")!==
false) {
3664 header(
'Location: '.$this->externalWSDLURL);
3666 header(
"Content-Type: text/xml\r\n");
3667 $fp = fopen($this->externalWSDLURL,
'r');
3670 } elseif ($this->
wsdl) {
3671 header(
"Content-Type: text/xml; charset=ISO-8859-1\r\n");
3673 if ($this->debug_flag) {
3674 $this->
debug(
'wsdl:');
3679 header(
"Content-Type: text/html; charset=ISO-8859-1\r\n");
3680 print
"This service does not provide WSDL";
3683 $this->
debug(
"In service, there is no data, so return Web description");
3686 $this->
debug(
"In service, invoke the request");
3688 if (! $this->
fault) {
3691 if (! $this->
fault) {
3711 global $HTTP_SERVER_VARS;
3713 $this->request =
'';
3714 $this->SOAPAction =
'';
3715 if(function_exists(
'getallheaders')){
3716 $this->
debug(
"In parse_http_headers, use getallheaders");
3719 $k = strtolower($k);
3720 $this->headers[$k] = $v;
3721 $this->request .=
"$k: $v\r\n";
3722 $this->
debug(
"$k: $v");
3725 if(isset($this->headers[
'soapaction'])){
3726 $this->SOAPAction = str_replace(
'"',
'',$this->headers[
'soapaction']);
3729 if(isset($this->headers[
'content-type']) && strpos($this->headers[
'content-type'],
'=')){
3730 $enc = str_replace(
'"',
'',substr(strstr($this->headers[
"content-type"],
'='),1));
3731 if(preg_match(
'/^(ISO-8859-1|US-ASCII|UTF-8)$/i',
$enc)){
3732 $this->xml_encoding = strtoupper(
$enc);
3734 $this->xml_encoding =
'US-ASCII';
3738 $this->xml_encoding =
'ISO-8859-1';
3740 } elseif(isset($_SERVER) && is_array($_SERVER)){
3741 $this->
debug(
"In parse_http_headers, use _SERVER");
3742 foreach ($_SERVER as $k => $v) {
3743 if (substr($k, 0, 5) ==
'HTTP_') {
3744 $k = str_replace(
' ',
'-', strtolower(str_replace(
'_',
' ', substr($k, 5))));
3746 $k = str_replace(
' ',
'-', strtolower(str_replace(
'_',
' ', $k)));
3748 if ($k ==
'soapaction') {
3751 $v = str_replace(
'"',
'', $v);
3752 $v = str_replace(
'\\',
'', $v);
3753 $this->SOAPAction = $v;
3754 }
else if ($k ==
'content-type') {
3756 if (strpos($v,
'=')) {
3757 $enc = substr(strstr($v,
'='), 1);
3759 $enc = str_replace(
'\\',
'',
$enc);
3760 if (preg_match(
'/^(ISO-8859-1|US-ASCII|UTF-8)$/i',
$enc)) {
3761 $this->xml_encoding = strtoupper(
$enc);
3763 $this->xml_encoding =
'US-ASCII';
3767 $this->xml_encoding =
'ISO-8859-1';
3770 $this->headers[$k] = $v;
3771 $this->request .=
"$k: $v\r\n";
3772 $this->
debug(
"$k: $v");
3774 } elseif (is_array($HTTP_SERVER_VARS)) {
3775 $this->
debug(
"In parse_http_headers, use HTTP_SERVER_VARS");
3776 foreach ($HTTP_SERVER_VARS as $k => $v) {
3777 if (substr($k, 0, 5) ==
'HTTP_') {
3778 $k = str_replace(
' ',
'-', strtolower(str_replace(
'_',
' ', substr($k, 5)))); $k = strtolower(substr($k, 5));
3780 $k = str_replace(
' ',
'-', strtolower(str_replace(
'_',
' ', $k))); $k = strtolower($k);
3782 if ($k ==
'soapaction') {
3785 $v = str_replace(
'"',
'', $v);
3786 $v = str_replace(
'\\',
'', $v);
3787 $this->SOAPAction = $v;
3788 }
else if ($k ==
'content-type') {
3790 if (strpos($v,
'=')) {
3791 $enc = substr(strstr($v,
'='), 1);
3793 $enc = str_replace(
'\\',
'',
$enc);
3794 if (preg_match(
'/^(ISO-8859-1|US-ASCII|UTF-8)$/i',
$enc)) {
3795 $this->xml_encoding = strtoupper(
$enc);
3797 $this->xml_encoding =
'US-ASCII';
3801 $this->xml_encoding =
'ISO-8859-1';
3804 $this->headers[$k] = $v;
3805 $this->request .=
"$k: $v\r\n";
3806 $this->
debug(
"$k: $v");
3809 $this->
debug(
"In parse_http_headers, HTTP headers not accessible");
3810 $this->
setError(
"HTTP headers not accessible");
3837 $this->
debug(
'entering parse_request()');
3839 $this->
debug(
'got character encoding: '.$this->xml_encoding);
3841 if (isset($this->headers[
'content-encoding']) && $this->headers[
'content-encoding'] !=
'') {
3842 $this->
debug(
'got content encoding: ' . $this->headers[
'content-encoding']);
3843 if ($this->headers[
'content-encoding'] ==
'deflate' || $this->headers[
'content-encoding'] ==
'gzip') {
3845 if (function_exists(
'gzuncompress')) {
3846 if ($this->headers[
'content-encoding'] ==
'deflate' && $degzdata = @gzuncompress(
$data)) {
3848 } elseif ($this->headers[
'content-encoding'] ==
'gzip' && $degzdata = gzinflate(substr(
$data, 10))) {
3851 $this->
fault(
'SOAP-ENV:Client',
'Errors occurred when trying to decode the data');
3855 $this->
fault(
'SOAP-ENV:Client',
'This Server does not support compressed data');
3860 $this->request .=
"\r\n".$data;
3862 $this->requestSOAP =
$data;
3863 $this->
debug(
'leaving parse_request');
3884 $this->
debug(
'in invoke_method, methodname=' . $this->methodname .
' methodURI=' . $this->methodURI .
' SOAPAction=' . $this->SOAPAction);
3888 $this->
debug(
'in invoke_method, found WSDL operation=' . $this->methodname);
3892 $this->
debug(
'in invoke_method, found WSDL soapAction=' . $this->SOAPAction .
' for operation=' . $this->opData[
'name']);
3894 $this->methodname = $this->opData[
'name'];
3896 $this->
debug(
'in invoke_method, no WSDL for operation=' . $this->methodname);
3897 $this->
fault(
'SOAP-ENV:Client',
"Operation '" . $this->methodname .
"' is not defined in the WSDL for this service");
3901 $this->
debug(
'in invoke_method, no WSDL to validate method');
3909 if (strpos($this->methodname,
'..') > 0) {
3911 }
else if (strpos($this->methodname,
'.') > 0) {
3917 if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1 &&
3918 class_exists(substr($this->methodname, 0, strpos($this->methodname, $delim)))) {
3920 $class = substr($this->methodname, 0, strpos($this->methodname, $delim));
3921 $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
3922 $this->
debug(
"in invoke_method, class=$class method=$method delim=$delim");
3926 if ($class ==
'' && $this->
class !=
'')
3928 $class = $this->class;
3935 if (!function_exists($this->methodname)) {
3936 $this->
debug(
"in invoke_method, function '$this->methodname' not found!");
3937 $this->result =
'fault: method not found';
3938 $this->
fault(
'SOAP-ENV:Client',
"method '$this->methodname' not defined in service");
3942 $method_to_compare = (substr(phpversion(), 0, 2) ==
'4.') ? strtolower($method) : $method;
3943 if (!in_array($method_to_compare, get_class_methods($class))) {
3944 $this->
debug(
"in invoke_method, method '$this->methodname' not found in class '$class'!");
3945 $this->result =
'fault: method not found';
3946 $this->
fault(
'SOAP-ENV:Client',
"method '$this->methodname' not defined in service");
3953 if(! $this->
verify_method($this->methodname,$this->methodparams)){
3955 $this->
debug(
'ERROR: request not verified against method signature');
3956 $this->result =
'fault: request failed validation against method signature';
3958 $this->
fault(
'SOAP-ENV:Client',
"Operation '$this->methodname' not defined in service.");
3963 $this->
debug(
'in invoke_method, params:');
3965 $this->
debug(
"in invoke_method, calling '$this->methodname'");
3966 if (!function_exists(
'call_user_func_array')) {
3968 $this->
debug(
'in invoke_method, calling function using eval()');
3969 $funcCall =
"\$this->methodreturn = $this->methodname(";
3971 if ($delim ==
'..') {
3972 $this->
debug(
'in invoke_method, calling class method using eval()');
3973 $funcCall =
"\$this->methodreturn = ".$class.
"::".$method.
"(";
3975 $this->
debug(
'in invoke_method, calling instance method using eval()');
3977 $instname =
"\$inst_".time();
3978 $funcCall = $instname.
" = new ".$class.
"(); ";
3979 $funcCall .=
"\$this->methodreturn = ".$instname.
"->".$method.
"(";
3982 if ($this->methodparams) {
3983 foreach ($this->methodparams as $param) {
3984 if (is_array($param) || is_object($param)) {
3985 $this->
fault(
'SOAP-ENV:Client',
'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available');
3988 $funcCall .=
"\"$param\",";
3990 $funcCall = substr($funcCall, 0, -1);
3993 $this->
debug(
'in invoke_method, function call: '.$funcCall);
3997 $this->
debug(
'in invoke_method, calling function using call_user_func_array()');
3998 $call_arg =
"$this->methodname";
3999 } elseif ($delim ==
'..') {
4000 $this->
debug(
'in invoke_method, calling class method using call_user_func_array()');
4001 $call_arg = array ($class, $method);
4003 $this->
debug(
'in invoke_method, calling instance method using call_user_func_array()');
4004 $instance =
new $class ();
4005 $call_arg = array(&$instance, $method);
4007 if (is_array($this->methodparams)) {
4008 $this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams));
4010 $this->methodreturn = call_user_func_array($call_arg, array());
4013 $this->
debug(
'in invoke_method, methodreturn:');
4015 $this->
debug(
"in invoke_method, called method $this->methodname, received data of type ".gettype($this->methodreturn));
4030 $this->
debug(
'Entering serialize_return methodname: ' . $this->methodname .
' methodURI: ' . $this->methodURI);
4032 if (isset($this->methodreturn) && ((get_class((
object)$this->methodreturn) ==
'soap_fault') || (get_class((
object)$this->methodreturn) ==
'nusoap_fault'))) {
4033 $this->
debug(
'got a fault object from method');
4036 } elseif ($this->methodreturnisliteralxml) {
4040 $this->
debug(
'got a(n) '.gettype($this->methodreturn).
' from method');
4041 $this->
debug(
'serializing return value');
4043 if (
sizeof($this->opData[
'output'][
'parts']) > 1) {
4044 $this->
debug(
'more than one output part, so use the method return unchanged');
4046 } elseif (
sizeof($this->opData[
'output'][
'parts']) == 1) {
4047 $this->
debug(
'exactly one output part, so wrap the method return in a simple array');
4052 $opParams = array($this->methodreturn);
4058 $this->
debug(
'got wsdl error: '.$errstr);
4059 $this->
fault(
'SOAP-ENV:Server',
'unable to serialize result');
4063 if (isset($this->methodreturn)) {
4064 $return_val = $this->
serialize_val($this->methodreturn,
'return');
4067 $this->
debug(
'in absence of WSDL, assume void return for backward compatibility');
4071 $this->
debug(
'return value:');
4074 $this->
debug(
'serializing response');
4076 $this->
debug(
'have WSDL for serialization: style is ' . $this->opData[
'style']);
4077 if ($this->opData[
'style'] ==
'rpc') {
4078 $this->
debug(
'style is rpc for serialization: use is ' . $this->opData[
'output'][
'use']);
4079 if ($this->opData[
'output'][
'use'] ==
'literal') {
4081 $payload =
'<ns1:'.$this->methodname.
'Response xmlns:ns1="'.$this->methodURI.
'">'.$return_val.
'</ns1:'.$this->methodname.
"Response>";
4083 $payload =
'<ns1:'.$this->methodname.
'Response xmlns:ns1="'.$this->methodURI.
'">'.$return_val.
'</ns1:'.$this->methodname.
"Response>";
4086 $this->
debug(
'style is not rpc for serialization: assume document');
4087 $payload = $return_val;
4090 $this->
debug(
'do not have WSDL for serialization: assume rpc/encoded');
4091 $payload =
'<ns1:'.$this->methodname.
'Response xmlns:ns1="'.$this->methodURI.
'">'.$return_val.
'</ns1:'.$this->methodname.
"Response>";
4093 $this->result =
'successful';
4098 if (isset($opData[
'output'][
'encodingStyle'])) {
4099 $encodingStyle = $opData[
'output'][
'encodingStyle'];
4101 $encodingStyle =
'';
4104 $this->responseSOAP = $this->
serializeEnvelope($payload,$this->responseHeaders,$this->
wsdl->usedNamespaces,$this->opData[
'style'],$this->opData[
'output'][
'use'],$encodingStyle);
4106 $this->responseSOAP = $this->
serializeEnvelope($payload,$this->responseHeaders);
4108 $this->
debug(
"Leaving serialize_return");
4122 $this->
debug(
'Enter send_response');
4124 $payload = $this->
fault->serialize();
4125 $this->outgoing_headers[] =
"HTTP/1.0 500 Internal Server Error";
4126 $this->outgoing_headers[] =
"Status: 500 Internal Server Error";
4136 if(isset($this->debug_flag) && $this->debug_flag){
4139 $this->outgoing_headers[] =
"Server: $this->title Server v$this->version";
4140 preg_match(
'/\$Revisio' .
'n: ([^ ]+)/', $this->revision, $rev);
4141 $this->outgoing_headers[] =
"X-SOAP-Server: $this->title/$this->version (".$rev[1].
")";
4147 $this->outgoing_headers[] =
"Content-Type: $type" . ($charset ?
'; charset=' . $charset :
'');
4151 if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers[
'accept-encoding'])) {
4152 if (strstr($this->headers[
'accept-encoding'],
'gzip')) {
4153 if (function_exists(
'gzencode')) {
4155 $payload .=
"<!-- Content being gzipped -->";
4157 $this->outgoing_headers[] =
"Content-Encoding: gzip";
4158 $payload = gzencode($payload);
4160 if (isset($this->debug_flag) && $this->debug_flag) {
4161 $payload .=
"<!-- Content will not be gzipped: no gzencode -->";
4164 } elseif (strstr($this->headers[
'accept-encoding'],
'deflate')) {
4168 if (function_exists(
'gzdeflate')) {
4169 if (isset($this->debug_flag) && $this->debug_flag) {
4170 $payload .=
"<!-- Content being deflated -->";
4172 $this->outgoing_headers[] =
"Content-Encoding: deflate";
4173 $payload = gzdeflate($payload);
4175 if (isset($this->debug_flag) && $this->debug_flag) {
4176 $payload .=
"<!-- Content will not be deflated: no gzcompress -->";
4182 $this->outgoing_headers[] =
"Content-Length: ".strlen($payload);
4183 reset($this->outgoing_headers);
4184 foreach($this->outgoing_headers as $hdr){
4185 header($hdr,
false);
4188 $this->response = join(
"\r\n",$this->outgoing_headers).
"\r\n\r\n".$payload;
4201 if(isset($this->
wsdl) && is_object($this->
wsdl)){
4205 } elseif(isset($this->operations[$operation])){
4220 $this->
debug(
'Entering parseRequest() for data of length ' . strlen(
$data) .
' and type ' .
$headers[
'content-type']);
4221 if (!strstr($headers[
'content-type'],
'text/xml')) {
4222 $this->
setError(
'Request not of type text/xml');
4225 if (strpos($headers[
'content-type'],
'=')) {
4226 $enc = str_replace(
'"',
'', substr(strstr($headers[
"content-type"],
'='), 1));
4227 $this->
debug(
'Got response encoding: ' .
$enc);
4228 if(preg_match(
'/^(ISO-8859-1|US-ASCII|UTF-8)$/i',
$enc)){
4229 $this->xml_encoding = strtoupper(
$enc);
4231 $this->xml_encoding =
'US-ASCII';
4235 $this->xml_encoding =
'ISO-8859-1';
4237 $this->
debug(
'Use encoding: ' . $this->xml_encoding .
' when creating nusoap_parser');
4241 $this->
debug(
"parser debug: \n".$parser->getDebug());
4243 if($err = $parser->getError()){
4244 $this->result =
'fault: error in msg parsing: '.$err;
4245 $this->
fault(
'SOAP-ENV:Client',
"error in msg parsing:\n".$err);
4249 $this->methodURI = $parser->root_struct_namespace;
4250 $this->methodname = $parser->root_struct_name;
4251 $this->
debug(
'methodname: '.$this->methodname.
' methodURI: '.$this->methodURI);
4252 $this->
debug(
'calling parser->get_soapbody()');
4253 $this->methodparams = $parser->get_soapbody();
4255 $this->requestHeaders = $parser->getHeaders();
4257 $this->requestHeader = $parser->get_soapheader();
4259 $this->document = $parser->document;
4326 function register(
$name,
$in=array(),
$out=array(),
$namespace=
false,$soapaction=
false,$style=
false,$use=
false,$documentation=
'',$encodingStyle=
''){
4327 global $HTTP_SERVER_VARS;
4329 if($this->externalWSDLURL){
4330 die(
'You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
4333 die(
'You must specify a name when you register an operation');
4335 if (!is_array(
$in)) {
4336 die(
'You must provide an array for operation inputs');
4338 if (!is_array(
$out)) {
4339 die(
'You must provide an array for operation outputs');
4343 if(
false == $soapaction) {
4344 if (isset($_SERVER)) {
4345 $SERVER_NAME = $_SERVER[
'SERVER_NAME'];
4346 $SCRIPT_NAME = isset($_SERVER[
'PHP_SELF']) ? $_SERVER[
'PHP_SELF'] : $_SERVER[
'SCRIPT_NAME'];
4347 $HTTPS = isset($_SERVER[
'HTTPS']) ? $_SERVER[
'HTTPS'] : (isset($HTTP_SERVER_VARS[
'HTTPS']) ? $HTTP_SERVER_VARS[
'HTTPS'] :
'off');
4348 } elseif (isset($HTTP_SERVER_VARS)) {
4349 $SERVER_NAME = $HTTP_SERVER_VARS[
'SERVER_NAME'];
4350 $SCRIPT_NAME = isset($HTTP_SERVER_VARS[
'PHP_SELF']) ? $HTTP_SERVER_VARS[
'PHP_SELF'] : $HTTP_SERVER_VARS[
'SCRIPT_NAME'];
4351 $HTTPS = isset($HTTP_SERVER_VARS[
'HTTPS']) ? $HTTP_SERVER_VARS[
'HTTPS'] :
'off';
4353 $this->
setError(
"Neither _SERVER nor HTTP_SERVER_VARS is available");
4355 if ($HTTPS ==
'1' || $HTTPS ==
'on') {
4360 $soapaction =
"$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name";
4362 if(
false == $style) {
4368 if ($use ==
'encoded' && $encodingStyle =
'') {
4369 $encodingStyle =
'http://schemas.xmlsoap.org/soap/encoding/';
4372 $this->operations[
$name] = array(
4377 'soapaction' => $soapaction,
4395 function fault($faultcode,$faultstring,$faultactor=
'',$faultdetail=
''){
4396 if ($faultdetail ==
'' && $this->debug_flag) {
4399 $this->
fault =
new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail);
4414 function configureWSDL($serviceName,
$namespace =
false,$endpoint =
false,$style=
'rpc', $transport =
'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace =
false)
4416 global $HTTP_SERVER_VARS;
4418 if (isset($_SERVER)) {
4419 $SERVER_NAME = $_SERVER[
'SERVER_NAME'];
4420 $SERVER_PORT = $_SERVER[
'SERVER_PORT'];
4421 $SCRIPT_NAME = isset($_SERVER[
'PHP_SELF']) ? $_SERVER[
'PHP_SELF'] : $_SERVER[
'SCRIPT_NAME'];
4422 $HTTPS = isset($_SERVER[
'HTTPS']) ? $_SERVER[
'HTTPS'] : (isset($HTTP_SERVER_VARS[
'HTTPS']) ? $HTTP_SERVER_VARS[
'HTTPS'] :
'off');
4423 } elseif (isset($HTTP_SERVER_VARS)) {
4424 $SERVER_NAME = $HTTP_SERVER_VARS[
'SERVER_NAME'];
4425 $SERVER_PORT = $HTTP_SERVER_VARS[
'SERVER_PORT'];
4426 $SCRIPT_NAME = isset($HTTP_SERVER_VARS[
'PHP_SELF']) ? $HTTP_SERVER_VARS[
'PHP_SELF'] : $HTTP_SERVER_VARS[
'SCRIPT_NAME'];
4427 $HTTPS = isset($HTTP_SERVER_VARS[
'HTTPS']) ? $HTTP_SERVER_VARS[
'HTTPS'] :
'off';
4429 $this->
setError(
"Neither _SERVER nor HTTP_SERVER_VARS is available");
4432 $colon = strpos($SERVER_NAME,
":");
4434 $SERVER_NAME = substr($SERVER_NAME, 0, $colon);
4436 if ($SERVER_PORT == 80) {
4439 $SERVER_PORT =
':' . $SERVER_PORT;
4442 $namespace =
"http://$SERVER_NAME/soap/$serviceName";
4445 if(
false == $endpoint) {
4446 if ($HTTPS ==
'1' || $HTTPS ==
'on') {
4451 $endpoint =
"$SCHEME://$SERVER_NAME$SERVER_PORT$SCRIPT_NAME";
4454 if(
false == $schemaTargetNamespace) {
4459 $this->
wsdl->serviceName = $serviceName;
4460 $this->
wsdl->endpoint = $endpoint;
4462 $this->
wsdl->namespaces[
'soap'] =
'http://schemas.xmlsoap.org/wsdl/soap/';
4463 $this->
wsdl->namespaces[
'wsdl'] =
'http://schemas.xmlsoap.org/wsdl/';
4465 $this->
wsdl->namespaces[
'types'] = $schemaTargetNamespace;
4468 if ($style ==
'document') {
4469 $this->
wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo[
'elementFormDefault'] =
'qualified';
4471 $this->
wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace;
4472 $this->
wsdl->schemas[$schemaTargetNamespace][0]->imports[
'http://schemas.xmlsoap.org/soap/encoding/'][0] = array(
'location' =>
'',
'loaded' =>
true);
4473 $this->
wsdl->schemas[$schemaTargetNamespace][0]->imports[
'http://schemas.xmlsoap.org/wsdl/'][0] = array(
'location' =>
'',
'loaded' =>
true);
4474 $this->
wsdl->bindings[$serviceName.
'Binding'] = array(
4475 'name'=>$serviceName.
'Binding',
4477 'transport'=>$transport,
4478 'portType'=>$serviceName.
'PortType');
4479 $this->
wsdl->ports[$serviceName.
'Port'] = array(
4480 'binding'=>$serviceName.
'Binding',
4481 'location'=>$endpoint,
4482 'bindingType'=>
'http://schemas.xmlsoap.org/wsdl/soap/');
4564 $this->
debug(
"ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
4583 $this->
debug(
"parse and process WSDL path=$wsdl");
4586 if ($this->
wsdl !=
"") {
4591 $imported_urls = array();
4593 while ($imported > 0) {
4596 foreach ($this->schemas as $ns => $list) {
4597 foreach ($list as $xs) {
4598 $wsdlparts = parse_url($this->
wsdl);
4599 foreach ($xs->imports as $ns2 => $list2) {
4600 for ($ii = 0; $ii < count($list2); $ii++) {
4601 if (! $list2[$ii][
'loaded']) {
4602 $this->schemas[$ns]->imports[$ns2][$ii][
'loaded'] =
true;
4603 $url = $list2[$ii][
'location'];
4605 $urlparts = parse_url($url);
4606 if (!isset($urlparts[
'host'])) {
4607 $url = $wsdlparts[
'scheme'] .
'://' . $wsdlparts[
'host'] . (isset($wsdlparts[
'port']) ?
':' .$wsdlparts[
'port'] :
'') .
4608 substr($wsdlparts[
'path'],0,strrpos($wsdlparts[
'path'],
'/') + 1) .$urlparts[
'path'];
4610 if (! in_array($url, $imported_urls)) {
4613 $imported_urls[] = $url;
4616 $this->
debug(
"Unexpected scenario: empty URL for unloaded import");
4624 $wsdlparts = parse_url($this->
wsdl);
4625 foreach ($this->
import as $ns => $list) {
4626 for ($ii = 0; $ii < count($list); $ii++) {
4627 if (! $list[$ii][
'loaded']) {
4628 $this->
import[$ns][$ii][
'loaded'] =
true;
4629 $url = $list[$ii][
'location'];
4631 $urlparts = parse_url($url);
4632 if (!isset($urlparts[
'host'])) {
4633 $url = $wsdlparts[
'scheme'] .
'://' . $wsdlparts[
'host'] . (isset($wsdlparts[
'port']) ?
':' . $wsdlparts[
'port'] :
'') .
4634 substr($wsdlparts[
'path'],0,strrpos($wsdlparts[
'path'],
'/') + 1) .$urlparts[
'path'];
4636 if (! in_array($url, $imported_urls)) {
4639 $imported_urls[] = $url;
4642 $this->
debug(
"Unexpected scenario: empty URL for unloaded import");
4649 foreach($this->bindings as $binding => $bindingData) {
4650 if (isset($bindingData[
'operations']) && is_array($bindingData[
'operations'])) {
4651 foreach($bindingData[
'operations'] as $operation =>
$data) {
4652 $this->
debug(
'post-parse data gathering for ' . $operation);
4653 $this->bindings[$binding][
'operations'][$operation][
'input'] =
4654 isset($this->bindings[$binding][
'operations'][$operation][
'input']) ?
4655 array_merge($this->bindings[$binding][
'operations'][$operation][
'input'], $this->portTypes[ $bindingData[
'portType'] ][$operation][
'input']) :
4656 $this->portTypes[ $bindingData[
'portType'] ][$operation][
'input'];
4657 $this->bindings[$binding][
'operations'][$operation][
'output'] =
4658 isset($this->bindings[$binding][
'operations'][$operation][
'output']) ?
4659 array_merge($this->bindings[$binding][
'operations'][$operation][
'output'], $this->portTypes[ $bindingData[
'portType'] ][$operation][
'output']) :
4660 $this->portTypes[ $bindingData[
'portType'] ][$operation][
'output'];
4661 if(isset($this->messages[ $this->bindings[$binding][
'operations'][$operation][
'input'][
'message'] ])){
4662 $this->bindings[$binding][
'operations'][$operation][
'input'][
'parts'] = $this->messages[ $this->bindings[$binding][
'operations'][$operation][
'input'][
'message'] ];
4664 if(isset($this->messages[ $this->bindings[$binding][
'operations'][$operation][
'output'][
'message'] ])){
4665 $this->bindings[$binding][
'operations'][$operation][
'output'][
'parts'] = $this->messages[ $this->bindings[$binding][
'operations'][$operation][
'output'][
'message'] ];
4668 if (isset($bindingData[
'style']) && !isset($this->bindings[$binding][
'operations'][$operation][
'style'])) {
4669 $this->bindings[$binding][
'operations'][$operation][
'style'] = $bindingData[
'style'];
4671 $this->bindings[$binding][
'operations'][$operation][
'transport'] = isset($bindingData[
'transport']) ? $bindingData[
'transport'] :
'';
4672 $this->bindings[$binding][
'operations'][$operation][
'documentation'] = isset($this->portTypes[ $bindingData[
'portType'] ][$operation][
'documentation']) ? $this->portTypes[ $bindingData[
'portType'] ][$operation][
'documentation'] :
'';
4673 $this->bindings[$binding][
'operations'][$operation][
'endpoint'] = isset($bindingData[
'endpoint']) ? $bindingData[
'endpoint'] :
'';
4686 $this->
debug(
"parse WSDL at path=$wsdl");
4689 $this->
debug(
'no wsdl passed to parseWSDL()!!');
4690 $this->
setError(
'no wsdl passed to parseWSDL()!!');
4695 $wsdl_props = parse_url(
$wsdl);
4697 if (isset($wsdl_props[
'scheme']) && ($wsdl_props[
'scheme'] ==
'http' || $wsdl_props[
'scheme'] ==
'https')) {
4698 $this->
debug(
'getting WSDL http(s) URL ' .
$wsdl);
4701 $tr->request_method =
'GET';
4702 $tr->useSOAPAction =
false;
4703 if($this->proxyhost && $this->proxyport){
4704 $tr->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
4706 if ($this->authtype !=
'') {
4707 $tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
4709 $tr->setEncoding(
'gzip, deflate');
4710 $wsdl_string = $tr->send(
'', $this->timeout, $this->response_timeout);
4715 if($err = $tr->getError() ){
4716 $errstr =
'HTTP ERROR: '.$err;
4717 $this->
debug($errstr);
4723 $this->
debug(
"got WSDL URL");
4726 if (isset($wsdl_props[
'scheme']) && ($wsdl_props[
'scheme'] ==
'file') && isset($wsdl_props[
'path'])) {
4727 $path = isset($wsdl_props[
'host']) ? ($wsdl_props[
'host'] .
':' . $wsdl_props[
'path']) : $wsdl_props[
'path'];
4732 if ($fp = @fopen(
$path,
'r')) {
4734 while (
$data = fread($fp, 32768)) {
4735 $wsdl_string .=
$data;
4739 $errstr =
"Bad path to WSDL file $path";
4740 $this->
debug($errstr);
4745 $this->
debug(
'Parse WSDL');
4748 $this->parser = xml_parser_create();
4751 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
4753 xml_set_object($this->parser, $this);
4755 xml_set_element_handler($this->parser,
'start_element',
'end_element');
4756 xml_set_character_data_handler($this->parser,
'character_data');
4758 if (!xml_parse($this->parser, $wsdl_string,
true)) {
4761 'XML error parsing WSDL from %s on line %d: %s',
4763 xml_get_current_line_number($this->parser),
4764 xml_error_string(xml_get_error_code($this->parser))
4766 $this->
debug($errstr);
4767 $this->
debug(
"XML payload:\n" . $wsdl_string);
4772 xml_parser_free($this->parser);
4773 $this->
debug(
'Parsing WSDL done');
4791 if ($this->status ==
'schema') {
4792 $this->currentSchema->schemaStartElement(
$parser,
$name, $attrs);
4793 $this->
appendDebug($this->currentSchema->getDebug());
4794 $this->currentSchema->clearDebug();
4795 } elseif (preg_match(
'/schema$/',
$name)) {
4796 $this->
debug(
'Parsing WSDL schema');
4798 $this->status =
'schema';
4800 $this->currentSchema->schemaStartElement(
$parser,
$name, $attrs);
4801 $this->
appendDebug($this->currentSchema->getDebug());
4802 $this->currentSchema->clearDebug();
4805 $pos = $this->position++;
4809 $this->message[
$pos] = array(
'cdata' =>
'');
4811 if (count($attrs) > 0) {
4813 foreach($attrs as $k => $v) {
4814 if (preg_match(
'/^xmlns/',$k)) {
4815 if ($ns_prefix = substr(strrchr($k,
':'), 1)) {
4816 $this->namespaces[$ns_prefix] = $v;
4818 $this->namespaces[
'ns' . (count($this->namespaces) + 1)] = $v;
4820 if ($v ==
'http://www.w3.org/2001/XMLSchema' || $v ==
'http://www.w3.org/1999/XMLSchema' || $v ==
'http://www.w3.org/2000/10/XMLSchema') {
4821 $this->XMLSchemaVersion = $v;
4822 $this->namespaces[
'xsi'] = $v .
'-instance';
4827 foreach($attrs as $k => $v) {
4828 $k = strpos($k,
':') ? $this->
expandQname($k) : $k;
4829 if ($k !=
'location' && $k !=
'soapAction' && $k !=
'namespace') {
4830 $v = strpos($v,
':') ? $this->
expandQname($v) : $v;
4839 if (preg_match(
'/:/',
$name)) {
4841 $prefix = substr(
$name, 0, strpos(
$name,
':'));
4843 $namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] :
'';
4849 switch ($this->status) {
4851 if (
$name ==
'part') {
4852 if (isset($attrs[
'type'])) {
4853 $this->
debug(
"msg " . $this->currentMessage .
": found part (with type) $attrs[name]: " . implode(
',', $attrs));
4856 if (isset($attrs[
'element'])) {
4857 $this->
debug(
"msg " . $this->currentMessage .
": found part (with element) $attrs[name]: " . implode(
',', $attrs));
4865 $this->currentPortOperation = $attrs[
'name'];
4866 $this->
debug(
"portType $this->currentPortType operation: $this->currentPortOperation");
4867 if (isset($attrs[
'parameterOrder'])) {
4871 case 'documentation':
4872 $this->documentation =
true;
4876 $m = isset($attrs[
'message']) ? $this->
getLocalPart($attrs[
'message']) :
'';
4885 if (isset($attrs[
'style'])) {
4888 $this->bindings[
$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs);
4894 if (isset($attrs[
'soapAction'])) {
4897 if (isset($attrs[
'style'])) {
4900 if (isset($attrs[
'name'])) {
4901 $this->currentOperation = $attrs[
'name'];
4902 $this->
debug(
"current binding operation: $this->currentOperation");
4909 $this->opStatus =
'input';
4912 $this->opStatus =
'output';
4915 if (isset($this->bindings[$this->currentBinding][
'operations'][$this->currentOperation][$this->opStatus])) {
4926 $this->currentPort = $attrs[
'name'];
4927 $this->
debug(
'current port: ' . $this->currentPort);
4935 $this->bindings[ $this->ports[
$this->currentPort][
'binding'] ][
'endpoint'] = $attrs[
'location'];
4943 if (isset($attrs[
'location'])) {
4944 $this->
import[$attrs[
'namespace']][] = array(
'location' => $attrs[
'location'],
'loaded' =>
false);
4945 $this->
debug(
'parsing import ' . $attrs[
'namespace'].
' - ' . $attrs[
'location'] .
' (' . count($this->
import[$attrs[
'namespace']]).
')');
4947 $this->
import[$attrs[
'namespace']][] = array(
'location' =>
'',
'loaded' =>
true);
4949 $this->namespaces[
'ns'.(count($this->namespaces)+1)] = $attrs[
'namespace'];
4951 $this->
debug(
'parsing import ' . $attrs[
'namespace'].
' - [no location] (' . count($this->
import[$attrs[
'namespace']]).
')');
4959 $this->status =
'message';
4960 $this->messages[$attrs[
'name']] = array();
4961 $this->currentMessage = $attrs[
'name'];
4964 $this->status =
'portType';
4965 $this->portTypes[$attrs[
'name']] = array();
4966 $this->currentPortType = $attrs[
'name'];
4969 if (isset($attrs[
'name'])) {
4971 if (strpos($attrs[
'name'],
':')) {
4972 $this->currentBinding = $this->
getLocalPart($attrs[
'name']);
4974 $this->currentBinding = $attrs[
'name'];
4976 $this->status =
'binding';
4978 $this->
debug(
"current binding: $this->currentBinding of portType: " . $attrs[
'type']);
4982 $this->serviceName = $attrs[
'name'];
4983 $this->status =
'service';
4984 $this->
debug(
'current service: ' . $this->serviceName);
4987 foreach ($attrs as
$name => $value) {
4988 $this->wsdl_info[
$name] = $value;
5004 if ( preg_match(
'/schema$/',
$name)) {
5006 $this->
appendDebug($this->currentSchema->getDebug());
5007 $this->currentSchema->clearDebug();
5009 $this->
debug(
'Parsing WSDL schema done');
5011 if ($this->status ==
'schema') {
5012 $this->currentSchema->schemaEndElement(
$parser,
$name);
5018 if ($this->documentation) {
5021 $this->documentation =
false;
5034 $pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[
$this->depth] : 0;
5035 if (isset($this->message[
$pos][
'cdata'])) {
5038 if ($this->documentation) {
5039 $this->documentation .=
$data;
5053 $this->
debug(
"setCredentials username=$username authtype=$authtype certRequest=");
5063 if (is_array($this->bindings[$binding])) {
5064 return $this->bindings[$binding];
5077 if ($bindingType ==
'soap') {
5078 $bindingType =
'http://schemas.xmlsoap.org/wsdl/soap/';
5079 } elseif ($bindingType ==
'soap12') {
5080 $bindingType =
'http://schemas.xmlsoap.org/wsdl/soap12/';
5083 foreach($this->ports as $port => $portData) {
5085 if ($portData[
'bindingType'] == $bindingType) {
5090 if (isset($this->bindings[ $portData[
'binding'] ][
'operations'])) {
5091 $ops = array_merge ($ops, $this->bindings[ $portData[
'binding'] ][
'operations']);
5108 if ($bindingType ==
'soap') {
5109 $bindingType =
'http://schemas.xmlsoap.org/wsdl/soap/';
5110 } elseif ($bindingType ==
'soap12') {
5111 $bindingType =
'http://schemas.xmlsoap.org/wsdl/soap12/';
5114 foreach($this->ports as $port => $portData) {
5116 if ($portData[
'bindingType'] == $bindingType) {
5119 foreach(array_keys($this->bindings[ $portData[
'binding'] ][
'operations']) as $bOperation) {
5121 if ($operation == $bOperation) {
5122 $opData = $this->bindings[ $portData[
'binding'] ][
'operations'][$operation];
5139 if ($bindingType ==
'soap') {
5140 $bindingType =
'http://schemas.xmlsoap.org/wsdl/soap/';
5141 } elseif ($bindingType ==
'soap12') {
5142 $bindingType =
'http://schemas.xmlsoap.org/wsdl/soap12/';
5145 foreach($this->ports as $port => $portData) {
5147 if ($portData[
'bindingType'] == $bindingType) {
5149 foreach ($this->bindings[ $portData[
'binding'] ][
'operations'] as $bOperation =>
$opData) {
5150 if (
$opData[
'soapAction'] == $soapAction) {
5177 $this->
debug(
"in getTypeDef: type=$type, ns=$ns");
5178 if ((! $ns) && isset($this->namespaces[
'tns'])) {
5179 $ns = $this->namespaces[
'tns'];
5180 $this->
debug(
"in getTypeDef: type namespace forced to $ns");
5182 if (!isset($this->schemas[$ns])) {
5183 foreach ($this->schemas as $ns0 => $schema0) {
5184 if (strcasecmp($ns, $ns0) == 0) {
5185 $this->
debug(
"in getTypeDef: replacing schema namespace $ns with $ns0");
5191 if (isset($this->schemas[$ns])) {
5192 $this->
debug(
"in getTypeDef: have schema for namespace $ns");
5193 for ($i = 0; $i < count($this->schemas[$ns]); $i++) {
5194 $xs = &$this->schemas[$ns][$i];
5199 if (!isset(
$t[
'phpType'])) {
5201 $uqType = substr(
$t[
'type'], strrpos(
$t[
'type'],
':') + 1);
5202 $ns = substr(
$t[
'type'], 0, strrpos(
$t[
'type'],
':'));
5205 $this->
debug(
"found type for [element] $type:");
5207 if (isset($etype[
'phpType'])) {
5208 $t[
'phpType'] = $etype[
'phpType'];
5210 if (isset($etype[
'elements'])) {
5211 $t[
'elements'] = $etype[
'elements'];
5213 if (isset($etype[
'attrs'])) {
5214 $t[
'attrs'] = $etype[
'attrs'];
5222 $this->
debug(
"in getTypeDef: do not have schema for namespace $ns");
5233 global $HTTP_SERVER_VARS;
5235 if (isset($_SERVER)) {
5236 $PHP_SELF = $_SERVER[
'PHP_SELF'];
5237 } elseif (isset($HTTP_SERVER_VARS)) {
5238 $PHP_SELF = $HTTP_SERVER_VARS[
'PHP_SELF'];
5240 $this->
setError(
"Neither _SERVER nor HTTP_SERVER_VARS is available");
5244 <html><head><title>NuSOAP: '.$this->serviceName.
'</title>
5245 <style type="text/css">
5246 body { font-family: arial; color: #000000; background-color: #ffffff; margin: 0px 0px 0px 0px; }
5247 p { font-family: arial; color: #000000; margin-top: 0px; margin-bottom: 12px; }
5248 pre { background-color: silver; padding: 5px; font-family: Courier New; font-size: x-small; color: #000000;}
5249 ul { margin-top: 10px; margin-left: 20px; }
5250 li { list-style-type: none; margin-top: 10px; color: #000000; }
5252 margin-left: 0px; padding-bottom: 2em; }
5254 padding-top: 10px; padding-bottom: 10px; padding-left: 15px; font-size: .70em;
5255 margin-top: 10px; margin-left: 0px; color: #000000;
5256 background-color: #ccccff; width: 20%; margin-left: 20px; margin-top: 20px; }
5258 font-family: arial; font-size: 26px; color: #ffffff;
5259 background-color: #999999; width: 105%; margin-left: 0px;
5260 padding-top: 10px; padding-bottom: 10px; padding-left: 15px;}
5262 position: absolute; visibility: hidden; z-index: 200; left: 250px; top: 100px;
5263 font-family: arial; overflow: hidden; width: 600;
5264 padding: 20px; font-size: 10px; background-color: #999999;
5265 layer-background-color:#FFFFFF; }
5266 a,a:active { color: charcoal; font-weight: bold; }
5267 a:visited { color: #666666; font-weight: bold; }
5268 a:hover { color: cc3300; font-weight: bold; }
5270 <script language="JavaScript" type="text/javascript">
5272 // POP-UP CAPTIONS...
5273 function lib_bwcheck(){ //Browsercheck (needed)
5274 this.ver=navigator.appVersion
5275 this.agent=navigator.userAgent
5276 this.dom=document.getElementById?1:0
5277 this.opera5=this.agent.indexOf("Opera 5")>-1
5278 this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
5279 this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
5280 this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
5281 this.ie=this.ie4||this.ie5||this.ie6
5282 this.mac=this.agent.indexOf("Mac")>-1
5283 this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
5284 this.ns4=(document.layers && !this.dom)?1:0;
5285 this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
5288 var bw = new lib_bwcheck()
5289 //Makes crossbrowser object.
5290 function makeObj(obj){
5291 this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?document.layers[obj]:0;
5292 if(!this.evnt) return false
5293 this.css=bw.dom||bw.ie4?this.evnt.style:bw.ns4?this.evnt:0;
5294 this.wref=bw.dom||bw.ie4?this.evnt:bw.ns4?this.css.document:0;
5295 this.writeIt=b_writeIt;
5298 // A unit of measure that will be added when setting the position of a layer.
5299 //var px = bw.ns4||window.opera?"":"px";
5300 function b_writeIt(text){
5301 if (bw.ns4){this.wref.write(text);this.wref.close()}
5302 else this.wref.innerHTML = text
5304 //Shows the messages
5306 function popup(divid){
5307 if(oDesc = new makeObj(divid)){
5308 oDesc.css.visibility = "visible"
5311 function popout(){ // Hides message
5312 if(oDesc) oDesc.css.visibility = "hidden"
5320 <div class=title>'.$this->serviceName.
'</div>
5322 <p>View the <a href="'.$PHP_SELF.
'?wsdl">WSDL</a> for the service.
5323 Click on an operation name to view it's details.</p>
5326 $b .=
"<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>";
5328 $b .=
"<div id='$op' class='hidden'>
5329 <a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>";
5330 foreach(
$data as $donnie => $marie){
5331 if($donnie ==
'input' || $donnie ==
'output'){
5332 $b .=
"<font color='white'>".ucfirst($donnie).
':</font><br>';
5333 foreach($marie as $captain => $tenille){
5334 if($captain ==
'parts'){
5335 $b .=
" $captain:<br>";
5337 foreach($tenille as $joanie => $chachi){
5338 $b .=
" $joanie: $chachi<br>";
5342 $b .=
" $captain: $tenille<br>";
5346 $b .=
"<font color='white'>".ucfirst($donnie).
":</font> $marie<br>";
5354 </div></body></html>';
5367 $xml =
'<?xml version="1.0" encoding="ISO-8859-1"?>';
5368 $xml .=
"\n<definitions";
5369 foreach($this->namespaces as $k => $v) {
5370 $xml .=
" xmlns:$k=\"$v\"";
5373 if (isset($this->namespaces[
'wsdl'])) {
5374 $xml .=
" xmlns=\"" . $this->namespaces[
'wsdl'] .
"\"";
5376 if (isset($this->namespaces[
'tns'])) {
5377 $xml .=
" targetNamespace=\"" . $this->namespaces[
'tns'] .
"\"";
5381 if (
sizeof($this->
import) > 0) {
5382 foreach($this->
import as $ns => $list) {
5383 foreach ($list as $ii) {
5384 if ($ii[
'location'] !=
'') {
5385 $xml .=
'<import location="' . $ii[
'location'] .
'" namespace="' . $ns .
'" />';
5387 $xml .=
'<import namespace="' . $ns .
'" />';
5393 if (count($this->schemas)>=1) {
5394 $xml .=
"\n<types>\n";
5395 foreach ($this->schemas as $ns => $list) {
5396 foreach ($list as $xs) {
5397 $xml .= $xs->serializeSchema();
5403 if (count($this->messages) >= 1) {
5404 foreach($this->messages as $msgName => $msgParts) {
5405 $xml .=
"\n<message name=\"" . $msgName .
'">';
5406 if(is_array($msgParts)){
5407 foreach($msgParts as $partName => $partType) {
5409 if (strpos($partType,
':')) {
5411 } elseif (isset($this->typemap[$this->namespaces[
'xsd']][$partType])) {
5413 $typePrefix =
'xsd';
5415 foreach($this->typemap as $ns => $types) {
5416 if (isset($types[$partType])) {
5420 if (!isset($typePrefix)) {
5421 die(
"$partType has no namespace!");
5426 $typeDef = $this->
getTypeDef($localPart, $ns);
5427 if ($typeDef[
'typeClass'] ==
'element') {
5428 $elementortype =
'element';
5429 if (substr($localPart, -1) ==
'^') {
5430 $localPart = substr($localPart, 0, -1);
5433 $elementortype =
'type';
5435 $xml .=
"\n" .
' <part name="' . $partName .
'" ' . $elementortype .
'="' . $typePrefix .
':' . $localPart .
'" />';
5438 $xml .=
'</message>';
5442 if (count($this->bindings) >= 1) {
5445 foreach($this->bindings as $bindingName => $attrs) {
5446 $binding_xml .=
"\n<binding name=\"" . $bindingName .
'" type="tns:' . $attrs[
'portType'] .
'">';
5447 $binding_xml .=
"\n" .
' <soap:binding style="' . $attrs[
'style'] .
'" transport="' . $attrs[
'transport'] .
'"/>';
5448 $portType_xml .=
"\n<portType name=\"" . $attrs[
'portType'] .
'">';
5449 foreach($attrs[
'operations'] as $opName => $opParts) {
5450 $binding_xml .=
"\n" .
' <operation name="' . $opName .
'">';
5451 $binding_xml .=
"\n" .
' <soap:operation soapAction="' . $opParts[
'soapAction'] .
'" style="'. $opParts[
'style'] .
'"/>';
5452 if (isset($opParts[
'input'][
'encodingStyle']) && $opParts[
'input'][
'encodingStyle'] !=
'') {
5453 $enc_style =
' encodingStyle="' . $opParts[
'input'][
'encodingStyle'] .
'"';
5457 $binding_xml .=
"\n" .
' <input><soap:body use="' . $opParts[
'input'][
'use'] .
'" namespace="' . $opParts[
'input'][
'namespace'] .
'"' . $enc_style .
'/></input>';
5458 if (isset($opParts[
'output'][
'encodingStyle']) && $opParts[
'output'][
'encodingStyle'] !=
'') {
5459 $enc_style =
' encodingStyle="' . $opParts[
'output'][
'encodingStyle'] .
'"';
5463 $binding_xml .=
"\n" .
' <output><soap:body use="' . $opParts[
'output'][
'use'] .
'" namespace="' . $opParts[
'output'][
'namespace'] .
'"' . $enc_style .
'/></output>';
5464 $binding_xml .=
"\n" .
' </operation>';
5465 $portType_xml .=
"\n" .
' <operation name="' . $opParts[
'name'] .
'"';
5466 if (isset($opParts[
'parameterOrder'])) {
5467 $portType_xml .=
' parameterOrder="' . $opParts[
'parameterOrder'] .
'"';
5469 $portType_xml .=
'>';
5470 if(isset($opParts[
'documentation']) && $opParts[
'documentation'] !=
'') {
5471 $portType_xml .=
"\n" .
' <documentation>' . htmlspecialchars($opParts[
'documentation']) .
'</documentation>';
5473 $portType_xml .=
"\n" .
' <input message="tns:' . $opParts[
'input'][
'message'] .
'"/>';
5474 $portType_xml .=
"\n" .
' <output message="tns:' . $opParts[
'output'][
'message'] .
'"/>';
5475 $portType_xml .=
"\n" .
' </operation>';
5477 $portType_xml .=
"\n" .
'</portType>';
5478 $binding_xml .=
"\n" .
'</binding>';
5480 $xml .= $portType_xml . $binding_xml;
5483 $xml .=
"\n<service name=\"" . $this->serviceName .
'">';
5484 if (count($this->ports) >= 1) {
5485 foreach($this->ports as $pName => $attrs) {
5486 $xml .=
"\n" .
' <port name="' . $pName .
'" binding="tns:' . $attrs[
'binding'] .
'">';
5487 $xml .=
"\n" .
' <soap:address location="' . $attrs[
'location'] . ($debug ?
'?debug=1' :
'') .
'"/>';
5488 $xml .=
"\n" .
' </port>';
5491 $xml .=
"\n" .
'</service>';
5492 return $xml .
"\n</definitions>";
5505 $this->
debug(
"in parametersMatchWrapped type=$type, parameters=");
5509 if (strpos(
$type,
':')) {
5510 $uqType = substr(
$type, strrpos(
$type,
':') + 1);
5512 $this->
debug(
"in parametersMatchWrapped: got a prefixed type: $uqType, $ns");
5515 $this->
debug(
"in parametersMatchWrapped: expanded prefixed type: $uqType, $ns");
5520 $this->
debug(
"in parametersMatchWrapped: No namespace for type $type");
5526 if (!$typeDef = $this->
getTypeDef($uqType, $ns)) {
5527 $this->
debug(
"in parametersMatchWrapped: $type ($uqType) is not a supported type.");
5530 $this->
debug(
"in parametersMatchWrapped: found typeDef=");
5532 if (substr($uqType, -1) ==
'^') {
5533 $uqType = substr($uqType, 0, -1);
5535 $phpType = $typeDef[
'phpType'];
5536 $arrayType = (isset($typeDef[
'arrayType']) ? $typeDef[
'arrayType'] :
'');
5537 $this->
debug(
"in parametersMatchWrapped: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: $arrayType");
5540 if ($phpType !=
'struct') {
5541 $this->
debug(
"in parametersMatchWrapped: not a struct");
5546 if (isset($typeDef[
'elements']) && is_array($typeDef[
'elements'])) {
5550 if ($this->
isArraySimpleOrStruct($parameters) ==
'arraySimple' && count($parameters) == count($typeDef[
'elements'])) {
5551 $this->
debug(
"in parametersMatchWrapped: (wrapped return value kludge) correct number of elements in simple array, so change array and wrap");
5554 foreach ($typeDef[
'elements'] as
$name => $attrs) {
5556 $this->
debug(
"in parametersMatchWrapped: change parameter $element to name $name");
5557 $parameters[
$name] = $parameters[$elements];
5558 unset($parameters[$elements]);
5560 } elseif (isset($parameters[
$name])) {
5561 $this->
debug(
"in parametersMatchWrapped: have parameter named $name");
5564 $this->
debug(
"in parametersMatchWrapped: do not have parameter named $name");
5569 $this->
debug(
"in parametersMatchWrapped: $matches parameter names match $elements wrapped parameter names");
5570 if ($matches == 0) {
5578 $this->
debug(
"in parametersMatchWrapped: no elements type $ns:$uqType");
5579 return count($parameters) == 0;
5598 $this->
debug(
"in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType");
5601 if ($direction !=
'input' && $direction !=
'output') {
5602 $this->
debug(
'The value of the \$direction argument needs to be either "input" or "output"');
5603 $this->
setError(
'The value of the \$direction argument needs to be either "input" or "output"');
5607 $this->
debug(
'Unable to retrieve WSDL data for operation: ' . $operation .
' bindingType: ' . $bindingType);
5608 $this->
setError(
'Unable to retrieve WSDL data for operation: ' . $operation .
' bindingType: ' . $bindingType);
5611 $this->
debug(
'in serializeRPCParameters: opData:');
5615 $encodingStyle =
'http://schemas.xmlsoap.org/soap/encoding/';
5616 if(($direction ==
'input') && isset(
$opData[
'output'][
'encodingStyle']) && (
$opData[
'output'][
'encodingStyle'] != $encodingStyle)) {
5617 $encodingStyle =
$opData[
'output'][
'encodingStyle'];
5618 $enc_style = $encodingStyle;
5623 if (isset(
$opData[$direction][
'parts']) &&
sizeof(
$opData[$direction][
'parts']) > 0) {
5624 $parts = &
$opData[$direction][
'parts'];
5625 $part_count =
sizeof($parts);
5627 $use =
$opData[$direction][
'use'];
5628 $this->
debug(
"have $part_count part(s) to serialize using $style/$use");
5629 if (is_array($parameters)) {
5631 $parameter_count = count($parameters);
5632 $this->
debug(
"have $parameter_count parameter(s) provided as $parametersArrayType to serialize");
5634 if ($style ==
'document' && $use ==
'literal' && $part_count == 1 && isset($parts[
'parameters'])) {
5635 $this->
debug(
'check whether the caller has wrapped the parameters');
5636 if ((($parametersArrayType ==
'arrayStruct' || $parameter_count == 0) && !isset($parameters[
'parameters'])) || ($direction ==
'output' && $parametersArrayType ==
'arraySimple' && $parameter_count == 1)) {
5637 $this->
debug(
'check whether caller\'s parameters match the wrapped ones');
5639 $this->
debug(
'wrap the parameters for the caller');
5640 $parameters = array(
'parameters' => $parameters);
5641 $parameter_count = 1;
5646 $this->
debug(
"serializing part $name of type $type");
5648 if (isset(
$opData[$direction][
'encodingStyle']) && $encodingStyle !=
$opData[$direction][
'encodingStyle']) {
5649 $encodingStyle =
$opData[$direction][
'encodingStyle'];
5650 $enc_style = $encodingStyle;
5656 if ($parametersArrayType ==
'arraySimple') {
5657 $p = array_shift($parameters);
5658 $this->
debug(
'calling serializeType w/indexed param');
5660 } elseif (isset($parameters[
$name])) {
5661 $this->
debug(
'calling serializeType w/named param');
5665 $this->
debug(
'calling serializeType w/null param');
5670 $this->
debug(
'no parameters passed.');
5673 $this->
debug(
"serializeRPCParameters returning: $xml");
5693 $this->
debug(
"in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
5696 if ($direction !=
'input' && $direction !=
'output') {
5697 $this->
debug(
'The value of the \$direction argument needs to be either "input" or "output"');
5698 $this->
setError(
'The value of the \$direction argument needs to be either "input" or "output"');
5702 $this->
debug(
'Unable to retrieve WSDL data for operation: ' . $operation);
5703 $this->
setError(
'Unable to retrieve WSDL data for operation: ' . $operation);
5706 $this->
debug(
'opData:');
5710 $encodingStyle =
'http://schemas.xmlsoap.org/soap/encoding/';
5711 if(($direction ==
'input') && isset(
$opData[
'output'][
'encodingStyle']) && (
$opData[
'output'][
'encodingStyle'] != $encodingStyle)) {
5712 $encodingStyle =
$opData[
'output'][
'encodingStyle'];
5713 $enc_style = $encodingStyle;
5718 if (isset(
$opData[$direction][
'parts']) &&
sizeof(
$opData[$direction][
'parts']) > 0) {
5720 $use =
$opData[$direction][
'use'];
5721 $this->
debug(
"use=$use");
5722 $this->
debug(
'got ' . count(
$opData[$direction][
'parts']) .
' part(s)');
5723 if (is_array($parameters)) {
5725 $this->
debug(
'have ' . $parametersArrayType .
' parameters');
5729 if(isset(
$opData[$direction][
'encodingStyle']) && $encodingStyle !=
$opData[$direction][
'encodingStyle']) {
5730 $encodingStyle =
$opData[$direction][
'encodingStyle'];
5731 $enc_style = $encodingStyle;
5737 if ($parametersArrayType ==
'arraySimple') {
5738 $p = array_shift($parameters);
5739 $this->
debug(
'calling serializeType w/indexed param');
5741 } elseif (isset($parameters[
$name])) {
5742 $this->
debug(
'calling serializeType w/named param');
5746 $this->
debug(
'calling serializeType w/null param');
5751 $this->
debug(
'no parameters passed.');
5754 $this->
debug(
"serializeParameters returning: $xml");
5772 $this->
debug(
"in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ?
"unqualified" :
"qualified"));
5774 if($use ==
'encoded' && $encodingStyle) {
5775 $encodingStyle =
' SOAP-ENV:encodingStyle="' . $encodingStyle .
'"';
5779 if (is_object($value) && get_class($value) ==
'soapval') {
5780 if ($value->type_ns) {
5781 $type = $value->type_ns .
':' . $value->type;
5783 $this->
debug(
"in serializeType: soapval overrides type to $type");
5784 } elseif ($value->type) {
5785 $type = $value->type;
5787 $this->
debug(
"in serializeType: soapval overrides type to $type");
5790 $this->
debug(
"in serializeType: soapval does not override type");
5792 $attrs = $value->attributes;
5793 $value = $value->value;
5794 $this->
debug(
"in serializeType: soapval overrides value to $value");
5796 if (!is_array($value)) {
5797 $value[
'!'] = $value;
5799 foreach ($attrs as $n => $v) {
5800 $value[
'!' . $n] = $v;
5802 $this->
debug(
"in serializeType: soapval provides attributes");
5809 if (strpos(
$type,
':')) {
5810 $uqType = substr(
$type, strrpos(
$type,
':') + 1);
5812 $this->
debug(
"in serializeType: got a prefixed type: $uqType, $ns");
5815 $this->
debug(
"in serializeType: expanded prefixed type: $uqType, $ns");
5818 if($ns == $this->XMLSchemaVersion || $ns ==
'http://schemas.xmlsoap.org/soap/encoding/'){
5819 $this->
debug(
'in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
5820 if ($unqualified && $use ==
'literal') {
5821 $elementNS =
" xmlns=\"\"";
5825 if (is_null($value)) {
5826 if ($use ==
'literal') {
5828 $xml =
"<$name$elementNS/>";
5831 $xml =
"<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->
getPrefixFromNamespace($ns) .
":$uqType\"/>";
5833 $this->
debug(
"in serializeType: returning: $xml");
5836 if ($uqType ==
'Array') {
5840 if ($uqType ==
'boolean') {
5841 if ((is_string($value) && $value ==
'false') || (! $value)) {
5847 if ($uqType ==
'string' && gettype($value) ==
'string') {
5850 if (($uqType ==
'long' || $uqType ==
'unsignedLong') && gettype($value) ==
'double') {
5851 $value = sprintf(
"%.0lf", $value);
5857 if ($use ==
'literal') {
5859 $xml =
"<$name$elementNS xsi:type=\"" . $this->
getPrefixFromNamespace($ns) .
":$uqType\">$value</$name>";
5861 $xml =
"<$name$elementNS>$value</$name>";
5864 $xml =
"<$name$elementNS xsi:type=\"" . $this->
getPrefixFromNamespace($ns) .
":$uqType\"$encodingStyle>$value</$name>";
5866 $this->
debug(
"in serializeType: returning: $xml");
5869 $this->
debug(
'custom type extends XML Schema or SOAP Encoding namespace (yuck)');
5870 }
else if ($ns ==
'http://xml.apache.org/xml-soap') {
5871 $this->
debug(
'in serializeType: appears to be Apache SOAP type');
5872 if ($uqType ==
'Map') {
5875 $this->
debug(
'in serializeType: Add namespace for Apache SOAP type');
5876 $tt_prefix =
'ns' . rand(1000, 9999);
5877 $this->namespaces[$tt_prefix] =
'http://xml.apache.org/xml-soap';
5882 foreach($value as $k => $v) {
5883 $this->
debug(
"serializing map element: key $k, value $v");
5884 $contents .=
'<item>';
5885 $contents .= $this->
serialize_val($k,
'key',
false,
false,
false,
false,$use);
5886 $contents .= $this->
serialize_val($v,
'value',
false,
false,
false,
false,$use);
5887 $contents .=
'</item>';
5889 if ($use ==
'literal') {
5891 $xml =
"<$name xsi:type=\"" . $tt_prefix .
":$uqType\">$contents</$name>";
5893 $xml =
"<$name>$contents</$name>";
5896 $xml =
"<$name xsi:type=\"" . $tt_prefix .
":$uqType\"$encodingStyle>$contents</$name>";
5898 $this->
debug(
"in serializeType: returning: $xml");
5901 $this->
debug(
'in serializeType: Apache SOAP type, but only support Map');
5906 $this->
debug(
"in serializeType: No namespace for type $type");
5910 if(!$typeDef = $this->
getTypeDef($uqType, $ns)){
5911 $this->
setError(
"$type ($uqType) is not a supported type.");
5912 $this->
debug(
"in serializeType: $type ($uqType) is not a supported type.");
5915 $this->
debug(
"in serializeType: found typeDef");
5917 if (substr($uqType, -1) ==
'^') {
5918 $uqType = substr($uqType, 0, -1);
5921 $phpType = $typeDef[
'phpType'];
5922 $this->
debug(
"in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef[
'arrayType']) ? $typeDef[
'arrayType'] :
'') );
5924 if ($phpType ==
'struct') {
5925 if (isset($typeDef[
'typeClass']) && $typeDef[
'typeClass'] ==
'element') {
5926 $elementName = $uqType;
5927 if (isset($typeDef[
'form']) && ($typeDef[
'form'] ==
'qualified')) {
5928 $elementNS =
" xmlns=\"$ns\"";
5930 $elementNS =
" xmlns=\"\"";
5933 $elementName =
$name;
5935 $elementNS =
" xmlns=\"\"";
5940 if (is_null($value)) {
5941 if ($use ==
'literal') {
5943 $xml =
"<$elementName$elementNS/>";
5945 $xml =
"<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->
getPrefixFromNamespace($ns) .
":$uqType\"/>";
5947 $this->
debug(
"in serializeType: returning: $xml");
5950 if (is_object($value)) {
5951 $value = get_object_vars($value);
5953 if (is_array($value)) {
5955 if ($use ==
'literal') {
5957 $xml =
"<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->
getPrefixFromNamespace($ns) .
":$uqType\">";
5959 $xml =
"<$elementName$elementNS$elementAttrs>";
5962 $xml =
"<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->
getPrefixFromNamespace($ns) .
":$uqType\"$encodingStyle>";
5966 $xml .=
"</$elementName>";
5968 $this->
debug(
"in serializeType: phpType is struct, but value is not an array");
5969 $this->
setError(
"phpType is struct, but value is not an array: see debug output for details");
5972 } elseif ($phpType ==
'array') {
5973 if (isset($typeDef[
'form']) && ($typeDef[
'form'] ==
'qualified')) {
5974 $elementNS =
" xmlns=\"$ns\"";
5977 $elementNS =
" xmlns=\"\"";
5982 if (is_null($value)) {
5983 if ($use ==
'literal') {
5985 $xml =
"<$name$elementNS/>";
5987 $xml =
"<$name$elementNS xsi:nil=\"true\" xsi:type=\"" .
5996 $this->
debug(
"in serializeType: returning: $xml");
5999 if (isset($typeDef[
'multidimensional'])) {
6001 foreach($value as $v) {
6002 $cols =
',' .
sizeof($v);
6003 $nv = array_merge($nv, $v);
6009 if (is_array($value) &&
sizeof($value) >= 1) {
6010 $rows =
sizeof($value);
6012 foreach($value as $k => $v) {
6013 $this->
debug(
"serializing array element: $k, $v of type: $typeDef[arrayType]");
6015 if (!in_array($typeDef[
'arrayType'],$this->typemap[
'http://www.w3.org/2001/XMLSchema'])) {
6016 $contents .= $this->
serializeType(
'item', $typeDef[
'arrayType'], $v, $use);
6018 $contents .= $this->
serialize_val($v,
'item', $typeDef[
'arrayType'], null, $this->XMLSchemaVersion,
false, $use);
6027 if ($use ==
'literal') {
6028 $xml =
"<$name$elementNS>"
6032 $xml =
"<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace(
'http://schemas.xmlsoap.org/soap/encoding/').
':Array" '.
6035 .$this->getPrefixFromNamespace($this->
getPrefix($typeDef[
'arrayType']))
6036 .
":".$this->
getLocalPart($typeDef[
'arrayType']).
"[$rows$cols]\">"
6040 } elseif ($phpType ==
'scalar') {
6041 if (isset($typeDef[
'form']) && ($typeDef[
'form'] ==
'qualified')) {
6042 $elementNS =
" xmlns=\"$ns\"";
6045 $elementNS =
" xmlns=\"\"";
6050 if ($use ==
'literal') {
6052 $xml =
"<$name$elementNS xsi:type=\"" . $this->
getPrefixFromNamespace($ns) .
":$uqType\">$value</$name>";
6054 $xml =
"<$name$elementNS>$value</$name>";
6057 $xml =
"<$name$elementNS xsi:type=\"" . $this->
getPrefixFromNamespace($ns) .
":$uqType\"$encodingStyle>$value</$name>";
6060 $this->
debug(
"in serializeType: returning: $xml");
6076 if (isset($typeDef[
'attrs']) && is_array($typeDef[
'attrs'])) {
6077 $this->
debug(
"serialize attributes for XML Schema type $ns:$uqType");
6078 if (is_array($value)) {
6080 } elseif (is_object($value)) {
6081 $xvalue = get_object_vars($value);
6083 $this->
debug(
"value is neither an array nor an object for XML Schema type $ns:$uqType");
6086 foreach ($typeDef[
'attrs'] as $aName => $attrs) {
6087 if (isset($xvalue[
'!' . $aName])) {
6088 $xname =
'!' . $aName;
6089 $this->
debug(
"value provided for attribute $aName with key $xname");
6090 } elseif (isset($xvalue[$aName])) {
6092 $this->
debug(
"value provided for attribute $aName with key $xname");
6093 } elseif (isset($attrs[
'default'])) {
6094 $xname =
'!' . $aName;
6095 $xvalue[$xname] = $attrs[
'default'];
6096 $this->
debug(
'use default value of ' . $xvalue[$aName] .
' for attribute ' . $aName);
6099 $this->
debug(
"no value provided for attribute $aName");
6102 $xml .=
" $aName=\"" . $this->
expandEntities($xvalue[$xname]) .
"\"";
6106 $this->
debug(
"no attributes to serialize for XML Schema type $ns:$uqType");
6108 if (isset($typeDef[
'extensionBase'])) {
6109 $ns = $this->
getPrefix($typeDef[
'extensionBase']);
6110 $uqType = $this->
getLocalPart($typeDef[
'extensionBase']);
6114 if ($typeDef = $this->
getTypeDef($uqType, $ns)) {
6115 $this->
debug(
"serialize attributes for extension base $ns:$uqType");
6118 $this->
debug(
"extension base $ns:$uqType is not a supported type");
6138 if (isset($typeDef[
'elements']) && is_array($typeDef[
'elements'])) {
6139 $this->
debug(
"in serializeComplexTypeElements, serialize elements for XML Schema type $ns:$uqType");
6140 if (is_array($value)) {
6142 } elseif (is_object($value)) {
6143 $xvalue = get_object_vars($value);
6145 $this->
debug(
"value is neither an array nor an object for XML Schema type $ns:$uqType");
6149 if (count($typeDef[
'elements']) != count($xvalue)){
6152 foreach ($typeDef[
'elements'] as $eName => $attrs) {
6153 if (!isset($xvalue[$eName])) {
6154 if (isset($attrs[
'default'])) {
6155 $xvalue[$eName] = $attrs[
'default'];
6156 $this->
debug(
'use default value of ' . $xvalue[$eName] .
' for element ' . $eName);
6160 if (isset($optionals)
6161 && (!isset($xvalue[$eName]))
6162 && ( (!isset($attrs[
'nillable'])) || $attrs[
'nillable'] !=
'true')
6164 if (isset($attrs[
'minOccurs']) && $attrs[
'minOccurs'] <>
'0') {
6165 $this->
debug(
"apparent error: no value provided for element $eName with minOccurs=" . $attrs[
'minOccurs']);
6168 $this->
debug(
"no value provided for complexType element $eName and element is not nillable, so serialize nothing");
6171 if (isset($xvalue[$eName])) {
6172 $v = $xvalue[$eName];
6176 if (isset($attrs[
'form'])) {
6177 $unqualified = ($attrs[
'form'] ==
'unqualified');
6179 $unqualified =
false;
6181 if (isset($attrs[
'maxOccurs']) && ($attrs[
'maxOccurs'] ==
'unbounded' || $attrs[
'maxOccurs'] > 1) && isset($v) && is_array($v) && $this->
isArraySimpleOrStruct($v) ==
'arraySimple') {
6183 foreach ($vv as $k => $v) {
6184 if (isset($attrs[
'type']) || isset($attrs[
'ref'])) {
6186 $xml .= $this->
serializeType($eName, isset($attrs[
'type']) ? $attrs[
'type'] : $attrs[
'ref'], $v, $use, $encodingStyle, $unqualified);
6189 $this->
debug(
"calling serialize_val() for $v, $eName, false, false, false, false, $use");
6190 $xml .= $this->
serialize_val($v, $eName,
false,
false,
false,
false, $use);
6194 if (isset($attrs[
'type']) || isset($attrs[
'ref'])) {
6196 $xml .= $this->
serializeType($eName, isset($attrs[
'type']) ? $attrs[
'type'] : $attrs[
'ref'], $v, $use, $encodingStyle, $unqualified);
6199 $this->
debug(
"calling serialize_val() for $v, $eName, false, false, false, false, $use");
6200 $xml .= $this->
serialize_val($v, $eName,
false,
false,
false,
false, $use);
6206 $this->
debug(
"no elements to serialize for XML Schema type $ns:$uqType");
6208 if (isset($typeDef[
'extensionBase'])) {
6209 $ns = $this->
getPrefix($typeDef[
'extensionBase']);
6210 $uqType = $this->
getLocalPart($typeDef[
'extensionBase']);
6214 if ($typeDef = $this->
getTypeDef($uqType, $ns)) {
6215 $this->
debug(
"serialize elements for extension base $ns:$uqType");
6218 $this->
debug(
"extension base $ns:$uqType is not a supported type");
6238 function addComplexType(
$name,$typeClass=
'complexType',$phpType=
'array',$compositor=
'',$restrictionBase=
'',$elements=array(),$attrs=array(),$arrayType=
'') {
6239 if (count($elements) > 0) {
6240 $eElements = array();
6241 foreach($elements as $n => $e){
6244 foreach ($e as $k => $v) {
6245 $k = strpos($k,
':') ? $this->
expandQname($k) : $k;
6246 $v = strpos($v,
':') ? $this->
expandQname($v) : $v;
6249 $eElements[$n] = $ee;
6251 $elements = $eElements;
6254 if (count($attrs) > 0) {
6255 foreach($attrs as $n => $a){
6257 foreach ($a as $k => $v) {
6258 $k = strpos($k,
':') ? $this->
expandQname($k) : $k;
6259 $v = strpos($v,
':') ? $this->
expandQname($v) : $v;
6267 $restrictionBase = strpos($restrictionBase,
':') ? $this->
expandQname($restrictionBase) : $restrictionBase;
6268 $arrayType = strpos($arrayType,
':') ? $this->
expandQname($arrayType) : $arrayType;
6270 $typens = isset($this->namespaces[
'types']) ? $this->namespaces[
'types'] : $this->namespaces[
'tns'];
6271 $this->schemas[$typens][0]->addComplexType(
$name,$typeClass,$phpType,$compositor,$restrictionBase,$elements,$attrs,$arrayType);
6285 function addSimpleType(
$name, $restrictionBase=
'', $typeClass=
'simpleType', $phpType=
'scalar', $enumeration=array()) {
6286 $restrictionBase = strpos($restrictionBase,
':') ? $this->
expandQname($restrictionBase) : $restrictionBase;
6288 $typens = isset($this->namespaces[
'types']) ? $this->namespaces[
'types'] : $this->namespaces[
'tns'];
6289 $this->schemas[$typens][0]->addSimpleType(
$name, $restrictionBase, $typeClass, $phpType, $enumeration);
6300 $typens = isset($this->namespaces[
'types']) ? $this->namespaces[
'types'] : $this->namespaces[
'tns'];
6301 $this->schemas[$typens][0]->addElement($attrs);
6319 if ($use ==
'encoded' && $encodingStyle ==
'') {
6320 $encodingStyle =
'http://schemas.xmlsoap.org/soap/encoding/';
6323 if ($style ==
'document') {
6324 $elements = array();
6325 foreach (
$in as $n =>
$t) {
6326 $elements[$n] = array(
'name' => $n,
'type' =>
$t);
6328 $this->
addComplexType(
$name .
'RequestType',
'complexType',
'struct',
'all',
'', $elements);
6330 $in = array(
'parameters' =>
'tns:' .
$name .
'^');
6332 $elements = array();
6333 foreach (
$out as $n =>
$t) {
6334 $elements[$n] = array(
'name' => $n,
'type' =>
$t);
6336 $this->
addComplexType(
$name .
'ResponseType',
'complexType',
'struct',
'all',
'', $elements);
6337 $this->
addElement(array(
'name' =>
$name .
'Response',
'type' =>
$name .
'ResponseType',
'form' =>
'qualified'));
6338 $out = array(
'parameters' =>
'tns:' .
$name .
'Response' .
'^');
6342 $this->bindings[ $this->serviceName .
'Binding' ][
'operations'][
$name] =
6345 'binding' => $this->serviceName .
'Binding',
6346 'endpoint' => $this->endpoint,
6347 'soapAction' => $soapaction,
6352 'encodingStyle' => $encodingStyle,
6353 'message' =>
$name .
'Request',
6358 'encodingStyle' => $encodingStyle,
6359 'message' =>
$name .
'Response',
6362 'transport' =>
'http://schemas.xmlsoap.org/soap/http',
6368 foreach(
$in as $pName => $pType)
6370 if(strpos($pType,
':')) {
6373 $this->messages[
$name.
'Request'][$pName] = $pType;
6376 $this->messages[
$name.
'Request']=
'0';
6380 foreach(
$out as $pName => $pType)
6382 if(strpos($pType,
':')) {
6385 $this->messages[
$name.
'Response'][$pName] = $pType;
6388 $this->messages[
$name.
'Response']=
'0';
6454 $this->xml_encoding = $encoding;
6461 $pos_xml = strpos(
$xml,
'<?xml');
6462 if ($pos_xml !== FALSE) {
6463 $xml_decl = substr(
$xml, $pos_xml, strpos(
$xml,
'?>', $pos_xml + 2) - $pos_xml + 1);
6464 if (preg_match(
"/encoding=[\"']([^\"']*)[\"']/", $xml_decl,
$res)) {
6467 $err =
"Charset from HTTP Content-Type '" . $encoding .
"' does not match encoding from XML declaration '" .
$xml_encoding .
"'";
6469 if ($encoding !=
'ISO-8859-1' || strtoupper(
$xml_encoding) !=
'UTF-8') {
6475 $this->
debug(
'Charset from HTTP Content-Type matches encoding from XML declaration');
6478 $this->
debug(
'No encoding specified in XML declaration');
6481 $this->
debug(
'No XML declaration');
6483 $this->
debug(
'Entering nusoap_parser(), length='.strlen(
$xml).
', encoding='.$encoding);
6485 $this->parser = xml_parser_create($this->xml_encoding);
6488 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
6489 xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding);
6491 xml_set_object($this->parser, $this);
6493 xml_set_element_handler($this->parser,
'start_element',
'end_element');
6494 xml_set_character_data_handler($this->parser,
'character_data');
6497 if(!xml_parse($this->parser,
$xml,
true)){
6499 $err = sprintf(
'XML error parsing SOAP payload on line %d: %s',
6500 xml_get_current_line_number($this->parser),
6501 xml_error_string(xml_get_error_code($this->parser)));
6506 $this->
debug(
'parsed successfully, found root struct: '.$this->root_struct.
' of name '.$this->root_struct_name);
6510 if($this->root_header !=
'' && isset($this->message[$this->root_header][
'result'])){
6514 if(
sizeof($this->multirefs) > 0){
6515 foreach($this->multirefs as $id => $hrefs){
6516 $this->
debug(
'resolving multirefs for id: '.$id);
6517 $idVal = $this->
buildVal($this->ids[$id]);
6518 if (is_array($idVal) && isset($idVal[
'!id'])) {
6519 unset($idVal[
'!id']);
6521 foreach($hrefs as $refPos => $ref){
6522 $this->
debug(
'resolving href at pos '.$refPos);
6523 $this->multirefs[$id][$refPos] = $idVal;
6528 xml_parser_free($this->parser);
6530 $this->
debug(
'xml was empty, didn\'t parse!');
6531 $this->
setError(
'xml was empty, didn\'t parse!');
6546 $pos = $this->position++;
6548 $this->message[
$pos] = array(
'pos' =>
$pos,
'children'=>
'',
'cdata'=>
'');
6551 $this->message[
$pos][
'depth'] = $this->depth++;
6560 $this->parent =
$pos;
6564 if(strpos(
$name,
':')){
6571 if(
$name ==
'Envelope'){
6572 $this->status =
'envelope';
6573 } elseif(
$name ==
'Header' && $this->status =
'envelope'){
6574 $this->root_header =
$pos;
6575 $this->status =
'header';
6576 } elseif(
$name ==
'Body' && $this->status =
'envelope'){
6577 $this->status =
'body';
6578 $this->body_position =
$pos;
6580 } elseif($this->status ==
'body' &&
$pos == ($this->body_position+1)){
6581 $this->status =
'method';
6582 $this->root_struct_name =
$name;
6583 $this->root_struct =
$pos;
6584 $this->message[
$pos][
'type'] =
'struct';
6585 $this->
debug(
"found root struct $this->root_struct_name, pos $this->root_struct");
6590 $this->message[
$pos][
'name'] = htmlspecialchars(
$name);
6592 $this->message[
$pos][
'attrs'] = $attrs;
6596 foreach($attrs as $key => $value){
6600 if($key_prefix ==
'xmlns'){
6601 if(preg_match(
'/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){
6602 $this->XMLSchemaVersion = $value;
6604 $this->namespaces[
'xsi'] = $this->XMLSchemaVersion.
'-instance';
6606 $this->namespaces[$key_localpart] = $value;
6608 if(
$name == $this->root_struct_name){
6609 $this->methodNamespace = $value;
6612 } elseif($key_localpart ==
'type'){
6613 if (isset($this->message[
$pos][
'type']) && $this->message[$pos][
'type'] ==
'array') {
6616 $value_prefix = $this->
getPrefix($value);
6618 $this->message[
$pos][
'type'] = $value_localpart;
6619 $this->message[
$pos][
'typePrefix'] = $value_prefix;
6620 if(isset($this->namespaces[$value_prefix])){
6621 $this->message[
$pos][
'type_namespace'] = $this->namespaces[$value_prefix];
6622 }
else if(isset($attrs[
'xmlns:'.$value_prefix])) {
6623 $this->message[
$pos][
'type_namespace'] = $attrs[
'xmlns:'.$value_prefix];
6627 } elseif($key_localpart ==
'arrayType'){
6628 $this->message[
$pos][
'type'] =
'array';
6637 $expr =
'/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/';
6638 if(preg_match($expr,$value,$regs)){
6639 $this->message[
$pos][
'typePrefix'] = $regs[1];
6640 $this->message[
$pos][
'arrayTypePrefix'] = $regs[1];
6641 if (isset($this->namespaces[$regs[1]])) {
6642 $this->message[
$pos][
'arrayTypeNamespace'] = $this->namespaces[$regs[1]];
6643 }
else if (isset($attrs[
'xmlns:'.$regs[1]])) {
6644 $this->message[
$pos][
'arrayTypeNamespace'] = $attrs[
'xmlns:'.$regs[1]];
6646 $this->message[
$pos][
'arrayType'] = $regs[2];
6647 $this->message[
$pos][
'arraySize'] = $regs[3];
6648 $this->message[
$pos][
'arrayCols'] = $regs[4];
6651 } elseif ($key_localpart ==
'nil'){
6652 $this->message[
$pos][
'nil'] = ($value ==
'true' || $value ==
'1');
6654 } elseif ($key !=
'href' && $key !=
'xmlns' && $key_localpart !=
'encodingStyle' && $key_localpart !=
'root') {
6655 $this->message[
$pos][
'xattrs'][
'!' . $key] = $value;
6658 if ($key ==
'xmlns') {
6659 $this->default_namespace = $value;
6663 $this->ids[$value] =
$pos;
6666 if($key_localpart ==
'root' && $value == 1){
6667 $this->status =
'method';
6668 $this->root_struct_name =
$name;
6669 $this->root_struct =
$pos;
6670 $this->
debug(
"found root struct $this->root_struct_name, pos $pos");
6673 $attstr .=
" $key=\"$value\"";
6677 $this->message[
$pos][
'namespace'] = $this->namespaces[$prefix];
6678 $this->default_namespace = $this->namespaces[$prefix];
6682 if($this->status ==
'header'){
6683 if ($this->root_header !=
$pos) {
6684 $this->responseHeaders .=
"<" . (isset($prefix) ? $prefix .
':' :
'') .
"$name$attstr>";
6686 } elseif($this->root_struct_name !=
''){
6687 $this->document .=
"<" . (isset($prefix) ? $prefix .
':' :
'') .
"$name$attstr>";
6700 $pos = $this->depth_array[$this->depth--];
6703 if(strpos(
$name,
':')){
6711 if(isset($this->body_position) &&
$pos > $this->body_position){
6713 if(isset($this->message[
$pos][
'attrs'][
'href'])){
6715 $id = substr($this->message[$pos][
'attrs'][
'href'],1);
6717 $this->multirefs[$id][
$pos] =
'placeholder';
6719 $this->message[
$pos][
'result'] =& $this->multirefs[$id][
$pos];
6721 } elseif($this->message[$pos][
'children'] !=
''){
6723 if(!isset($this->message[$pos][
'result'])){
6724 $this->message[
$pos][
'result'] = $this->
buildVal($pos);
6727 } elseif (isset($this->message[$pos][
'xattrs'])) {
6728 if (isset($this->message[$pos][
'nil']) && $this->message[$pos][
'nil']) {
6729 $this->message[
$pos][
'xattrs'][
'!'] = null;
6730 } elseif (isset($this->message[$pos][
'cdata']) && trim($this->message[$pos][
'cdata']) !=
'') {
6731 if (isset($this->message[$pos][
'type'])) {
6732 $this->message[
$pos][
'xattrs'][
'!'] = $this->
decodeSimple($this->message[$pos][
'cdata'], $this->message[$pos][
'type'], isset($this->message[$pos][
'type_namespace']) ? $this->message[$pos][
'type_namespace'] :
'');
6735 if (isset($this->message[
$parent][
'type']) && ($this->message[$parent][
'type'] ==
'array') && isset($this->message[$parent][
'arrayType'])) {
6736 $this->message[
$pos][
'xattrs'][
'!'] = $this->
decodeSimple($this->message[$pos][
'cdata'], $this->message[$parent][
'arrayType'], isset($this->message[$parent][
'arrayTypeNamespace']) ? $this->message[$parent][
'arrayTypeNamespace'] :
'');
6738 $this->message[
$pos][
'xattrs'][
'!'] = $this->message[
$pos][
'cdata'];
6742 $this->message[
$pos][
'result'] = $this->message[
$pos][
'xattrs'];
6746 if (isset($this->message[$pos][
'nil']) && $this->message[$pos][
'nil']) {
6747 $this->message[
$pos][
'xattrs'][
'!'] = null;
6748 } elseif (isset($this->message[$pos][
'type'])) {
6749 $this->message[
$pos][
'result'] = $this->
decodeSimple($this->message[$pos][
'cdata'], $this->message[$pos][
'type'], isset($this->message[$pos][
'type_namespace']) ? $this->message[$pos][
'type_namespace'] :
'');
6752 if (isset($this->message[
$parent][
'type']) && ($this->message[$parent][
'type'] ==
'array') && isset($this->message[$parent][
'arrayType'])) {
6753 $this->message[
$pos][
'result'] = $this->
decodeSimple($this->message[$pos][
'cdata'], $this->message[$parent][
'arrayType'], isset($this->message[$parent][
'arrayTypeNamespace']) ? $this->message[$parent][
'arrayTypeNamespace'] :
'');
6755 $this->message[
$pos][
'result'] = $this->message[
$pos][
'cdata'];
6773 if($this->status ==
'header'){
6774 if ($this->root_header !=
$pos) {
6775 $this->responseHeaders .=
"</" . (isset($prefix) ? $prefix .
':' :
'') .
"$name>";
6777 } elseif(
$pos >= $this->root_struct){
6778 $this->document .=
"</" . (isset($prefix) ? $prefix .
':' :
'') .
"$name>";
6781 if(
$pos == $this->root_struct){
6782 $this->status =
'body';
6783 $this->root_struct_namespace = $this->message[
$pos][
'namespace'];
6784 } elseif(
$name ==
'Body'){
6785 $this->status =
'envelope';
6786 } elseif(
$name ==
'Header'){
6787 $this->status =
'envelope';
6788 } elseif(
$name ==
'Envelope'){
6792 $this->parent = $this->message[
$pos][
'parent'];
6804 if ($this->xml_encoding==
'UTF-8'){
6808 if($this->decode_utf8){
6814 if($this->status ==
'header'){
6815 $this->responseHeaders .=
$data;
6817 $this->document .=
$data;
6874 return (
string) $value;
6877 return (
int) $value;
6880 return (
double) $value;
6882 if (
$type ==
'boolean') {
6883 if (strtolower($value) ==
'false' || strtolower($value) ==
'f') {
6886 return (
boolean) $value;
6888 if (
$type ==
'base64' ||
$type ==
'base64Binary') {
6889 $this->
debug(
'Decode base64 value');
6890 return base64_decode($value);
6893 if (
$type ==
'nonPositiveInteger' ||
$type ==
'negativeInteger'
6894 ||
$type ==
'nonNegativeInteger' ||
$type ==
'positiveInteger'
6895 ||
$type ==
'unsignedInt'
6896 ||
$type ==
'unsignedShort' ||
$type ==
'unsignedByte') {
6897 return (
int) $value;
6900 if (
$type ==
'array') {
6904 return (
string) $value;
6916 if(!isset($this->message[
$pos][
'type'])){
6917 $this->message[
$pos][
'type'] =
'';
6919 $this->
debug(
'in buildVal() for '.$this->message[$pos][
'name'].
"(pos $pos) of type ".$this->message[$pos][
'type']);
6921 if($this->message[$pos][
'children'] !=
''){
6922 $this->
debug(
'in buildVal, there are children');
6923 $children = explode(
'|',$this->message[$pos][
'children']);
6924 array_shift($children);
6926 if(isset($this->message[$pos][
'arrayCols']) && $this->message[$pos][
'arrayCols'] !=
''){
6929 foreach($children as $child_pos){
6930 $this->
debug(
"in buildVal, got an MD array element: $r, $c");
6931 $params[$r][] = $this->message[$child_pos][
'result'];
6933 if($c == $this->message[$pos][
'arrayCols']){
6939 } elseif($this->message[$pos][
'type'] ==
'array' || $this->message[$pos][
'type'] ==
'Array'){
6940 $this->
debug(
'in buildVal, adding array '.$this->message[$pos][
'name']);
6941 foreach($children as $child_pos){
6942 $params[] = &$this->message[$child_pos][
'result'];
6945 } elseif($this->message[$pos][
'type'] ==
'Map' && $this->message[$pos][
'type_namespace'] ==
'http://xml.apache.org/xml-soap'){
6946 $this->
debug(
'in buildVal, Java Map '.$this->message[$pos][
'name']);
6947 foreach($children as $child_pos){
6948 $kv = explode(
"|",$this->message[$child_pos][
'children']);
6949 $params[$this->message[$kv[1]][
'result']] = &$this->message[$kv[2]][
'result'];
6955 $this->
debug(
'in buildVal, adding Java Vector or generic compound type '.$this->message[$pos][
'name']);
6956 if ($this->message[$pos][
'type'] ==
'Vector' && $this->message[$pos][
'type_namespace'] ==
'http://xml.apache.org/xml-soap') {
6962 foreach($children as $child_pos){
6964 $params[] = &$this->message[$child_pos][
'result'];
6966 if (isset($params[$this->message[$child_pos][
'name']])) {
6968 if ((!is_array($params[$this->message[$child_pos][
'name']])) || (!isset($params[$this->message[$child_pos][
'name']][0]))) {
6969 $params[$this->message[$child_pos][
'name']] = array($params[$this->message[$child_pos][
'name']]);
6971 $params[$this->message[$child_pos][
'name']][] = &$this->message[$child_pos][
'result'];
6973 $params[$this->message[$child_pos][
'name']] = &$this->message[$child_pos][
'result'];
6978 if (isset($this->message[$pos][
'xattrs'])) {
6979 $this->
debug(
'in buildVal, handling attributes');
6980 foreach ($this->message[$pos][
'xattrs'] as $n => $v) {
6985 if (isset($this->message[$pos][
'cdata']) && trim($this->message[$pos][
'cdata']) !=
'') {
6986 $this->
debug(
'in buildVal, handling simpleContent');
6987 if (isset($this->message[$pos][
'type'])) {
6988 $params[
'!'] = $this->
decodeSimple($this->message[$pos][
'cdata'], $this->message[$pos][
'type'], isset($this->message[$pos][
'type_namespace']) ? $this->message[$pos][
'type_namespace'] :
'');
6991 if (isset($this->message[
$parent][
'type']) && ($this->message[$parent][
'type'] ==
'array') && isset($this->message[$parent][
'arrayType'])) {
6992 $params[
'!'] = $this->
decodeSimple($this->message[$pos][
'cdata'], $this->message[$parent][
'arrayType'], isset($this->message[$parent][
'arrayTypeNamespace']) ? $this->message[$parent][
'arrayTypeNamespace'] :
'');
6994 $params[
'!'] = $this->message[
$pos][
'cdata'];
6998 $ret = is_array($params) ? $params : array();
6999 $this->
debug(
'in buildVal, return:');
7003 $this->
debug(
'in buildVal, no children, building scalar');
7004 $cdata = isset($this->message[$pos][
'cdata']) ? $this->message[
$pos][
'cdata'] :
'';
7005 if (isset($this->message[$pos][
'type'])) {
7006 $ret = $this->
decodeSimple($cdata, $this->message[$pos][
'type'], isset($this->message[$pos][
'type_namespace']) ? $this->message[$pos][
'type_namespace'] :
'');
7007 $this->
debug(
"in buildVal, return: $ret");
7011 if (isset($this->message[
$parent][
'type']) && ($this->message[$parent][
'type'] ==
'array') && isset($this->message[$parent][
'arrayType'])) {
7012 $ret = $this->
decodeSimple($cdata, $this->message[$parent][
'arrayType'], isset($this->message[$parent][
'arrayTypeNamespace']) ? $this->message[$parent][
'arrayTypeNamespace'] :
'');
7013 $this->
debug(
"in buildVal, return: $ret");
7016 $ret = $this->message[
$pos][
'cdata'];
7017 $this->
debug(
"in buildVal, return: $ret");
7134 $this->
debug(
"ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
7141 $this->endpoint = $this->
wsdl->
wsdl;
7143 $this->
debug(
'existing wsdl instance created from ' . $this->endpoint);
7148 $this->
debug(
'will use lazy evaluation of wsdl from ' . $this->endpoint);
7150 $this->endpointType =
'wsdl';
7152 $this->
debug(
"instantiate SOAP with endpoint at $endpoint");
7153 $this->endpointType =
'soap';
7182 function call($operation,$params=array(),
$namespace=
'http://tempuri.org',$soapAction=
'',$headers=
false,$rpcParams=null,$style=
'rpc',$use=
'encoded'){
7183 $this->operation = $operation;
7184 $this->fault =
false;
7186 $this->request =
'';
7187 $this->response =
'';
7188 $this->responseData =
'';
7189 $this->faultstring =
'';
7190 $this->faultcode =
'';
7191 $this->opData = array();
7193 $this->
debug(
"call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType");
7197 $this->requestHeaders = $headers;
7199 if ($this->endpointType ==
'wsdl' && is_null($this->
wsdl)) {
7205 if($this->endpointType ==
'wsdl' && $opData = $this->
getOperationData($operation)){
7207 $this->opData = $opData;
7208 $this->
debug(
"found operation");
7210 if (isset($opData[
'soapAction'])) {
7211 $soapAction = $opData[
'soapAction'];
7213 if (! $this->forceEndpoint) {
7214 $this->endpoint = $opData[
'endpoint'];
7218 $namespace = isset($opData[
'input'][
'namespace']) ? $opData[
'input'][
'namespace'] :
$namespace;
7219 $style = $opData[
'style'];
7220 $use = $opData[
'input'][
'use'];
7223 $nsPrefix =
'ns' . rand(1000, 9999);
7228 if (is_string($params)) {
7229 $this->
debug(
"serializing param string for WSDL operation $operation");
7231 } elseif (is_array($params)) {
7232 $this->
debug(
"serializing param array for WSDL operation $operation");
7235 $this->
debug(
'params must be array or string');
7236 $this->
setError(
'params must be array or string');
7240 if (isset($opData[
'input'][
'encodingStyle'])) {
7241 $encodingStyle = $opData[
'input'][
'encodingStyle'];
7243 $encodingStyle =
'';
7248 $this->
debug(
'got wsdl error: '.$errstr);
7249 $this->
setError(
'wsdl error: '.$errstr);
7252 } elseif($this->endpointType ==
'wsdl') {
7256 $this->
setError(
'operation '.$operation.
' not present.');
7257 $this->
debug(
"operation '$operation' not present.");
7262 $nsPrefix =
'ns' . rand(1000, 9999);
7265 if (is_string($params)) {
7266 $this->
debug(
"serializing param string for operation $operation");
7268 } elseif (is_array($params)) {
7269 $this->
debug(
"serializing param array for operation $operation");
7270 foreach($params as $k => $v){
7271 $payload .= $this->
serialize_val($v,$k,
false,
false,
false,
false,$use);
7274 $this->
debug(
'params must be array or string');
7275 $this->
setError(
'params must be array or string');
7279 if ($use ==
'encoded') {
7280 $encodingStyle =
'http://schemas.xmlsoap.org/soap/encoding/';
7282 $encodingStyle =
'';
7286 if ($style ==
'rpc') {
7287 if ($use ==
'literal') {
7288 $this->
debug(
"wrapping RPC request with literal method element");
7291 $payload =
"<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
7293 "</$nsPrefix:$operation>";
7295 $payload =
"<$operation>" . $payload .
"</$operation>";
7298 $this->
debug(
"wrapping RPC request with encoded method element");
7300 $payload =
"<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
7302 "</$nsPrefix:$operation>";
7304 $payload =
"<$operation>" .
7312 $this->
debug(
"endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style, use=$use, encodingStyle=$encodingStyle");
7313 $this->
debug(
'SOAP message length=' . strlen($soapmsg) .
' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000));
7315 $return = $this->
send($this->
getHTTPBody($soapmsg),$soapAction,$this->timeout,$this->response_timeout);
7317 $this->
debug(
'Error: '.$errstr);
7320 $this->
return = $return;
7321 $this->
debug(
'sent message successfully and got a(n) '.gettype($return));
7325 if(is_array($return) && isset($return[
'faultcode'])){
7326 $this->
debug(
'got fault');
7327 $this->
setError($return[
'faultcode'].
': '.$return[
'faultstring']);
7328 $this->fault =
true;
7329 foreach($return as $k => $v){
7331 $this->
debug(
"$k = $v<br>");
7334 } elseif ($style ==
'document') {
7340 if(is_array($return)){
7343 if(
sizeof($return) > 1){
7347 $return = array_shift($return);
7348 $this->
debug(
'return shifted value: ');
7367 $this->
debug(
'checkWSDL');
7370 $this->
debug(
'got wsdl error: '.$errstr);
7371 $this->
setError(
'wsdl error: '.$errstr);
7373 $this->bindingType =
'soap';
7374 $this->
debug(
'got '.count($this->operations).
' operations from wsdl '.$this->wsdlFile.
' for binding type '.$this->bindingType);
7376 $this->bindingType =
'soap12';
7377 $this->
debug(
'got '.count($this->operations).
' operations from wsdl '.$this->wsdlFile.
' for binding type '.$this->bindingType);
7378 $this->
debug(
'**************** WARNING: SOAP 1.2 BINDING *****************');
7380 $this->
debug(
'getOperations returned false');
7381 $this->
setError(
'no operations defined in the WSDL document!');
7391 $this->
debug(
'instantiating wsdl class with doc: '.$this->wsdlFile);
7392 $this->
wsdl =&
new wsdl(
'',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout,$this->curl_options,$this->use_curl);
7393 $this->
wsdl->
setCredentials($this->username, $this->password, $this->authtype, $this->certRequest);
7406 if ($this->endpointType ==
'wsdl' && is_null($this->
wsdl)) {
7411 if(isset($this->operations[$operation])){
7412 return $this->operations[$operation];
7414 $this->
debug(
"No data for operation: $operation");
7436 case preg_match(
'/^http/',$this->endpoint):
7437 $this->
debug(
'transporting via HTTP');
7438 if($this->persistentConnection ==
true && is_object($this->persistentConnection)){
7442 if ($this->persistentConnection) {
7443 $http->usePersistentConnection();
7447 $http->setSOAPAction($soapaction);
7448 if($this->proxyhost && $this->proxyport){
7449 $http->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
7451 if($this->authtype !=
'') {
7452 $http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
7454 if($this->http_encoding !=
''){
7455 $http->setEncoding($this->http_encoding);
7457 $this->
debug(
'sending message, length='.strlen($msg));
7458 if(preg_match(
'/^http:/',$this->endpoint)){
7461 } elseif(preg_match(
'/^https/',$this->endpoint)){
7470 $this->
setError(
'no http/s in endpoint url');
7472 $this->request = $http->outgoing_payload;
7473 $this->response = $http->incoming_payload;
7478 if ($this->persistentConnection) {
7479 $http->clearDebug();
7480 if (!is_object($this->persistentConnection)) {
7481 $this->persistentConnection = $http;
7485 if($err = $http->getError()){
7486 $this->
setError(
'HTTP Error: '.$err);
7491 $this->
debug(
'got response, length='. strlen($this->responseData).
' type='.$http->incoming_headers[
'content-type']);
7492 return $this->
parseResponse($http->incoming_headers, $this->responseData);
7496 $this->
setError(
'no transport found, or selected transport is not yet supported!');
7511 $this->
debug(
'Entering parseResponse() for data of length ' . strlen(
$data) .
' headers:');
7513 if (!strstr($headers[
'content-type'],
'text/xml')) {
7514 $this->
setError(
'Response not of type text/xml: ' . $headers[
'content-type']);
7517 if (strpos($headers[
'content-type'],
'=')) {
7518 $enc = str_replace(
'"',
'', substr(strstr($headers[
"content-type"],
'='), 1));
7519 $this->
debug(
'Got response encoding: ' .
$enc);
7520 if(preg_match(
'/^(ISO-8859-1|US-ASCII|UTF-8)$/i',
$enc)){
7521 $this->xml_encoding = strtoupper(
$enc);
7523 $this->xml_encoding =
'US-ASCII';
7527 $this->xml_encoding =
'ISO-8859-1';
7529 $this->
debug(
'Use encoding: ' . $this->xml_encoding .
' when creating nusoap_parser');
7530 $parser =
new nusoap_parser(
$data,$this->xml_encoding,$this->operation,$this->decode_utf8);
7534 if($errstr = $parser->getError()){
7541 $this->responseHeaders = $parser->getHeaders();
7543 $this->responseHeader = $parser->get_soapheader();
7545 $return = $parser->get_soapbody();
7547 $this->document = $parser->document;
7563 $this->
debug(
"setCurlOption option=$option, value=");
7565 $this->curl_options[$option] = $value;
7575 $this->
debug(
"setEndpoint(\"$endpoint\")");
7586 $this->
debug(
"setHeaders headers=");
7588 $this->requestHeaders = $headers;
7637 $this->
debug(
"setCredentials username=$username authtype=$authtype certRequest=");
7652 $this->
debug(
"setHTTPEncoding(\"$enc\")");
7653 $this->http_encoding =
$enc;
7663 $this->
debug(
"setUseCURL($use)");
7664 $this->use_curl = $use;
7673 $this->
debug(
"useHTTPPersistentConnection");
7674 $this->persistentConnection =
true;
7704 $this->defaultRpcParams = $rpcParams;
7719 $this->
debug(
"Error from _getProxyClassCode, so return NULL");
7725 eval(
"\$proxy = new nusoap_proxy_$r('');");
7727 $proxy->endpointType =
'wsdl';
7728 $proxy->wsdlFile = $this->wsdlFile;
7729 $proxy->wsdl = $this->wsdl;
7763 $this->
debug(
"in getProxy endpointType=$this->endpointType");
7765 if ($this->endpointType !=
'wsdl') {
7766 $evalStr =
'A proxy can only be created for a WSDL client';
7768 $evalStr =
"echo \"$evalStr\";";
7771 if ($this->endpointType ==
'wsdl' && is_null($this->
wsdl)) {
7774 return "echo \"" . $this->
getError() .
"\";";
7778 foreach ($this->operations as $operation => $opData) {
7779 if ($operation !=
'') {
7781 if (
sizeof($opData[
'input'][
'parts']) > 0) {
7783 $paramArrayStr =
'';
7784 $paramCommentStr =
'';
7785 foreach ($opData[
'input'][
'parts'] as
$name =>
$type) {
7786 $paramStr .=
"\$$name, ";
7787 $paramArrayStr .=
"'$name' => \$$name, ";
7788 $paramCommentStr .=
"$type \$$name, ";
7790 $paramStr = substr($paramStr, 0, strlen($paramStr)-2);
7791 $paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr)-2);
7792 $paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr)-2);
7795 $paramArrayStr =
'';
7796 $paramCommentStr =
'void';
7798 $opData[
'namespace'] = !isset($opData[
'namespace']) ?
'http://testuri.com' : $opData[
'namespace'];
7799 $evalStr .=
"// $paramCommentStr
7800 function " . str_replace(
'.',
'__', $operation) .
"($paramStr) {
7801 \$params = array($paramArrayStr);
7802 return \$this->call('$operation', \$params, '".$opData[
'namespace'].
"', '".(isset($opData[
'soapAction']) ? $opData[
'soapAction'] :
'').
"');
7806 unset($paramCommentStr);
7809 $evalStr =
'class nusoap_proxy_'.$r.
' extends nusoap_client {
7869 $this->decode_utf8 = $bool;
7882 if (strlen(
$name) == 0) {
7885 $this->cookies[] = array(
'name' =>
$name,
'value' => $value);
7906 if (
sizeof($this->cookies) == 0) {
7909 $this->
debug(
'checkCookie: check ' .
sizeof($this->cookies) .
' cookies');
7911 $this->cookies = array();
7912 foreach ($curr_cookies as $cookie) {
7913 if (! is_array($cookie)) {
7914 $this->
debug(
'Remove cookie that is not an array');
7917 if ((isset($cookie[
'expires'])) && (! empty($cookie[
'expires']))) {
7918 if (strtotime($cookie[
'expires']) > time()) {
7919 $this->cookies[] = $cookie;
7921 $this->
debug(
'Remove expired cookie ' . $cookie[
'name']);
7924 $this->cookies[] = $cookie;
7927 $this->
debug(
'checkCookie: '.
sizeof($this->cookies).
' cookies left in array');
7939 if (
sizeof($this->cookies) == 0) {
7942 $this->
debug(
'Setting new cookie(s)');
7953 if (!is_array($newCookie)) {
7956 if ((!isset($newCookie[
'name'])) || (!isset($newCookie[
'value']))) {
7959 $newName = $newCookie[
'name'];
7962 for ($i = 0; $i < count($this->cookies); $i++) {
7963 $cookie = $this->cookies[$i];
7964 if (!is_array($cookie)) {
7967 if (!isset($cookie[
'name'])) {
7970 if ($newName != $cookie[
'name']) {
7973 $newDomain = isset($newCookie[
'domain']) ? $newCookie[
'domain'] :
'NODOMAIN';
7974 $domain = isset($cookie[
'domain']) ? $cookie[
'domain'] :
'NODOMAIN';
7975 if ($newDomain != $domain) {
7978 $newPath = isset($newCookie[
'path']) ? $newCookie[
'path'] :
'NOPATH';
7979 $path = isset($cookie[
'path']) ? $cookie[
'path'] :
'NOPATH';
7980 if ($newPath !=
$path) {
7983 $this->cookies[$i] = $newCookie;
7985 $this->
debug(
'Update cookie ' . $newName .
'=' . $newCookie[
'value']);
7989 $this->
debug(
'Add cookie ' . $newName .
'=' . $newCookie[
'value']);
7990 $this->cookies[] = $newCookie;
7997 if (!extension_loaded(
'soap')) {