- encoding is always utf-8

- add missing location property
- consider domdocument for get/setContent
This commit is contained in:
Andreas Schamberger 2011-12-17 13:45:18 +01:00
parent 7fab5be555
commit 099c1542a9
1 changed files with 38 additions and 23 deletions

View File

@ -22,18 +22,17 @@ abstract class SoapMessage
const ACTION_HEADER = 'HTTP_SOAPACTION'; const ACTION_HEADER = 'HTTP_SOAPACTION';
static protected $versionToContentTypeMap = array( static protected $versionToContentTypeMap = array(
SOAP_1_1 => 'text/xml; charset=%s', SOAP_1_1 => 'text/xml; charset=utf-8',
SOAP_1_2 => 'application/soap+xml; charset=%s' SOAP_1_2 => 'application/soap+xml; charset=utf-8'
); );
static public function getContentTypeForVersion($version, $encoding = 'utf-8') static public function getContentTypeForVersion($version)
{
if(!in_array($soapVersion, array(SOAP_1_1, SOAP_1_2)))
{ {
if(!in_array($soapVersion, array(SOAP_1_1, SOAP_1_2))) {
throw new \InvalidArgumentException("The 'version' argument has to be either 'SOAP_1_1' or 'SOAP_1_2'!"); throw new \InvalidArgumentException("The 'version' argument has to be either 'SOAP_1_1' or 'SOAP_1_2'!");
} }
return sprintf(self::$versionToContentTypeMap[$version], $encoding); return self::$versionToContentTypeMap[$version];
} }
protected $contentType; protected $contentType;
@ -43,6 +42,7 @@ abstract class SoapMessage
protected $version; protected $version;
protected $action; protected $action;
protected $location;
public function getContentType() public function getContentType()
{ {
@ -56,18 +56,23 @@ abstract class SoapMessage
public function getContent() public function getContent()
{ {
if (null !== $this->contentDomDocument) {
$this->content = $this->contentDomDocument->saveXML();
}
return $this->content; return $this->content;
} }
public function setContent($content) public function setContent($content)
{ {
$this->content = $content; $this->content = $content;
if (null !== $this->contentDomDocument) {
$this->contentDomDocument->loadXML($this->content);
}
} }
public function getContentDocument() public function getContentDocument()
{ {
if(null === $this->contentDomDocument) if (null === $this->contentDomDocument) {
{
$this->contentDomDocument = new \DOMDocument(); $this->contentDomDocument = new \DOMDocument();
$this->contentDomDocument->loadXML($this->content); $this->contentDomDocument->loadXML($this->content);
} }
@ -94,4 +99,14 @@ abstract class SoapMessage
{ {
$this->action = $action; $this->action = $action;
} }
public function getLocation()
{
return $this->location;
}
public function setLocation($location)
{
$this->location = $location;
}
} }