value = CreateObject('phpgwapi.soapval',$method,"struct",$params,$method_namespace); if(is_array($new_namespaces)) { global $namespaces; $i = count($namespaces); while(list($v) = each($new_namespaces)) /* foreach($new_namespaces as $v) */ { $namespaces[$v] = "ns".$i++; } $this->namespaces = $namespaces; } $this->payload = ''; $this->debug_flag = False; $this->debug_str = "entering soapmsg() with soapval ".$this->value->name."\n"; } function make_envelope($payload) { global $namespaces; while(list($k,$v) = each($namespaces)) /* foreach($namespaces as $k => $v) */ { $ns_string .= " xmlns:$v=\"$k\""; } return "\n" . $payload . "\n"; } function make_body($payload) { return "\n" . $payload . "\n"; } function createPayload() { $value = $this->value; $payload = $this->make_envelope($this->make_body($value->serialize())); $this->debug($value->debug_str); $payload = "\n".$payload; if($this->debug_flag) { $payload .= $this->serializeDebug(); } $this->payload = str_replace("\n","\r\n", $payload); } function serialize() { if($this->payload == '') { $this->createPayload(); return $this->payload; } else { return $this->payload; } } // returns a soapval object function parseResponse($data) { $this->debug("Entering parseResponse()"); //$this->debug(" w/ data $data"); // get rid of headers here $clean_data = ereg_replace("\r\n","\n", $data); if(ereg("^.*\r\n\r\n",$data)) { $this->debug("getting rid of headers, stringlen: ".strlen($data)); $clean_data = ereg_replace("^.*\r\n\r\n","", $data); $this->debug("cleaned data, stringlen: ".strlen($clean_data)); } elseif(ereg("^.*\n\n",$data)) { $this->debug("getting rid of headers, stringlen: ".strlen($data)); $clean_data = ereg_replace("^.*\n\n","", $data); $this->debug("cleaned data, stringlen: ".strlen($clean_data)); } // if response is a proper http response, and is not a 200 if(ereg("^HTTP",$clean_data) && !ereg("200$", $clean_data)) { // get error data $errstr = substr($clean_data, 0, strpos($clean_data, "\n")-1); // return fault return CreateObject('phpgwapi.soapval', "fault", "SOAPStruct", array( CreateObject('phpgwapi.soapval',"faultcode","string","SOAP-MSG"), CreateObject('phpgwapi.soapval',"faultstring","string","HTTP error") ) ); } $this->debug("about to create parser instance w/ data: $clean_data"); // parse response $response = CreateObject('phpgwapi.soap_parser',$clean_data); // return array of parameters $ret = $response->get_response(); $this->debug($response->debug_str); return $ret; } // dbg function debug($string) { if($this->debug_flag) { $this->debug_str .= "$string\n"; } } // preps debug data for encoding into soapmsg function serializeDebug() { if($this->debug_flag) { return "\n"; } else { return ''; } } } ?>