The next step is to provide data in your
server classes that can be used to generate
Schema and WSDL. We do this by filling out the
dispatch mapping and data types.
- • Normally, all object methods are SOAP accessable (except _name)
- • The dispactch map does not need to be used, but aids
the server class in knowing what parameters are used
with the functions
- • For multiple OUT parameters, you MUST use the dispatch mapping
- • If you use dispatch mapping, you MUST have a map for each SOAP function
- •
- •
Disco Server Example
<?php
require_once 'SOAP/Value.php';
require_once 'SOAP/Fault.php';
require_once './example_types.php';
class SOAP_Example_Server {
var $__dispatch_map = array();
var $__typedef = array();
function SOAP_Example_Server() {
$this->__typedef['{http://soapinterop.org/xsd}SOAPStruct'] =
array(
'varString' => 'string',
'varInt' => 'int',
'varFloat' => 'float'
);
$this->__dispatch_map['echoStruct'] =
array(
'in' => array('inputStruct' =>
'{http://soapinterop.org/xsd}SOAPStruct'),
'out' => array('outputStruct' =>
'{http://soapinterop.org/xsd}SOAPStruct'),
);
}
function __dispatch($methodname) {
if (isset($this->__dispatch_map[$methodname]))
return $this->__dispatch_map[$methodname];
return NULL;
}
function echoStruct($inputStruct)
{
return $inputStruct->__to_soap('outputStruct');
}
}
?>
WSDL Generated
<?xml version="1.0"?>
<definitions name="ServerExample"
targetNamespace="urn:ServerExample"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="urn:ServerExample"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:ns5="http://soapinterop.org/xsd">
<types xmlns="http://schemas.xmlsoap.org/wsdl/">
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://soapinterop.org/xsd">
<complexType name="SOAPStruct">
<all>
<element name="varString" type="xsd:string" />
<element name="varInt" type="xsd:int" />
<element name="varFloat" type="xsd:float" />
</all>
</complexType>
</schema>
</types>
<message name="echoStructRequest">
<part name="inputStruct" type="ns5:SOAPStruct" />
</message>
<message name="echoStructResponse">
<part name="outputStruct" type="ns5:SOAPStruct" />
</message>
<portType name="ServerExamplePort">
<operation name="echoStruct">
<input message="tns:echoStructRequest" />
<output message="tns:echoStructResponse" />
</operation>
</portType>
<binding name="ServerExampleBinding" type="tns:ServerExamplePort">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/wsdl/http/" />
<operation name="echoStruct">
<soap:operation
soapAction="urn:SOAP_Example_Server#soap_example_server#echoStruct" />
<input>
<soap:body
use="encoded"
namespace="urn:SOAP_Example_Server"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body use="encoded"
namespace="urn:SOAP_Example_Server"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
<service name="ServerExampleService">
<documentation />
<port name="ServerExamplePort"
binding="tns:ServerExampleBinding">
<soap:address
location="http://localhost/pres2/presentations/slides/soap/examples/server.php" />
</port>
</service>
</definitions>