summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwei <>2007-01-12 06:27:16 +0000
committerwei <>2007-01-12 06:27:16 +0000
commit6626a5498df1e9231c6711544d69e93feebfec21 (patch)
tree366f9ece6a5955e7485bc36c6cee11f0ae3e6992
parent121e88c87ba310f03d4587bd68c6cf4b7b7ea2b8 (diff)
simplify class maps in soap server
-rw-r--r--demos/quickstart/protected/pages/Services/SoapService.page28
-rw-r--r--framework/Web/Services/TSoapService.php25
2 files changed, 39 insertions, 14 deletions
diff --git a/demos/quickstart/protected/pages/Services/SoapService.page b/demos/quickstart/protected/pages/Services/SoapService.page
index 04dea07a..4a83c8ed 100644
--- a/demos/quickstart/protected/pages/Services/SoapService.page
+++ b/demos/quickstart/protected/pages/Services/SoapService.page
@@ -129,7 +129,33 @@ The tool requires a MS .NET runtime to be installed.
</div>
<p>
-<tt>TSoapService</tt> may be configured and customized in several ways. In the example above, the &lt;soap&gt; element actually specifies a SOAP service using the default <tt>TSoapServer</tt> implementation. Attributes in &lt;soap&gt; are passed to <tt>TSoapServer</tt> as its initial property values. For example, the <tt>provider</tt> attribute initializes the <tt>Provider</tt> property of <tt>TSoapServer</tt>. By setting <tt>SessionPersistent</tt> to be true in &lt;soap&gt; element, the provider instance will persist within the user session. You may develop your own SOAP server class and use it by specifying the <tt>class</tt> attribute of &lt;soap&gt;.
+<tt>TSoapService</tt> may be configured and customized in several ways. In the example above, the <tt>&lt;soap&gt;</tt> element actually specifies a SOAP service using the default <tt>TSoapServer</tt> implementation. Attributes in <tt>&lt;soap&gt;</tt> are passed to <tt>TSoapServer</tt> as its initial property values. For example, the <tt>provider</tt> attribute initializes the <tt>Provider</tt> property of <tt>TSoapServer</tt>. By setting <tt>SessionPersistent</tt> to be true in <tt>&lt;soap&gt;</tt> element, the provider instance will persist within the user session. You may develop your own SOAP server class and use it by specifying the <tt>class</tt> attribute of <tt>&lt;soap&gt;</tt>.
+</p>
+
+<p>By default, PHP's soap server will create objects of the type <tt>StdClass</tt>
+when objects are received from the client. The soap server can be configured to
+automatically create objects of certain type objects are received as method
+parameters. For example, if we have a Soap method that accepts
+a <tt>Contact</tt> object as parameter.
+<com:TTextHighlighter Language="php" CssClass="source">
+/**
+ * @param Contact $contact
+ * @return boolean true if saved, false otherwise
+ * @soapmethod
+ */
+ function save(Contact $contact)
+ {
+ return true
+ }
+</com:TTextHighlighter>
+The do this, we need to set the <tt>ClassMaps</tt> property of
+the <tt>TSoapServer</tt> in the <tt>&lt;soap&gt;</tt> tags as
+a comma separated string of class names that we wish to be automatically
+converted.
+<com:TTextHighlighter Language="xml" CssClass="source">
+<soap id="contact-manager" provider="path.to.ContactManager"
+ ClassMaps="Contact, Address"/>
+</com:TTextHighlighter>
</p>
</com:TContent> \ No newline at end of file
diff --git a/framework/Web/Services/TSoapService.php b/framework/Web/Services/TSoapService.php
index 69f133fe..1472ffc4 100644
--- a/framework/Web/Services/TSoapService.php
+++ b/framework/Web/Services/TSoapService.php
@@ -289,15 +289,6 @@ class TSoapServer extends TApplicationComponent
private $_wsdlUri='';
/**
- * Constructor.
- * It creates the classmap object.
- */
- public function __construct()
- {
- $this->_classMap=new TAttributeCollection;
- }
-
- /**
* @return string the ID of the SOAP server
*/
public function getID()
@@ -368,9 +359,9 @@ class TSoapServer extends TApplicationComponent
$options['encoding']=$this->_encoding;
if(!empty($this->_uri))
$options['uri']=$this->_uri;
- if($this->_classMap->getCount()>0)
+ if(is_string($this->_classMap))
{
- foreach($this->_classMap as $className)
+ foreach(preg_split('/\s?,\s?/', $this->_classMap) as $className)
$options['classmap'][$className]=$className; //complex type uses the class name in the wsdl
}
return $options;
@@ -533,12 +524,20 @@ class TSoapServer extends TApplicationComponent
}
/**
- * @return TAttributeCollection the class map for the SOAP service
+ * @return string comma delimit list of complex type classes.
*/
- public function getClassMap()
+ public function getClassMaps()
{
return $this->_classMap;
}
+
+ /**
+ * @return string comma delimit list of class names
+ */
+ public function setClassMaps($classes)
+ {
+ $this->_classMap = $classes;
+ }
}
?> \ No newline at end of file