cvs: pear /SOAP Base.php Client.php Header.php Message.php Parser.php Server.php Value.php WSDL.php globals.php /SOAP/Transport HTTP.php

From: Date: Sat, 30 Mar 2002 23:13:21 +0000
Subject: cvs: pear /SOAP Base.php Client.php Header.php Message.php Parser.php Server.php Value.php WSDL.php globals.php /SOAP/Transport HTTP.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-2917@lists.php.net to get a copy of this message
shane Sat Mar 30 18:13:21 2002 EDT Added files: /pear/SOAP Header.php Modified files: /pear/SOAP Base.php Client.php Message.php Parser.php Server.php Value.php WSDL.php globals.php /pear/SOAP/Transport HTTP.php Log: - add SOAP Header support - improve WSDL support in SOAP Value

Index: pear/SOAP/Base.php diff -u pear/SOAP/Base.php:1.4 pear/SOAP/Base.php:1.5 --- pear/SOAP/Base.php:1.4 Fri Mar 8 21:02:30 2002 +++ pear/SOAP/Base.php Sat Mar 30 18:13:21 2002 @@ -17,13 +17,13 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: Base.php,v 1.4 2002/03/09 02:02:30 shane Exp $ +// $Id: Base.php,v 1.5 2002/03/30 23:13:21 shane Exp $ // /** * Common base class of all Soap lclasses * -* @version $Id: Base.php,v 1.4 2002/03/09 02:02:30 shane Exp $ +* @version $Id: Base.php,v 1.5 2002/03/30 23:13:21 shane Exp $ * @package SOAP::Client * @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more * @author Dietrich Ayala <dietrich@ganx4.com> Original Author @@ -135,16 +135,22 @@ { var $name = ''; var $ns = ''; + #var $arrayInfo = ''; + function QName($name) { $s = split(':',$name); $s = array_reverse($s); $this->name = $s[0]; $this->ns = $s[1]; - if (strpos($this->name, '[') != false) { - # XXX need to re-examine this logic later - # chop off [] - $this->name = substr($this->name, 0, strlen($this->name)-2); - } + + # a little more magic than should be in a qname + #$p = strpos($this->name, '['); + #if ($p) { + # # XXX need to re-examine this logic later + # # chop off [] + # $this->arrayInfo = substr($this->name, $p); + # $this->name = substr($this->name, 0, $p); + #} } } ?> Index: pear/SOAP/Client.php diff -u pear/SOAP/Client.php:1.16 pear/SOAP/Client.php:1.17 --- pear/SOAP/Client.php:1.16 Wed Mar 20 21:13:29 2002 +++ pear/SOAP/Client.php Sat Mar 30 18:13:21 2002 @@ -17,7 +17,7 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: Client.php,v 1.16 2002/03/21 02:13:29 shane Exp $ +// $Id: Client.php,v 1.17 2002/03/30 23:13:21 shane Exp $ // require_once 'SOAP/Value.php'; @@ -38,7 +38,7 @@ * originaly based on SOAPx4 by Dietrich Ayala http://dietrich.ganx4.com/soapx4 * * @access public -* @version $Id: Client.php,v 1.16 2002/03/21 02:13:29 shane Exp $ +* @version $Id: Client.php,v 1.17 2002/03/30 23:13:21 shane Exp $ * @package SOAP::Client * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates * @author Stig Bakken <ssb@fast.no> Conversion to PEAR @@ -105,7 +105,9 @@ */ var $wsdl = NULL; + var $wire = NULL; + var $soapmsg = NULL; /** * SOAP_Client constructor * @@ -131,6 +133,22 @@ } } + function addHeader($soap_value) + { + if (!$this->soapmsg) + $this->soapmsg = new SOAP_Message(NULL, $this->wsdl); + # add a new header to the message + if (get_class($soap_value) == 'soap_header') { + $this->soapmsg->addHeader($soap_value); + } else if (gettype($soap_value) == 'array') { + // name, value, namespace, mustunderstand, actor + $h = new SOAP_Header($soap_value[0], NULL, $soap_value[1], $soap_value[2], $soap_value[3], $soap_value[4]); + $this->soapmsg->addHeader($h); + } else { + $this->raiseSoapFault("Don't understand the header info you provided. Must be array or SOAP_Header."); + } + } + /** * SOAP_Client::call * @@ -195,7 +213,7 @@ else $type_namespace = NULL; $type = $qname->name; - $nparams[$name] = new SOAP_Value($name, $type, $nparams[$name], $namespace, $type_namespace, $this->wsdl); + $nparams[$name] = new SOAP_Value($name, $qname->name, $nparams[$name], NULL, $type_namespace, $this->wsdl); } } } @@ -207,13 +225,15 @@ $this->debug("namespace: $namespace"); // make message - $soapmsg = new SOAP_Message($method, $params, $namespace, NULL, $this->wsdl); - if ($soapmsg->fault) { - return $this->raiseSoapFault($soapmsg->fault); + if (!$this->soapmsg) + $this->soapmsg = new SOAP_Message(NULL, $this->wsdl); + $this->soapmsg->method($method, $params, $namespace); + if ($this->soapmsg->fault) { + return $this->raiseSoapFault($this->soapmsg->fault); } // serialize the message - $soap_data = $soapmsg->serialize(); + $soap_data = $this->soapmsg->serialize(); $this->debug("soap_data " . $soap_data); if (PEAR::isError($soap_data)) { return $this->raiseSoapFault($soap_data); @@ -224,6 +244,7 @@ $dbg = "calling server at '$this->endpoint'..."; $soap_transport = new SOAP_Transport($this->endpoint, $this->debug_flag); + if ($soap_transport->fault) { return $this->raiseSoapFault($soap_transport->fault); } @@ -236,12 +257,30 @@ // send the message $this->response = $soap_transport->send($soap_data, $soapAction); + + // save the wire information for debugging + $this->wire = "OUTGOING:\n\n". + $soap_transport->transport->outgoing_payload. + "\n\nINCOMING\n\n". + preg_replace("/>/",">\n",$soap_transport->transport->incoming_payload); + $this->debug($this->wire); + if ($soap_transport->fault) { return $this->raiseSoapFault($this->response); } // parse the response - $return = $soapmsg->parseResponse($this->response); + #$return = $this->soapmsg->parseResponse($this->response); + $this->response = new SOAP_Parser($this->response); + // return array of parameters + $return = $this->response->getResponse(); + $headers = $this->response->getHeaders(); + if ($headers) { + $this->headers = $headers->decode(); + } + + $this->soapmsg = NULL; + $this->debug($soap_transport->debug_data); $this->debug($dbg . 'sent message successfully and got a(n) ' . gettype($return) . ' back'); Index: pear/SOAP/Message.php diff -u pear/SOAP/Message.php:1.9 pear/SOAP/Message.php:1.10 --- pear/SOAP/Message.php:1.9 Fri Mar 8 04:25:14 2002 +++ pear/SOAP/Message.php Sat Mar 30 18:13:21 2002 @@ -17,13 +17,14 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: Message.php,v 1.9 2002/03/08 09:25:14 shane Exp $ +// $Id: Message.php,v 1.10 2002/03/30 23:13:21 shane Exp $ // require_once 'SOAP/globals.php'; require_once 'SOAP/Base.php'; require_once 'SOAP/Parser.php'; require_once 'SOAP/Value.php'; +require_once 'SOAP/Header.php'; /** * SOAP Message Class @@ -32,7 +33,7 @@ * originaly based on SOAPx4 by Dietrich Ayala http://dietrich.ganx4.com/soapx4 * * @access public -* @version $Id: Message.php,v 1.9 2002/03/08 09:25:14 shane Exp $ +* @version $Id: Message.php,v 1.10 2002/03/30 23:13:21 shane Exp $ * @package SOAP::Message * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates * @author Dietrich Ayala <dietrich@ganx4.com> Original Author @@ -61,6 +62,8 @@ */ var $value = ''; + var $headers = array(); + /** * SOAP::Message constructor * @@ -73,26 +76,31 @@ * * @access public */ - function SOAP_Message($method, $params, $method_namespace = 'http://testuri.org', $new_namespaces = NULL, $wsdl = NULL) + function SOAP_Message($new_namespaces = NULL, $wsdl = NULL) { + $this->debug_data = "entering SOAP_Message()\n"; parent::SOAP_Base('Message'); - // make method struct - $this->value = new SOAP_Value($method, 'Struct', $params, $method_namespace, NULL, $wsdl); - + $this->wsdl = $wsdl; if (is_array($new_namespaces)) { global $SOAP_namespaces; - $i = count($SOAP_namespaces); - foreach ($new_namespaces as $v) { $SOAP_namespaces[$v] = 'ns' . $i++; } - $this->namespaces = $SOAP_namespaces; } + } - - $this->debug_data = 'entering SOAP_Message() with SOAP_Value ' . $this->value->name . "\n"; + function addHeader($soap_value) + { + $this->headers[] = $soap_value; + } + + function method($method, $params, $method_namespace = NULL) + { + // make method struct + $this->value = new SOAP_Value($method, 'Struct', $params, $method_namespace, NULL, $wsdl); + $this->debug_data = 'SOAP_Message() with method SOAP_Value ' . $this->value->name . "\n"; } /** @@ -102,7 +110,7 @@ * @return string xml_soap_data * @access private */ - function _makeEnvelope($payload) + function _makeEnvelope($header, $body) { global $SOAP_namespaces; @@ -112,9 +120,28 @@ $ns_string .= "xmlns:$v=\"$k\"\n "; } return "<SOAP-ENV:Envelope $ns_string SOAP-ENV:encodingStyle=\"" . SOAP_SCHEMA_ENCODING . "\">\n" . - $payload . + $header . + $body . "</SOAP-ENV:Envelope>\n"; } + + /** + * wraps the soap Header + * + * @param string $payload soap data (in xml) + * + * @return string xml_soap_data + * @access private + */ + function _makeHeader() + { + $payload = ''; + foreach ($this->headers as $header) { + $payload .= $header->serialize(); + } + if (!$payload) return NULL; + return "<SOAP-ENV:Header>\n" . $payload . "</SOAP-ENV:Header>\n"; + } /** * wraps the soap body @@ -136,8 +163,9 @@ */ function _createPayload() { - $value = $this->value; - $payload = $this->_makeEnvelope($this->_makeBody($value->serialize())); + $body = $this->value?$this->_makeBody($this->value->serialize()):NULL; + $header = count($this->headers)?$this->_makeHeader():NULL; + $payload = $this->_makeEnvelope($header, $body); $this->debug($value->debug_data); $payload = "<?xml version=\"1.0\"?>\n\n" . $payload; if ($this->debug_flag) { Index: pear/SOAP/Parser.php diff -u pear/SOAP/Parser.php:1.10 pear/SOAP/Parser.php:1.11 --- pear/SOAP/Parser.php:1.10 Mon Mar 11 03:32:20 2002 +++ pear/SOAP/Parser.php Sat Mar 30 18:13:21 2002 @@ -17,7 +17,7 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: Parser.php,v 1.10 2002/03/11 08:32:20 shane Exp $ +// $Id: Parser.php,v 1.11 2002/03/30 23:13:21 shane Exp $ // require_once('SOAP/globals.php'); @@ -30,7 +30,7 @@ * originaly based on SOAPx4 by Dietrich Ayala http://dietrich.ganx4.com/soapx4 * * @access public -* @version $Id: Parser.php,v 1.10 2002/03/11 08:32:20 shane Exp $ +* @version $Id: Parser.php,v 1.11 2002/03/30 23:13:21 shane Exp $ * @package SOAP::Parser * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates * @author Dietrich Ayala <dietrich@ganx4.com> Original Author @@ -55,16 +55,18 @@ var $soapresponse = NULL; var $parent = 0; var $root_struct_name = array(); + var $header_struct_name = array(); var $curent_root_struct_name = ''; var $entities = array ( '&' => '&amp;', '<' => '&lt;', '>' => '&gt;', "'" => '&apos;', '"' => '&quot;' ); var $xml = ''; var $xml_encoding = ''; var $root_struct = array(); + var $header_struct = array(); var $curent_root_struct = 0; var $references = array(); var $need_references = array(); var $XMLSchemaVersion; - + function SOAP_Parser($xml, $encoding = 'UTF-8') { $this->setSchemaVersion(SOAP_XML_SCHEMA_VERSION); @@ -102,6 +104,7 @@ } else { // get final value $this->soapresponse = $this->buildResponse($this->root_struct[0]); + $this->soapheaders = $this->buildResponse($this->header_struct[0]); } xml_parser_free($parser); } else { @@ -173,26 +176,35 @@ // add current node's value if ($response) { #print "Parser creating: {$this->message[$pos]["name"]} type: {$this->message[$pos]["type"]}\n"; - $response = new SOAP_Value($this->message[$pos]["name"], $this->message[$pos]["type"] , $response); + $response = new SOAP_Value($this->message[$pos]["name"], $this->message[$pos]["type"] , $response, $this->message[$pos]["namespace"], $this->message[$pos]['type_namespace']); } else { #print "Parser creating: {$this->message[$pos]["name"]} type: {$this->message[$pos]["type"]}\n"; $this->debug('inside buildresponse: creating SOAP_Value '.$this->message[$pos]['name'].' of type '.$this->message[$pos]['type'].' and value: '.$this->message[$pos]['cdata']); - $response = new SOAP_Value($this->message[$pos]['name'], $this->message[$pos]['type'] , $this->message[$pos]['cdata']); + $response = new SOAP_Value($this->message[$pos]['name'], $this->message[$pos]['type'] , $this->message[$pos]['cdata'], $this->message[$pos]["namespace"], $this->message[$pos]['type_namespace']); + } + // handle header attribute that we need + if ($this->message[$pos]['actor']) { + $response->actor = $this->message[$pos]['actor']; + } + if ($this->message[$pos]['mustUnderstand']) { + $response->mustunderstand = $this->message[$pos]['mustUnderstand']; } - return $response; } // start-element handler function startElement($parser, $name, $attrs) { + global $SOAP_XMLSchema; // position in a total number of elements, starting from 0 // update class level pos $pos = $this->position++; // and set mine + $this->message[$pos] = array(); $this->message[$pos]['pos'] = $pos; - + $this->message[$pos]['id'] = ''; + // parent/child/depth determinations // depth = how many levels removed from root? @@ -211,13 +223,16 @@ $this->depth_array[$this->depth] = $pos; // set self as current parent $this->parent = $pos; - + $qname = new QName($name); // set status - if (preg_match("/:Envelope$/i",$name)) { + if (strcasecmp('envelope',$qname->name)==0) { $this->status = 'envelope'; - } elseif (preg_match("/:Header$/i",$name)) { + } elseif (strcasecmp('header',$qname->name)==0) { $this->status = 'header'; - } elseif (preg_match("/:Body$/i",$name)) { + $this->header_struct_name[] = $this->curent_root_struct_name = $qname->name; + $this->header_struct[] = $this->curent_root_struct = $pos; + $this->message[$pos]['type'] = 'Struct'; + } elseif (strcasecmp('body',$qname->name)==0) { $this->status = 'body'; // set method } elseif ($this->status == 'body') { @@ -225,7 +240,7 @@ // XXX this needs to be optimized, we loop through attrs twice now $can_root = TRUE; foreach ($attrs as $key => $value) { - if (preg_match('/:root$/i', $key) && !$value) { + if (stristr($key, ':root') && !$value) { $can_root = FALSE; } } @@ -233,12 +248,7 @@ $this->status = 'method'; if ($can_root) { - if (strpos($name,':') !== false) { - $this->root_struct_name[] = $this->curent_root_struct_name = substr(strrchr($name,':'),1); - } else { - $this->root_struct_name[] = $this->curent_root_struct_name = $name; - } - + $this->root_struct_name[] = $this->curent_root_struct_name = $qname->name; $this->root_struct[] = $this->curent_root_struct = $pos; $this->message[$pos]['type'] = 'Struct'; } @@ -248,62 +258,68 @@ $this->message[$pos]['status'] = $this->status; // set name - $this->message[$pos]['name'] = htmlspecialchars($name); + $this->message[$pos]['name'] = htmlspecialchars($qname->name); // set attrs $this->message[$pos]['attrs'] = $attrs; // get namespace - if (strpos($name,':') !== false) { - $namespace = substr($name,0,strpos($name,':')); - $this->message[$pos]['namespace'] = $namespace; - $this->default_namespace = $namespace; - } else { - $this->message[$pos]['namespace'] = $this->default_namespace; - } + $namespace = $qname->ns?$this->namespaces[$qname->ns]:$this->default_namespace; + $this->message[$pos]['namespace'] = $namespace; + $this->default_namespace = $namespace; // loop through atts, logging ns and type declarations foreach ($attrs as $key => $value) { // if ns declarations, add to class level array of valid namespaces - if (preg_match('/^xmlns:/i',$key)) { - $prefix = substr(strrchr($key,':'),1); + $kqn = new QName($key); + if ($kqn->ns == 'xmlns') { + $prefix = $kqn->name; - if ($prefix == 'xsd') { + if (in_array($value, $SOAP_XMLSchema)) { $this->setSchemaVersion($value); } - $this->namespaces[substr(strrchr($key,':'),1)] = $value; + $this->namespaces[$prefix] = $value; // set method namespace # XXX unused??? #if ($name == $this->curent_root_struct_name) { # $this->methodNamespace = $value; #} + + } elseif ($kqn->name == 'actor') { + $this->message[$pos]['actor'] = $value; + } elseif ($kqn->name == 'mustUnderstand') { + $this->message[$pos]['mustUnderstand'] = $value; + // if it's a type declaration, set type - } elseif (preg_match('/:type$/i',$key)) { - $type = substr(strrchr($value,':'),1); - - if (!$type) $type = $value; - $this->message[$pos]['type'] = $type; + } elseif ($kqn->name == 'type') { + $vqn = new QName($value); + $this->message[$pos]['type'] = $vqn->name; + $this->message[$pos]['type_namespace'] = $this->namespaces[$vqn->ns]; #print "set type for {$this->message[$pos]['name']} to {$this->message[$pos]['type']}\n"; // should do something here with the namespace of specified type? - } elseif (preg_match('/:arrayType$/i',$key)) { + + } elseif ($kqn->name == 'arrayType') { + $vqn = new QName($value); $this->message[$pos]['type'] = 'Array'; - $type = substr(strrchr($value,':'),1); - if (!$type) $type = $value; + $type = $vqn->name; $sa = strpos($type,'['); if ($sa > 0) { $this->message[$pos]['arraySize'] = split(',',substr($type,$sa+1, strlen($type)-$sa-2)); $type = substr($type, 0, $sa); } $this->message[$pos]['arrayType'] = $type; - } elseif (preg_match('/:offset$/i',$key)) { + + } elseif ($kqn->name == 'offset') { $this->message[$pos]['arrayOffset'] = split(',',substr($value, 1, strlen($value)-2)); - } elseif ($key == 'id') { + + } elseif ($kqn->name == 'id') { # save id to reference array $this->references[$value] = $pos; $this->message[$pos]['id'] = $value; - } elseif ($key == 'href' && $value[0] == '#') { + + } elseif ($kqn->name == 'href' && $value[0] == '#') { $ref = substr($value, 1); if (array_key_exists($ref,$this->references)) { # cdata, type, inval @@ -313,6 +329,7 @@ $this->message[$pos]['inval'] = &$this->message[$ref_pos]['inval']; } else { # reverse reference, store in 'need reference' + if (!is_array($this->need_references[$ref])) $this->need_references[$ref] = array(); $this->need_references[$ref][] = $pos; } } @@ -326,6 +343,7 @@ $pos = $this->depth_array[$this->depth]; // bring depth down a notch $this->depth--; + $qname = new QName($name); // get type if not explicitly declared in an xsi:type attribute // XXX check on integrating wsdl validation here @@ -356,9 +374,7 @@ // if tag we are currently closing is the method wrapper if ($pos == $this->curent_root_struct) { $this->status = 'body'; - } elseif (stristr($name,':Body')) { - $this->status = 'header'; - } elseif (stristr($name,':Header')) { + } elseif ($qname->name == 'Body' || $qname->name == 'Header') { $this->status = 'envelope'; } @@ -401,9 +417,8 @@ { if ($this->fault) { return true; - } else { - return false; } + return false; } // have this return a soap_val object @@ -411,12 +426,21 @@ { if ($this->soapresponse) { return $this->soapresponse; - } else { - $this->debug('ERROR: did not successfully eval the msg'); - $this->fault = true; + } + $this->debug('ERROR: did not successfully eval the msg'); + $this->fault = true; + return new SOAP_Value('Fault','Struct', array(new SOAP_Value('faultcode','string','SOAP-ENV:Parser'), new SOAP_Value('faultstring','string',"couldn't build response"))); + } - return new SOAP_Value('Fault','Struct', array(new SOAP_Value('faultcode','string','SOAP-ENV:Parser'), new SOAP_Value('faultstring','string',"couldn't build response"))); + // have this return a soap_val object + function getHeaders() + { + if ($this->soapheaders) { + return $this->soapheaders; } + // we don't fault if there are no headers + // that can be handled by the app if necessary + return NULL; } function debug($string) Index: pear/SOAP/Server.php diff -u pear/SOAP/Server.php:1.8 pear/SOAP/Server.php:1.9 --- pear/SOAP/Server.php:1.8 Tue Mar 19 01:47:16 2002 +++ pear/SOAP/Server.php Sat Mar 30 18:13:21 2002 @@ -17,7 +17,7 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: Server.php,v 1.8 2002/03/19 06:47:16 shane Exp $ +// $Id: Server.php,v 1.9 2002/03/30 23:13:21 shane Exp $ // require_once('SOAP/globals.php'); @@ -35,7 +35,7 @@ * originaly based on SOAPx4 by Dietrich Ayala http://dietrich.ganx4.com/soapx4 * * @access public -* @version $Id: Server.php,v 1.8 2002/03/19 06:47:16 shane Exp $ +* @version $Id: Server.php,v 1.9 2002/03/30 23:13:21 shane Exp $ * @package SOAP::Client * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates * @author Dietrich Ayala <dietrich@ganx4.com> Original Author @@ -109,18 +109,29 @@ var $result = 'successful'; // for logging interop results to db + var $endpoint = ''; // the uri to ME! + function SOAP_Server($debug = SOAP_DEBUG) { // turn on debugging? $this->debug_flag = $debug; } // parses request and posts response - function service($data) + function service($data, $endpoint = '', $test = FALSE) { global $_ENV, $_SERVER; + // figure out our endpoint + $this->endpoint = $endpoint; + if (!$this->endpoint) { + // we'll try to build our endpoint + $this->endpoint = 'http://'.$_SERVER['SERVER_NAME']; + if ($_SERVER['SERVER_PORT']) $this->endpoint .= ':'.$_SERVER['SERVER_PORT']; + $this->endpoint .= $PHP_SELF; + } + // if this is not a POST with Content-Type text/xml, try to return a WSDL file - if ($_SERVER['REQUEST_METHOD'] != 'POST' || - strncmp($_ENV['HTTP_CONTENT_TYPE'], 'text/xml', 8) != 0) { + if (!$test && ($_SERVER['REQUEST_METHOD'] != 'POST' || + strncmp($_ENV['HTTP_CONTENT_TYPE'], 'text/xml', 8) != 0)) { // this is not possibly a valid soap request, try to return a WSDL file $this->makeFault('Server',"Invalid SOAP request"); $response = $this->fault(); @@ -158,6 +169,55 @@ print $payload; } + function callMethod($methodname, &$args) { + if ($args) { + // call method with parameters + $this->debug("calling '$methodname' with params"); + if (is_object($this->soapobject)) { + return call_user_func_array(array(&$this->soapobject, $methodname),$args); + } + return call_user_func_array($methodname,$args); + } + + // call method w/ no parameters + $this->debug("calling $methodname w/ no params"); + if (is_object($this->soapobject)) { + return call_user_func(array(&$this->soapobject, $methodname)); + } + return call_user_func($methodname); + } + + // create soap_val object w/ return values from method, use method signature to determine type + function buildResult(&$method_response, &$return_type, $return_name='return', $namespace = '') + { + $class = get_class($method_response) ; + if ($class == 'soap_value' || $class == 'soap_header') { + $return_val = array($method_response); + } else { + $this->debug("creating new SOAP_Value to return, of type $return_type"); + if (is_array($return_type) && is_array($method_response)) { + $i = 0; + + foreach ($return_type as $key => $type) { + if (is_numeric($key)) $key = 'item'; + $return_val[] = new SOAP_Value($key,$type,$method_response[$i++],$namespace); + } + } else { + if (is_array($return_type)) { + $keys = array_keys($return_type); + if (!is_numeric($keys[0])) $return_name = $keys[0]; + $values = array_values($return_type); + $return_type = $values[0]; + } + $return_val = array(new SOAP_Value($return_name,$return_type,$method_response, $namespace)); + } + } + if ($this->debug_flag) { + $this->debug($return_val->debug_data); + } + return $return_val; + } + function parseRequest($data='') { global $_ENV, $_SERVER; @@ -196,138 +256,162 @@ // return soapresp return $this->fault(); // else successfully parsed request into SOAP_Value object - } else { - // evaluate message, getting back a SOAP_Value object - $this->debug('calling parser->getResponse()'); - $this->methodname = $parser->root_struct_name[0]; - $this->debug("method name: $this->methodname"); - - // does method exist? - if (!$this->methodname || !$this->validateMethod($this->methodname)) { - // "method not found" fault here - $this->debug("method '$this->methodname' not found!"); - $this->result = 'fault: method not found'; - $this->makeFault('Server',"method '$this->methodname' not defined in service '$this->service'"); - return $this->fault(); - } - $this->debug("method '$this->methodname' exists"); - + } + // parser debug + $this->debug($parser->debug_data); - if (!$request_val = $parser->getResponse()) { - return $this->fault(); - } - // parser debug - $this->debug($parser->debug_data); + /* set namespaces + if ($parser->namespaces['xsd'] != '') { + //print 'got '.$parser->namespaces['xsd']; + global $SOAP_namespaces; + $this->XMLSchemaVersion = $parser->namespaces['xsd']; + $tmpNS = array_flip($SOAP_namespaces); + $tmpNS['xsd'] = $this->XMLSchemaVersion; + $tmpNS['xsi'] = $this->XMLSchemaVersion.'-instance'; + $SOAP_namespaces = array_flip($tmpNS); + }*/ - /* set namespaces - if ($parser->namespaces['xsd'] != '') { - //print 'got '.$parser->namespaces['xsd']; - global $SOAP_namespaces; - $this->XMLSchemaVersion = $parser->namespaces['xsd']; - $tmpNS = array_flip($SOAP_namespaces); - $tmpNS['xsd'] = $this->XMLSchemaVersion; - $tmpNS['xsi'] = $this->XMLSchemaVersion.'-instance'; - $SOAP_namespaces = array_flip($tmpNS); - }*/ - - if (strcasecmp(get_class($request_val),'SOAP_Value')==0) { - // verify that SOAP_Value objects in request match the methods signature - if ($this->verifyMethod($request_val)) { - $this->debug("request data - name: $request_val->name, type: $request_val->type, value: $request_val->value"); - // need to set special error detection inside the value class - // so as to differentiate between no params passed, and an error decoding - $request_data = $request_val->decode(); - $this->debug($request_val->debug_data); - $this->debug("request data: $request_data"); - $this->debug("about to call method '$this->methodname'"); + //******************************************************* + // handle message headers - // if there are parameters to pass - if ($request_data) { - // call method with parameters - $this->debug("calling '$this->methodname' with params"); - if (is_object($this->soapobject)) { - $method_response = call_user_func_array(array(&$this->soapobject, $this->methodname),$request_data); - } else { - $method_response = call_user_func_array($this->methodname,$request_data); - } - } else { - // call method w/ no parameters - $this->debug("calling $this->methodname w/ no params"); - if (is_object($this->soapobject)) { - $method_response = call_user_func(array(&$this->soapobject, $this->methodname)); - } else { - $method_response = call_user_func($this->methodname); - } - } + $request_headers = $parser->getHeaders(); + $header_results = array(); - $this->debug("done calling method: $this->methodname"); + if ($request_headers) { + if (get_class($request_headers) != 'soap_value') { + // debug + $this->debug("ERROR: parser did not return SOAP_Value object: $request_headers ".get_class($request_headers)); + $this->result = "fault: parser did not return SOAP_Value object: $request_headers"; - // if return val is SOAP_Message - if (strcasecmp(get_class($method_response),'SOAP_Message')==0) { - if (eregi('fault',$method_response->value->name)) { + // return fault + $this->makeFault('Server',"parser did not return SOAP_Value object: $request_headers"); + return $this->fault(); + } + if ($request_headers->value) { + // handle headers now + foreach ($request_headers->value as $header_val) { + $f_exists = $this->validateMethod($header_val->name); + $myactor = ( + $header_val->actor == 'http://schemas.xmlsoap.org/soap/actor/next' || + $header_val->actor == $this->endpoint); + + if (!$f_exists && $header_val->mustunderstand && $myactor) { + $this->makeFault('Server',"I don't understand header $header_val->name."); + return $this->fault(); + } + + // we only handle the header if it's for us + $isok = $f_exists && $myactor; + + if ($isok) { + # call our header now! + $header_method = $header_val->name; + $header_data = array($header_val->decode()); + // if there are parameters to pass + $hr = $this->callMethod($header_method, $header_data); + # if they return a fault, then it's all over! + if (strcasecmp(get_class($hr),'SOAP_Message')==0) { + if (eregi('fault',$hr->value->name)) { $this->fault = true; + return $hr; } - $return_msg = $method_response; - } else { - // if return val is SOAP_Value object - if (strcasecmp(get_class($method_response),'SOAP_Value')==0) { - $return_val = array($method_response); - - // create soap_val object w/ return values from method, use method signature to determine type - } else { - $this->debug("creating new SOAP_Value to return, of type $this->return_type"); - if (is_array($this->return_type) && is_array($method_response)) { - $i = 0; - - foreach ($this->return_type as $key => $type) { - if (is_numeric($key)) $key = 'item'; - $return_val[] = new SOAP_Value($key,$type,$method_response[$i++]); - } - } else { - $return_name = 'return'; - if (is_array($this->return_type)) { - $keys = array_keys($this->return_type); - if (!is_numeric($keys[0])) $return_name = $keys[0]; - $values = array_values($this->return_type); - $this->return_type = $values[0]; - } - $return_val = array(new SOAP_Value($return_name,$this->return_type,$method_response)); - } - } - if ($this->debug_flag) { - $this->debug($return_val->debug_data); - } - - $this->debug("creating return soap_msg object: ".$this->methodname.'Response'); - // response object is a soap_msg object - $return_msg = new SOAP_Message($this->methodname.'Response',$return_val,"$this->service"); + # hmm, they returned a soap_message, we have to + # de-messagize it so we can append stuff. } + $header_results[] = array_shift($this->buildResult($hr, $this->return_type, $header_method, $header_val->namespace)); + } + } + } + } - if ($this->debug_flag) { - $return_msg->debug_flag = true; - } + //******************************************************* + // handle the method call + + // evaluate message, getting back a SOAP_Value object + $this->debug('calling parser->getResponse()'); + $this->methodname = $parser->root_struct_name[0]; + $this->debug("method name: $this->methodname"); + + // does method exist? + if (!$this->methodname || !$this->validateMethod($this->methodname)) { + // "method not found" fault here + $this->debug("method '$this->methodname' not found!"); + $this->result = 'fault: method not found'; + $this->makeFault('Server',"method '$this->methodname' not defined in service '$this->service'"); + return $this->fault(); + } + $this->debug("method '$this->methodname' exists"); - $this->result = 'successful'; - return $return_msg; - } else { - // debug - $this->debug('ERROR: request not verified against method signature'); - $this->result = 'fault: request failed validation against method signature'; + if (!$request_val = $parser->getResponse()) { + return $this->fault(); + } + if (strcasecmp(get_class($request_val),'SOAP_Value') != 0) { + // debug + $this->debug("ERROR: parser did not return SOAP_Value object: $request_val ".get_class($request_val)); + $this->result = "fault: parser did not return SOAP_Value object: $request_val"; - // return soapresp - return $this->fault(); - } - } else { - // debug - $this->debug("ERROR: parser did not return SOAP_Value object: $request_val ".get_class($request_val)); - $this->result = "fault: parser did not return SOAP_Value object: $request_val"; + // return fault + $this->makeFault('Server',"parser did not return SOAP_Value object: $request_val"); + return $this->fault(); + } + + // verify that SOAP_Value objects in request match the methods signature + if (!$this->verifyMethod($request_val)) { + // debug + $this->debug('ERROR: request not verified against method signature'); + $this->result = 'fault: request failed validation against method signature'; - // return fault - $this->makeFault('Server',"parser did not return SOAP_Value object: $request_val"); - return $this->fault(); + // return soapresp + return $this->fault(); + } + + $this->debug("request data - name: $request_val->name, type: $request_val->type, value: $request_val->value"); + // need to set special error detection inside the value class + // so as to differentiate between no params passed, and an error decoding + $request_data = $request_val->decode(); + $this->debug($request_val->debug_data); + $this->debug("request data: $request_data"); + $this->debug("about to call method '$this->methodname'"); + + $method_response = $this->callMethod($this->methodname, $request_data); + + $this->debug("done calling method: $this->methodname"); + + // if return val is SOAP_Message + if (strcasecmp(get_class($method_response),'SOAP_Message')==0) { + // XXX this needs to be done better + if (stristr($method_response->value->name,'fault')) { + $this->fault = true; + } + return $method_response; + } + + // get the method result + $return_val = $this->buildResult($method_response, $this->return_type, $this->methodname); + + + $this->debug("creating return soap_msg object: ".$this->methodname.'Response'); + + // response object is a soap_msg object + $return_msg = new SOAP_Message(); + + // add response headers + if (count($header_results) > 0) { + foreach($header_results as $hr) { + $return_msg->addHeader($hr); } } + + $return_msg->method($this->methodname.'Response',$return_val,$this->service); + + if ($this->debug_flag) { + $return_msg->debug_flag = true; + } + + $this->result = 'successful'; + + return $return_msg; } function verifyMethod($request) @@ -403,14 +487,14 @@ } // get string return type from dispatch map - function getReturnType() + function getReturnType($methodname) { - if (is_array($this->dispatch_map[$this->methodname]['out'])) { - if (count($this->dispatch_map[$this->methodname]['out']) > 1) { + if (is_array($this->dispatch_map[$methodname]['out'])) { + if (count($this->dispatch_map[$methodname]['out']) > 1) { $this->debug("got multiple return types from dispatch map: '$type'"); - return $this->dispatch_map[$this->methodname]['out']; + return $this->dispatch_map[$methodname]['out']; } - $type = array_shift($this->dispatch_map[$this->methodname]['out']); + $type = array_shift($this->dispatch_map[$methodname]['out']); $this->debug("got return type from dispatch map: '$type'"); return $type; } @@ -462,7 +546,8 @@ // set up a fault function fault() { - return new SOAP_Message('Fault', + $msg = new SOAP_Message(); + $msg->method('Fault', array( 'faultcode' => $this->fault_code, 'faultstring' => $this->fault_str, @@ -471,6 +556,7 @@ ), 'http://schemas.xmlsoap.org/soap/envelope/' ); + return $msg; } function makeFault($fault_code, $fault_string) Index: pear/SOAP/Value.php diff -u pear/SOAP/Value.php:1.17 pear/SOAP/Value.php:1.18 --- pear/SOAP/Value.php:1.17 Tue Mar 19 01:47:16 2002 +++ pear/SOAP/Value.php Sat Mar 30 18:13:21 2002 @@ -17,7 +17,7 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: Value.php,v 1.17 2002/03/19 06:47:16 shane Exp $ +// $Id: Value.php,v 1.18 2002/03/30 23:13:21 shane Exp $ // require_once 'SOAP/Base.php'; require_once 'SOAP/globals.php'; @@ -31,7 +31,7 @@ * originaly based on SOAPx4 by Dietrich Ayala http://dietrich.ganx4.com/soapx4 * * @access public -* @version $Id: Value.php,v 1.17 2002/03/19 06:47:16 shane Exp $ +* @version $Id: Value.php,v 1.18 2002/03/30 23:13:21 shane Exp $ * @package SOAP::Client * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates * @author Dietrich Ayala <dietrich@ganx4.com> Original Author @@ -93,7 +93,7 @@ * @var string */ var $namespace = ''; - + var $type_namespace = ''; /** * * @var string @@ -133,7 +133,8 @@ $this->name = $name; $this->wsdl = $wsdl; - $this->type = $this->_getSoapType($value, $type); + $this->type_namespace = $type_namespace; + $this->type = $this->_getSoapType($value, $type, $name, $type_namespace); #$this->debug("Entering SOAP_Value - name: '$name' type: '$type' value: $value"); @@ -152,7 +153,7 @@ $qname = new QName($type); $this->type = $qname->name; $this->type_prefix = $qname->ns; - + } elseif ($type_namespace) { if (!isset($SOAP_namespaces[$type_namespace])) { @@ -241,7 +242,7 @@ // else make obj and serialize } else { #$type = $this->arrayType; - #$type = $this->_getSoapType($v, $type); + $type = $this->_getSoapType($v, $type, $k); $new_val = new SOAP_Value('item', $this->arrayType, $v); $this->debug($new_val->debug_data); $this->value[] = $new_val; @@ -268,7 +269,7 @@ // else make obj and serialize } else { $type = NULL; - $type = $this->_getSoapType($v, $type); + $type = $this->_getSoapType($v, $type, $k); $new_val = new SOAP_Value($k, $type, $v); $this->debug($new_val->debug_data); $this->value[] = $new_val; @@ -321,7 +322,7 @@ } else { foreach ($value as $array_val) { #$array_types[$array_val->type] = 1; - $xml .= $this->serializeval($array_val); + $xml .= $array_val->serialize(); } } } @@ -345,62 +346,54 @@ if (is_int($soapval->name)) { $soapval->name = 'item'; + $soapval->prefix = ''; } - $xml = ''; + if ($soapval->prefix && $soapval->type_prefix) { + $xmlout_name = "$soapval->prefix:$soapval->name"; + $xmlout_type = "$soapval->type_prefix:$soapval->type"; + } else + if ($soapval->type_prefix) { + $xmlout_name = $soapval->name; + $xmlout_type = "$soapval->type_prefix:$soapval->type"; + } elseif ($soapval->prefix) { + $xmlout_name = "$soapval->prefix:$soapval->name"; + } else { + $xmlout_name = $soapval->name; + } + $xmlout_value = ''; + $xmlout_offset = ''; switch ($soapval->type_code) { case SOAP_VALUE_STRUCT: // struct - $this->debug('got a struct'); - - # XXX we should be able to do this, but ASP.Net fails if we do - #if ($soapval->prefix && $soapval->type_prefix) { - # $xml .= "<$soapval->prefix:$soapval->name xsi:type=\"$soapval->type_prefix:$soapval->type\">\n"; - #} else - if ($soapval->type_prefix) { - $xml .= "<$soapval->name xsi:type=\"$soapval->type_prefix:$soapval->type\">\n"; - } elseif ($soapval->prefix) { - $xml .= "<$soapval->prefix:$soapval->name>\n"; - } else { - $xml .= "<$soapval->name>\n"; - } if (is_array($soapval->value)) { foreach ($soapval->value as $k => $v) { - $xml .= $this->serializeval($v); + $xmlout_value .= $v->serialize($v); } } - if ($soapval->type_prefix) { - $xml .= "</$soapval->name>\n"; - } else if ($soapval->prefix) { - $xml .= "</$soapval->prefix:$soapval->name>\n"; - } else { - $xml .= "</$soapval->name>\n"; - } break; case SOAP_VALUE_ARRAY: // array - $offset = ''; - + $xmlout_type = 'SOAP-ENC:Array'; // XXX this will be slow on larger array's. We can probably move this // out to an external helper function. Basicly, it flattens array's to allow us // to serialize multi-dimensional array's - $numtypes = $this->_getArrayType($soapval->value, $array_type, $ar_size, $xml); + $numtypes = $this->_getArrayType($soapval->value, $array_type, $ar_size, $xmlout_value); #$numtypes = 0; $array_type_prefix = ''; if ($numtypes != 1) { - $xml =''; foreach ($soapval->value as $array_val) { $array_types[$array_val->type] = 1; - $xml .= $this->serializeval($array_val); + $xmlout_value .= $array_val->serialize(); } $ar_size = count($soapval->value); $numtypes = count($array_types); $array_type = $array_val->type; $array_type_prefix = $array_val->type_prefix; - $offset = " SOAP-ENC:offset=\"[0]\""; + $xmlout_offset = " SOAP-ENC:offset=\"[0]\""; } if ($numtypes > 1) { $array_type = 'xsd:ur-type'; @@ -411,30 +404,21 @@ $array_type = $array_type_prefix . ':' . $array_type; } } - - $xml = "<$soapval->name xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_type."[$ar_size]\"$offset>\n".$xml."</$soapval->name>\n"; + $xmlout_arrayType = " SOAP-ENC:arrayType=\"".$array_type."[$ar_size]\""; break; case SOAP_VALUE_SCALAR: - # XXX we should be able to do this, but ASP.Net fails if we do - #if ($soapval->prefix && $soapval->type_prefix) { - # $xml .= "<$soapval->prefix:$soapval->name xsi:type=\"$soapval->type_prefix:$soapval->type\">$soapval->value</$soapval->prefix:$soapval->name>\n"; - #} else - if ($soapval->type_prefix) { - $xml .= "<$soapval->name xsi:type=\"$soapval->type_prefix:$soapval->type\">$soapval->value</$soapval->name>\n"; - # XXX we should be able to do this, but ASP.Net fails if we do - #} elseif ($soapval->prefix) { - # $xml .= "<$soapval->prefix:$soapval->name>$soapval->value</$soapval->prefix:$soapval->name>\n"; - } else - if ($soapval->type) { - $xml .= "<$soapval->name xsi:type=\"$soapval->type\">$soapval->value</$soapval->name>\n"; - } else { - $xml .= "<$soapval->name>$soapval->value</$soapval->name>\n"; - } + $xmlout_value = $soapval->value; break; default: break; } + + if ($xmlout_type) $xmlout_type = " xsi:type=\"$xmlout_type\""; + $xml = "\n<{$xmlout_name}{$xmlout_type}{$xmlout_arrayType}{$xmlout_offset}". + $this->xmlout_extra.">". + $xmlout_value."</$xmlout_name>\n"; + return $xml; } @@ -570,32 +554,44 @@ * @return string type - soap type * @access private */ - function _getSoapType(&$value, &$type) { + function _getSoapType(&$value, &$type, $name, $type_namespace='') { $doconvert = FALSE; - if (0 && $this->wsdl) { + if ($this->wsdl) { # see if it's a complex type so we can deal properly with SOAPENC:arrayType - if (!$type && $this->name) { + if (!$type && $name) { # XXX TODO: # look up the name in the wsdl and validate the type - $this->debug("SOAP_VALUE no type for $this->name!"); - } else if ($type) { + $this->debug("SOAP_VALUE no type for $name!"); + if ($this->type) { + foreach ($this->wsdl->complexTypes as $types) { + if (array_key_exists($this->type, $types) && + array_key_exists($name, $types[$this->type]['elements'])) { + $type = $types[$this->type]['elements']['type']; + return $type; + } + } + } + } else if ($type && $type_namespace) { # XXX TODO: # this code currently handles only one way of encoding array types in wsdl # need to do a generalized function to figure out complex types - if (array_key_exists($type, $this->wsdl->complexTypes)) { - if ($this->arrayType = $this->wsdl->complexTypes[$type]['arrayType']) { + $p = $this->wsdl->ns[$type_namespace]; + if ($p && + array_key_exists($p, $this->wsdl->complexTypes) && + array_key_exists($type, $this->wsdl->complexTypes[$p])) { + if ($this->arrayType = $this->wsdl->complexTypes[$p][$type]['arrayType']) { $type = 'Array'; - } else if ($this->wsdl->complexTypes[$type]['order']=='sequence' && - array_key_exists('elements', $this->wsdl->complexTypes[$type])) { - reset($this->wsdl->complexTypes[$type]['elements']); + } else if ($this->wsdl->complexTypes[$p][$type]['order']=='sequence' && + array_key_exists('elements', $this->wsdl->complexTypes[$p][$type])) { + reset($this->wsdl->complexTypes[$p][$type]['elements']); # assume an array - if (count($this->wsdl->complexTypes[$type]['elements']) == 1) { - $arg = current($this->wsdl->complexTypes[$type]['elements']); + if (count($this->wsdl->complexTypes[$p][$type]['elements']) == 1) { + $arg = current($this->wsdl->complexTypes[$p][$type]['elements']); $this->arrayType = $arg['type']; $type = 'Array'; } else { - foreach($this->wsdl->complexTypes[$type]['elements'] as $element) { + foreach($this->wsdl->complexTypes[$p][$type]['elements'] as $element) { if ($element['name'] == $type) { $this->arrayType = $element['type']; $type = $element['type']; @@ -603,13 +599,11 @@ } } } + return $type; } } } if (!$type || !$this->verifyType($type)) { - if ($type && $this->wsdl && array_key_exists($type, $this->wsdl->complexTypes)) { - # do nothing, this preserves our complex types - } else if (is_object($value)) { # allows for creating special classes to handle soap types $type = get_class($value); @@ -633,6 +627,7 @@ # idea what the type realy is, we have to try to figure it out # this is the best we can do if the user did not use the SOAP_Value class if ($type == 'string') $doconvert = TRUE; + elseif ($type == 'NULL') $type = ''; } } # we have the type, handle any value munging we need Index: pear/SOAP/WSDL.php diff -u pear/SOAP/WSDL.php:1.15 pear/SOAP/WSDL.php:1.16 --- pear/SOAP/WSDL.php:1.15 Wed Mar 20 21:13:29 2002 +++ pear/SOAP/WSDL.php Sat Mar 30 18:13:21 2002 @@ -17,7 +17,7 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: WSDL.php,v 1.15 2002/03/21 02:13:29 shane Exp $ +// $Id: WSDL.php,v 1.16 2002/03/30 23:13:21 shane Exp $ // require_once 'SOAP/Base.php'; require_once 'SOAP/Fault.php'; @@ -38,7 +38,7 @@ * implement IDL type syntax declaration so we can generate WSDL * * @access public -* @version $Id: WSDL.php,v 1.15 2002/03/21 02:13:29 shane Exp $ +* @version $Id: WSDL.php,v 1.16 2002/03/30 23:13:21 shane Exp $ * @package SOAP::Client * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates * @author Dietrich Ayala <dietrich@ganx4.com> Original Author @@ -412,7 +412,10 @@ $this->wsdl->complexTypes[$this->schema] = array(); break; case 'complexType': - if ($parent_tag == 'schema') { + if ($parent_tag == 'schema' && + # XXX this check if funky, but there are wsdl's with redefinitions, need to find out why. + !array_key_exists($attrs['name'], $this->wsdl->complexTypes[$this->schema])) { + $this->currentElement = $attrs['name']; if ($attrs['base']) { $qn = new QName($attrs['base']); @@ -431,9 +434,12 @@ $attrs['namespace'] = $this->wsdl->namespaces[$qname->ns]; } if ($parent_tag == 'schema') { - $this->currentElement = $attrs['name']; - $this->wsdl->complexTypes[$this->schema][$this->currentElement] = $attrs; - $this->schemaStatus = 'complexType'; + # XXX this check if funky, but there are wsdl's with redefinitions, need to find out why. + if (!array_key_exists($attrs['name'], $this->wsdl->complexTypes[$this->schema])) { + $this->currentElement = $attrs['name']; + $this->wsdl->complexTypes[$this->schema][$this->currentElement] = $attrs; + $this->schemaStatus = 'complexType'; + } } else { if ($this->wsdl->complexTypes[$this->schema][$this->currentElement]['order'] == 'sequence' && $this->wsdl->complexTypes[$this->schema][$this->currentElement]['base'] == 'Array') { Index: pear/SOAP/globals.php diff -u pear/SOAP/globals.php:1.10 pear/SOAP/globals.php:1.11 --- pear/SOAP/globals.php:1.10 Wed Mar 20 21:13:29 2002 +++ pear/SOAP/globals.php Sat Mar 30 18:13:21 2002 @@ -17,7 +17,7 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: globals.php,v 1.10 2002/03/21 02:13:29 shane Exp $ +// $Id: globals.php,v 1.11 2002/03/30 23:13:21 shane Exp $ // /** @@ -25,7 +25,7 @@ * * @module globals * @package SOAP -* @version $Id: globals.php,v 1.10 2002/03/21 02:13:29 shane Exp $ +* @version $Id: globals.php,v 1.11 2002/03/30 23:13:21 shane Exp $ * @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more * @author Dietrich Ayala <dietrich@ganx4.com> Original Author */ @@ -37,7 +37,7 @@ * * @const SOAP_DEBUG */ -define('SOAP_DEBUG', true); +define('SOAP_DEBUG', false); if (!function_exists('version_compare') || version_compare(phpversion(), '4.1', '<')) { @@ -71,22 +71,8 @@ define('SOAP_INTEROPORG', 'http://soapinterop.org/xsd'); $SOAP_XMLSchema = array(SOAP_XML_SCHEMA_VERSION, SOAP_XML_SCHEMA_1999); + // load types into typemap array -/* -$SOAP_typemap['http://www.w3.org/2001/XMLSchema'] = array( - 'string','boolean','float','double','decimal','duration','dateTime','time', - 'date','gYearMonth','gYear','gMonthDay','gDay','gMonth','hexBinary','base64Binary', - // derived datatypes - 'normalizedString','token','language','NMTOKEN','NMTOKENS','Name','NCName','ID', - 'IDREF','IDREFS','ENTITY','ENTITIES','integer','nonPositiveInteger', - 'negativeInteger','long','int','short','byte','nonNegativeInteger', - 'unsignedLong','unsignedInt','unsignedShort','unsignedByte','positiveInteger'); -$SOAP_typemap['http://www.w3.org/1999/XMLSchema'] = array( - 'i4','int','boolean','string','double','float','dateTime', - 'timeInstant','base64Binary','base64','ur-type'); -$SOAP_typemap[SOAP_INTEROPORG] = array('SOAPStruct'); -$SOAP_typemap[SOAP_SCHEMA_ENCODING] = array('base64','array','Array'); -*/ $SOAP_typemap[SOAP_XML_SCHEMA_VERSION] = array( 'string' => 'string', 'boolean' => 'boolean', Index: pear/SOAP/Transport/HTTP.php diff -u pear/SOAP/Transport/HTTP.php:1.8 pear/SOAP/Transport/HTTP.php:1.9 --- pear/SOAP/Transport/HTTP.php:1.8 Tue Mar 5 11:55:29 2002 +++ pear/SOAP/Transport/HTTP.php Sat Mar 30 18:13:21 2002 @@ -16,7 +16,7 @@ // | Authors: Shane Caraveo <Shane@Caraveo.com> | // +----------------------------------------------------------------------+ // -// $Id: HTTP.php,v 1.8 2002/03/05 16:55:29 uw Exp $ +// $Id: HTTP.php,v 1.9 2002/03/30 23:13:21 shane Exp $ // require_once 'SOAP/globals.php'; @@ -26,7 +26,7 @@ * HTTP Transport for SOAP * * @access public -* @version $Id: HTTP.php,v 1.8 2002/03/05 16:55:29 uw Exp $ +* @version $Id: HTTP.php,v 1.9 2002/03/30 23:13:21 shane Exp $ * @package SOAP::Transport::HTTP * @author Shane Caraveo <shane@php.net> */ @@ -189,6 +189,9 @@ { if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $this->incoming_payload, $match)) { $this->response = preg_replace("/[\r|\n]/", '', $match[2]); + // find the response error + //if (preg_match("/^HTTP\/1\.. (\d+).*/s",$match[1],$status) && + // $status[1] != 200) return FALSE; // if no content, return false return strlen($this->response) > 0; } @@ -235,7 +238,7 @@ $fp = fsockopen($this->urlparts['host'], $this->urlparts['port'], $this->errno, $this->errmsg); } if (!$fp) { - $this->errmsg = "Unable to connect to {$this->urlparts['host']}:{$this->urlparts['port']}"; + $this->errmsg = "Connect Error to {$this->urlparts['host']}:{$this->urlparts['port']}"; return $this->raiseSoapFault($this->errmsg); } if (!fputs($fp, $this->outgoing_payload, strlen($this->outgoing_payload))) { Index: pear/SOAP/Header.php +++ pear/SOAP/Header.php <?php // // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2002 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.02 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more | // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // // $Id: Header.php,v 1.1 2002/03/30 23:13:21 shane Exp $ // require_once 'SOAP/Base.php'; require_once 'SOAP/globals.php'; require_once 'SOAP/Value.php'; /** * SOAP::Value * this class converts values between PHP and SOAP * * originaly based on SOAPx4 by Dietrich Ayala http://dietrich.ganx4.com/soapx4 * * @access public * @version $Id: Header.php,v 1.1 2002/03/30 23:13:21 shane Exp $ * @package SOAP::Client * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates * @author Dietrich Ayala <dietrich@ganx4.com> Original Author */ class SOAP_Header extends SOAP_Value { var $actor = NULL; var $mustunderstand = 0; /** * * * @param string name of the soap-value <value_name> * @param mixed soap header value * @param int namespace * @param mixed actor * @param mixed wsdl */ function SOAP_Header($name = '', $type, $value = NULL, $namespace = NULL, $mustunderstand = 0, $actor = 'http://schemas.xmlsoap.org/soap/actor/next', $wsdl = NULL) { parent::SOAP_Value($name, $type, $value, $namespace, NULL, $wsdl); $this->actor = $actor; $this->mustunderstand = (int)$mustunderstand; $this->xmlout_extra =" SOAP-ENV:actor=\"$actor\" SOAP-ENV:mustUnderstand=\"$mustunderstand\""; } } ?>
« previous php.pear.cvs (#2917) next »