public function send(BindingOperation $bOperation, array $params, array $headers = array()) { $xml = $this->buildMessage($params, $bOperation, $bOperation->getInput(), $headers); $response = $this->getTransport()->send($xml, $this->port, $bOperation); if ($outMessage = $bOperation->getOutput()) { try { $retDoc = new XMLDom(); $retDoc->loadXMLStrict($response); } catch (\DOMException $e) { throw new \Exception("Wrong response, expected valid XML. Found '" . substr($response, 0, 2000) . "...'", 100, $e); } list($head, $body, $env) = $this->getEnvelopeParts($retDoc); $partsReturned = $this->decodeMessage($body, $bOperation, $outMessage); foreach ($partsReturned as $param) { if ($param instanceof SoapFault) { throw $param; } } // @todo configurazione per i metodi che ritornano piu parti if (count($partsReturned) == 1) { return reset($partsReturned); } elseif (count($partsReturned) == 0) { return null; } return $partsReturned; } }
public function handleServerError(\Exception $exception, Port $port) { $xml = new XMLDom(); $envelope = $xml->addChildNS(static::NS_ENVELOPE, $xml->getPrefixFor(static::NS_ENVELOPE) . ':Envelope'); $body = $envelope->addChildNS(static::NS_ENVELOPE, 'Body'); $fault = $body->addChildNS(static::NS_ENVELOPE, 'Fault'); $fault->addChild("faultcode", "soap:Server"); $fault->addChild("faultstring", get_class($exception) . ": " . $exception->getMessage() . "\n" . $exception); return $this->createResponse($xml->saveXML(), 500); }
public function testAdapt() { $a = new \DOMDocument("1.0", "UTF-8"); $a->load(__DIR__ . "/xml/no_ns.xml"); $obj = \goetas\xml\XMLDom::adapt($a); $this->assertTrue($obj instanceof \goetas\xml\XMLDom); $this->assertContains("<testsuites>", $obj->saveXML()); }
protected function getXML($path) { $tmpPath = sys_get_temp_dir() . "/wsdl" . md5($path) . ".xml"; $xml = new XMLDom(); if (!$this->options->cache || !is_file($tmpPath) || time() - $this->options->cache > filemtime($tmpPath)) { $cnt = file_get_contents($path); if ($cnt) { file_put_contents($tmpPath, $cnt); } } $xml->loadXMLStrictFile($tmpPath); $xml->documentURI = $path; return $xml; }
public function GetCityWeatherByZIP() { try { $this->proxy->GetCityWeatherByZIP(array("zip" => 30020)); } catch (\Exception $e) { } $xml = ' <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:weat="http://ws.cdyne.com/WeatherWS/"> <soap:Body> <weat:GetCityWeatherByZIP> <weat:ZIP>30020</weat:ZIP> </weat:GetCityWeatherByZIP> </soap:Body> </soap:Envelope> '; $this->assertEqualXML(XMLDom::loadXMLString($xml)->documentElement, $this->transport->getXmlNode()->documentElement); }
public function setUp() { $this->xml = new XMLDom(); $this->xml->loadXMLStrictFile(__DIR__ . "/xml/soap.xml"); }
/** * @return \goetas\xml\XMLDom */ public function getXmlNode() { $dom = new XMLDom(); $dom->loadXMLStrict($this->xml); return $dom; }