cvs: presentations / soap-phpcon-ny2003.xml /slides/soap anatomyclient1.xml anatomyclient2.xml anatomyclient3.xml clientapi1.xml datatypemaps.xml
dispatchmaps.xml document2.xml document3.xml document4.xml headers2.xml proxygen.xml resources2.xml serverdisco.xml serverdisco2.xml
simpleclient-run.xml simpleclient2.xml soapslides.kpf wsdlclient.xml /slides/soap/examples client-babelfish-real.php example_server.php
example_types.php server.php

From: Date: Mon, 21 Apr 2003 07:26:14 +0000
Subject: cvs: presentations / soap-phpcon-ny2003.xml /slides/soap anatomyclient1.xml anatomyclient2.xml anatomyclient3.xml clientapi1.xml datatypemaps.xml
dispatchmaps.xml document2.xml document3.xml document4.xml headers2.xml proxygen.xml resources2.xml serverdisco.xml serverdisco2.xml
simpleclient-run.xml simpleclient2.xml soapslides.kpf wsdlclient.xml /slides/soap/examples client-babelfish-real.php example_server.php
example_types.php server.php
Groups: php.pres 
Request: Send a blank email to pres+get-637@lists.php.net to get a copy of this message
shane Mon Apr 21 03:26:14 2003 EDT Added files: /presentations/slides/soap datatypemaps.xml dispatchmaps.xml serverdisco.xml serverdisco2.xml /presentations/slides/soap/examples example_server.php example_types.php server.php Modified files: /presentations soap-phpcon-ny2003.xml /presentations/slides/soap anatomyclient1.xml anatomyclient2.xml anatomyclient3.xml clientapi1.xml document2.xml document3.xml document4.xml headers2.xml proxygen.xml resources2.xml simpleclient-run.xml simpleclient2.xml soapslides.kpf wsdlclient.xml /presentations/slides/soap/examples client-babelfish-real.php Log: more work

Index: presentations/soap-phpcon-ny2003.xml diff -u presentations/soap-phpcon-ny2003.xml:1.1 presentations/soap-phpcon-ny2003.xml:1.2 --- presentations/soap-phpcon-ny2003.xml:1.1 Sun Apr 20 15:58:12 2003 +++ presentations/soap-phpcon-ny2003.xml Mon Apr 21 03:26:13 2003 @@ -42,6 +42,7 @@ <slide x="xml schema part1">slides/soap/schema1-xml.xml</slide> <slide x="xml schema part2">slides/soap/schema2.xml</slide> <slide x="xml schema part2">slides/soap/schema2-xml.xml</slide> +<slide>slides/soap/soapobjects1.xml</slide> <slide x="xml schema summary">slides/soap/schemasummary.xml</slide> <slide x="wsdl description">slides/soap/wsdl.xml</slide> @@ -88,7 +89,6 @@ <slide>slides/soap/soapsmtp.xml</slide> -<slide>slides/soap/wsdlclient.xml</slide> <slide>slides/soap/proxygen.xml</slide> <slide>slides/soap/clientapi5.xml</slide> @@ -102,7 +102,10 @@ <slide>slides/soap/serverwsdl.xml</slide> -<slide>slides/soap/soapobjects1.xml</slide> +<slide>slides/soap/dispatchmaps.xml</slide> +<slide>slides/soap/datatypemaps.xml</slide> +<slide>slides/soap/serverdisco.xml</slide> +<slide>slides/soap/serverdisco2.xml</slide> <slide>slides/soap/soapresources.xml</slide> <slide>slides/soap/resources.xml</slide> Index: presentations/slides/soap/anatomyclient1.xml diff -u presentations/slides/soap/anatomyclient1.xml:1.1 presentations/slides/soap/anatomyclient1.xml:1.2 --- presentations/slides/soap/anatomyclient1.xml:1.1 Tue Oct 22 22:52:09 2002 +++ presentations/slides/soap/anatomyclient1.xml Mon Apr 21 03:26:13 2003 @@ -7,8 +7,8 @@ <example type="php" title="Generate the Client Proxy" fontsize='1.4em'> <![CDATA[<?php $wsdlurl = 'http://api.google.com/GoogleSearch.wsdl'; -$WSDL = new SOAP_WSDL($wsdlurl); -$client = $WSDL->getProxy(); +$WSDL =& new SOAP_WSDL($wsdlurl); +$client =& $WSDL->getProxy(); ?> ]]> </example> Index: presentations/slides/soap/anatomyclient2.xml diff -u presentations/slides/soap/anatomyclient2.xml:1.1 presentations/slides/soap/anatomyclient2.xml:1.2 --- presentations/slides/soap/anatomyclient2.xml:1.1 Tue Oct 22 22:52:09 2002 +++ presentations/slides/soap/anatomyclient2.xml Mon Apr 21 03:26:13 2003 @@ -7,29 +7,30 @@ <example type="php" title="Create the SOAP Client" fontsize='1.4em'> <![CDATA[<?php $endpoint = 'http://api.google.com/search/beta2'; -$client = new SOAP_Client($endpoint); +$client =& new SOAP_Client($endpoint); ?> ]]> </example> <example type="php" title="Prepare the Data" fontsize='1.4em'> <![CDATA[<?php -$key = new SOAP_Value('key','string','xxxx'); -$query = new SOAP_Value('q','string','Caraveo'); -$start = new SOAP_Value('start','int',0); -$maxResults = new SOAP_Value('maxResults','int',4); -$filter = new SOAP_Value('filter','boolean',false); -$restrict = new SOAP_Value('restrict','string',''); -$safeSearch = new SOAP_Value('safeSearch','boolean',false); -$lr = new SOAP_Value('lr','string',''); -$ie = new SOAP_Value('ie','string',''); -$oe = new SOAP_Value('oe','string',''); +$key =& new SOAP_Value('key','string','xxxx'); +$query =& new SOAP_Value('q','string','Caraveo'); +$start =& new SOAP_Value('start','int',0); +$maxResults =& new SOAP_Value('maxResults','int',4); +$filter =& new SOAP_Value('filter','boolean',false); +$restrict =& new SOAP_Value('restrict','string',''); +$safeSearch =& new SOAP_Value('safeSearch','boolean',false); +$lr =& new SOAP_Value('lr','string',''); +$ie =& new SOAP_Value('ie','string',''); +$oe =& new SOAP_Value('oe','string',''); ?> ]]> </example> <example type="php" title="Make the SOAP Call" fontsize='1.4em'> <![CDATA[<?php $response = $client->call('doGoogleSearch', - array($key,$query,$start,$maxResults, + $params = + array($key,$query,$start,$maxResults, $filter,$restrict,$safeSearch, $lr,$ie,$oe), array('namespace'=>'urn:GoogleSearch')); Index: presentations/slides/soap/anatomyclient3.xml diff -u presentations/slides/soap/anatomyclient3.xml:1.1 presentations/slides/soap/anatomyclient3.xml:1.2 --- presentations/slides/soap/anatomyclient3.xml:1.1 Tue Oct 22 22:52:09 2002 +++ presentations/slides/soap/anatomyclient3.xml Mon Apr 21 03:26:13 2003 @@ -7,7 +7,7 @@ <example type="php" title="Create the SOAP Client" fontsize='1.4em'> <![CDATA[<?php $endpoint = 'http://api.google.com/search/beta2'; -$client = new SOAP_Client($endpoint); +$client =& new SOAP_Client($endpoint); ?> ]]> </example> @@ -29,7 +29,7 @@ <example type="php" title="Make the SOAP Call" fontsize='1.4em'> <![CDATA[<?php $response = $client->call('doGoogleSearch', - array('key'=>$key, + $params = array('key'=>$key, 'q'=>$query, 'start'=>$start, 'maxResults'=>$maxResults, Index: presentations/slides/soap/clientapi1.xml diff -u presentations/slides/soap/clientapi1.xml:1.2 presentations/slides/soap/clientapi1.xml:1.3 --- presentations/slides/soap/clientapi1.xml:1.2 Wed Oct 23 03:27:04 2002 +++ presentations/slides/soap/clientapi1.xml Mon Apr 21 03:26:13 2003 @@ -10,7 +10,7 @@ <bullet>Arg 1 Required: String: WSDL or Endpoint URL</bullet> <bullet>Arg 2 Optional: Boolean: Is a WSDL URL? (false)</bullet> <bullet>Arg 3 Optional: String: Port Name (null)</bullet> -<bullet>Arg 4 Optional: Array: Proxy Settings (none)</bullet> +<bullet>Arg 4 Optional: Array: Proxy Settings (none) - necessary for WSDL proxy</bullet> </list> <list> <bullet>Method: call</bullet> @@ -36,6 +36,19 @@ <bullet>from (SMTP)</bullet> <bullet>transfer-encoding (SMTP, sets the Content-Transfer-Encoding)</bullet> <bullet>subject (SMTP, subject header)</bullet> +<bullet>CURL:</bullet> +</list> +<list marginleft="6em"> +<bullet>Any additional CURL options as avialable via the CURL extension.</bullet> +</list> +<list> + <bullet>Method: setOpt</bullet> +</list> +<list marginleft="2em"> +<bullet>Can be used to set options listed above.</bullet> +<bullet>Arg 1 Required: String: Category | Option</bullet> +<bullet>Arg 2 Required: String: Option | Value</bullet> +<bullet>Arg 3 Optional: String: Value</bullet> </list> <list> <bullet>Method: setEncoding</bullet> @@ -60,5 +73,11 @@ </list> <list marginleft="2em"> <bullet>Contains the received xml.</bullet> +</list> +<list> + <bullet>Other:</bullet> +</list> +<list marginleft="2em"> +<bullet>A bunch of undocumented members, some methods, that may change prior to 1.0</bullet> </list> </slide> Index: presentations/slides/soap/document2.xml diff -u presentations/slides/soap/document2.xml:1.2 presentations/slides/soap/document2.xml:1.3 --- presentations/slides/soap/document2.xml:1.2 Wed Jul 10 16:00:38 2002 +++ presentations/slides/soap/document2.xml Mon Apr 21 03:26:13 2003 @@ -1,5 +1,5 @@ <slide title="Document/Literal Example"> -<blurb>But the code to use RPC or Document style SOAP is +<blurb>The code to use RPC or Document style SOAP is practically the same! WSDL handles the details for you.</blurb> <example type="php" fontsize='1.4em' title='RPC/Encoded SOAP Call'> Index: presentations/slides/soap/document3.xml diff -u presentations/slides/soap/document3.xml:1.3 presentations/slides/soap/document3.xml:1.4 --- presentations/slides/soap/document3.xml:1.3 Wed Oct 23 03:27:04 2002 +++ presentations/slides/soap/document3.xml Mon Apr 21 03:26:13 2003 @@ -1,37 +1,25 @@ <slide title="Document/Literal Example"> <blurb>Document/Literal without WSDL possible also:</blurb> -<example type="php" fontsize='1.0em'> +<example type="php" result="1" fontsize='1.0em'> <![CDATA[<?php -require_once('SOAP/Client.php'); +include("SOAP/Client.php"); -$baseurl = "http://www.epionet.com/webservices/epiowebservices"; -$endpoint = 'http://www.epionet.com/epiowavewebservices/livecitycams/livecitycams.asp'; -$client = new SOAP_Client($endpoint); +$endpoint = 'http://mssoapinterop.org/stkv3/wsdl/interopTestDocLit.wsdl'; +$client =& new SOAP_Client($endpoint); -$result = $client->call("ListLiveCityCams", - NULL, - array('namespace' => $baseurl.'/livecitycams.wsdl', - 'soapaction' => $baseurl.'/livecitycams/listlivecitycams', - 'style' => 'document', - 'use' => 'literal')); - -if (PEAR::isError($result)) { - echo $result->getMessage(); - exit; -} - -print $client->wire; - -foreach($result as $citycam) { - $cam = $client->call("GetLiveCityCam", - array("citycamid" => $citycam->camid), - array('namespace'=> $baseurl.'/livecitycams.wsdl', - 'soapaction'=> $baseurl.'/livecitycams/getlivecitycam', - 'style' => 'document', - 'use' => 'literal')); - echo "$cam\n"; -} +$echoStringParam =& new SOAP_Value( + '{http://soapinterop.org/xsd}echoStringParam', + 'string','Hello World'); + +$return = $client->call("echoString", + $v = array("echoStringParam"=>$echoStringParam), + array('namespace'=>'http://soapinterop.org/WSDLInteropTestDocLit', + 'soapaction'=>'http://soapinterop.org/', + 'style'=>'document', + 'use'=>'literal' )); +print $return; ?>]]> </example> + </slide> Index: presentations/slides/soap/document4.xml diff -u presentations/slides/soap/document4.xml:1.2 presentations/slides/soap/document4.xml:1.3 --- presentations/slides/soap/document4.xml:1.2 Sat Dec 7 04:25:42 2002 +++ presentations/slides/soap/document4.xml Mon Apr 21 03:26:13 2003 @@ -1,5 +1,6 @@ <slide title="Document/Literal Key Points"> <list> +<bullet>Doc/Lit will become the defacto standard for Web Services</bullet> <bullet>Services typically support only RPC/Encoded OR Doc/Lit</bullet> <bullet>MS .Net defaults to Doc/Lit</bullet> <bullet>Doc/Lit is easier for dynamicaly typed langauges</bullet> @@ -7,16 +8,5 @@ <bullet>Literal encoding avoids some (de)serialization overhead</bullet> <bullet>PEAR::SOAP defaults to RPC/Encoded, you must set style and use</bullet> </list> -<example type="php" fontsize='1.3em'> -<![CDATA[<?php -$result = $client->call("ListLiveCityCams", - NULL, - array('namespace' => $baseurl.'/livecitycams.wsdl', - 'soapaction' => $baseurl.'/livecitycams/listlivecitycams', - 'style' => 'document', - 'use' => 'literal')); -?> -]]> -</example> </slide> Index: presentations/slides/soap/headers2.xml diff -u presentations/slides/soap/headers2.xml:1.2 presentations/slides/soap/headers2.xml:1.3 --- presentations/slides/soap/headers2.xml:1.2 Wed Jul 10 16:00:38 2002 +++ presentations/slides/soap/headers2.xml Mon Apr 21 03:26:13 2003 @@ -4,10 +4,10 @@ <![CDATA[<?php require_once('SOAP/Client.php'); -$client = new SOAP_Client( +$client =& new SOAP_Client( 'http://www.caraveo.com/soap_interop/server_round2.php'); -$header = new SOAP_Header( +$header =& new SOAP_Header( '{http://soapinterop.org/echoheader/}echoMeStringRequest', 'string', 'This is a test header', @@ -18,7 +18,7 @@ $client->addHeader($header); -$response = $client->call('echoVoid'); +$response = $client->call('echoVoid', $p = NULL); print $client->wire; ?>]]> </example> Index: presentations/slides/soap/proxygen.xml diff -u presentations/slides/soap/proxygen.xml:1.1 presentations/slides/soap/proxygen.xml:1.2 --- presentations/slides/soap/proxygen.xml:1.1 Wed Oct 23 03:27:04 2002 +++ presentations/slides/soap/proxygen.xml Mon Apr 21 03:26:13 2003 @@ -14,46 +14,61 @@ <![CDATA[<?php require_once('SOAP/Client.php'); -class WebService_GoogleSearchService extends SOAP_Client { - function WebService_GoogleSearchService() { - $this->SOAP_Client("http://api.google.com/search/beta2", 0); +class WebService_GoogleSearchService_GoogleSearchPort + extends SOAP_Client { + + function WebService_GoogleSearchService_GoogleSearchPort() + { + $this->SOAP_Client( + "http://api.google.com/search/beta2", 0); } + function doGetCachedPage($key, $url) { return $this->call("doGetCachedPage", - array("key"=>$key, "url"=>$url), + $v = array("key"=>$key, "url"=>$url), array('namespace'=>'urn:GoogleSearch', 'soapaction'=>'urn:GoogleSearchAction', 'style'=>'rpc', - 'use'=>'encoded')); + 'use'=>'encoded' )); } function doSpellingSuggestion($key, $phrase) { return $this->call("doSpellingSuggestion", - array("key"=>$key, "phrase"=>$phrase), + $v = array("key"=>$key, + "phrase"=>$phrase), array('namespace'=>'urn:GoogleSearch', 'soapaction'=>'urn:GoogleSearchAction', 'style'=>'rpc', - 'use'=>'encoded')); + 'use'=>'encoded' )); } - function doGoogleSearch($key, $q, $start, $maxResults, - $filter, $restrict, $safeSearch, - $lr, $ie, $oe) { + function doGoogleSearch($key, + $q, + $start, + $maxResults, + $filter, + $restrict, + $safeSearch, + $lr, + $ie, + $oe) { + return $this->call("doGoogleSearch", - array("key"=>$key, - "q"=>$q, - "start"=>$start, - "maxResults"=>$maxResults, - "filter"=>$filter, - "restrict"=>$restrict, - "safeSearch"=>$safeSearch, - "lr"=>$lr, - "ie"=>$ie, - "oe"=>$oe), + $v = array("key"=>$key, + "q"=>$q, + "start"=>$start, + "maxResults"=>$maxResults, + "filter"=>$filter, + "restrict"=>$restrict, + "safeSearch"=>$safeSearch, + "lr"=>$lr, + "ie"=>$ie, + "oe"=>$oe), array('namespace'=>'urn:GoogleSearch', 'soapaction'=>'urn:GoogleSearchAction', 'style'=>'rpc', - 'use'=>'encoded')); + 'use'=>'encoded' )); } } + ?> ]]> </example> Index: presentations/slides/soap/resources2.xml diff -u presentations/slides/soap/resources2.xml:1.1 presentations/slides/soap/resources2.xml:1.2 --- presentations/slides/soap/resources2.xml:1.1 Tue Aug 13 21:22:24 2002 +++ presentations/slides/soap/resources2.xml Mon Apr 21 03:26:13 2003 @@ -19,12 +19,7 @@ <list marginleft="2em"> <bullet>Large listing of public web services</bullet> </list> -<list> -<bullet>SOAPWare: www.soapware.com</bullet> -</list> -<list marginleft="2em"> -<bullet>Various Web Services resources, including SOAP implementations for other languages.</bullet> -</list> + <list> <bullet>SOAP Builders: http://groups.yahoo.com/group/soapbuilders/</bullet> </list> Index: presentations/slides/soap/simpleclient-run.xml diff -u presentations/slides/soap/simpleclient-run.xml:1.1 presentations/slides/soap/simpleclient-run.xml:1.2 --- presentations/slides/soap/simpleclient-run.xml:1.1 Sun Apr 20 15:58:12 2003 +++ presentations/slides/soap/simpleclient-run.xml Mon Apr 21 03:26:13 2003 @@ -19,11 +19,11 @@ <form action="$action" method=GET> Text: <input type="text" name="text" value="$text"> <select name="translation"> +<option value="en_es" SELECTED>English -> Spanish</option> <option value="en_de">English -> German</option> <option value="en_fr">English -> French</option> <option value="en_it">English -> Italian</option> <option value="en_pt">English -> Portugese</option> -<option value="en_es" SELECTED>English -> Spanish</option> <option value="fr_en">French -> English</option> <option value="it_en">German -> English</option> <option value="pt_en">Italian -> English</option> Index: presentations/slides/soap/simpleclient2.xml diff -u presentations/slides/soap/simpleclient2.xml:1.2 presentations/slides/soap/simpleclient2.xml:1.3 --- presentations/slides/soap/simpleclient2.xml:1.2 Sat Dec 7 04:25:42 2002 +++ presentations/slides/soap/simpleclient2.xml Mon Apr 21 03:26:13 2003 @@ -4,15 +4,16 @@ <![CDATA[<?php include("SOAP/Client.php"); -$soapclient = new SOAP_Client("http://localhost/server.php"); +$soapclient =& new SOAP_Client("http://localhost/server.php"); // this namespace is the same as declared in server.php $options = array('namespace' => 'urn:SOAP_Example_Server', 'trace' => 1); $ret = $soapclient->call("echoString", - array("inputString"=>"this is a test"), - $options); + $params = array("inputString"=> + "this is a test"), + $options); print_r($ret); ?> @@ -30,8 +31,8 @@ } } -$server = new SOAP_Server; -$soapclass = new SOAP_Example_Server(); +$server =& new SOAP_Server; +$soapclass =& new SOAP_Example_Server(); $server->addObjectMap($soapclass,'urn:SOAP_Example_Server'); $server->service($HTTP_RAW_POST_DATA); ?> Index: presentations/slides/soap/soapslides.kpf diff -u presentations/slides/soap/soapslides.kpf:1.5 presentations/slides/soap/soapslides.kpf:1.6 --- presentations/slides/soap/soapslides.kpf:1.5 Sun Apr 20 15:58:12 2003 +++ presentations/slides/soap/soapslides.kpf Mon Apr 21 03:26:13 2003 @@ -136,8 +136,6 @@ </file> <file name="wsdlclient.xml" url="wsdlclient.xml"> </file> -<file name="proxygen.xml" url="proxygen.xml"> -</file> <file name="clientapi5.xml" url="clientapi5.xml"> </file> <file name="simpleclient-run.xml" url="simpleclient-run.xml"> @@ -174,6 +172,16 @@ </file> <file name="uddi.xml" url="uddi.xml"> </file> +<file name="proxygen.xml" url="proxygen.xml"> +</file> +<file name="datatypemaps.xml" url="datatypemaps.xml"> +</file> +<file name="serverdisco2.xml" url="serverdisco2.xml"> +</file> +<file name="serverdisco.xml" url="serverdisco.xml"> +</file> +<file name="dispatchmaps.xml" url="dispatchmaps.xml"> +</file> </folder> <folder name="Faults"> <file name="serverfault.xml" url="serverfault.xml"> @@ -220,19 +228,19 @@ <folder name="real scripts"> <preference-set id=""> </preference-set> -<file name="client.php" url="client.php"> -</file> -<file name="example_server.php" url="example_server.php"> -</file> -<file name="example_types.php" url="example_types.php"> -</file> -<file name="server.php" url="server.php"> -</file> <file name="client-echostring-real.php" url="examples/client-echostring-real.php"> </file> <file name="client-echostring.php" url="examples/client-echostring.php"> </file> <file name="client-babelfish-real.php" url="examples/client-babelfish-real.php"> +<preference-set id=""> +</preference-set> +</file> +<file name="example_types.php" url="examples/example_types.php"> +</file> +<file name="example_server.php" url="examples/example_server.php"> +</file> +<file name="server.php" url="examples/server.php"> <preference-set id=""> </preference-set> </file> Index: presentations/slides/soap/wsdlclient.xml diff -u presentations/slides/soap/wsdlclient.xml:1.1 presentations/slides/soap/wsdlclient.xml:1.2 --- presentations/slides/soap/wsdlclient.xml:1.1 Wed Oct 23 03:27:04 2002 +++ presentations/slides/soap/wsdlclient.xml Mon Apr 21 03:26:13 2003 @@ -5,8 +5,8 @@ require_once('SOAP/Client.php'); $wsdlurl = 'http://api.google.com/GoogleSearch.wsdl'; -$WSDL = new SOAP_WSDL($wsdlurl); -$client = $WSDL->getProxy(); +$WSDL =& new SOAP_WSDL($wsdlurl); +$client =& $WSDL->getProxy(); $response = $client->doGoogleSearch( @@ -21,12 +21,13 @@ ?> ]]> </example> +<blurb>Overload does not work with PHP 4.3.x, and still has issues in PHP 5 cvs.</blurb> <example type="php" title="Using SOAP_Client and Overload" fontsize='1.4em'> <![CDATA[<?php require_once('SOAP/Client.php'); $wsdlurl = 'http://api.google.com/GoogleSearch.wsdl'; -$client = new SOAP_Client($wsdlurl,1); +$client =& new SOAP_Client($wsdlurl,1); $response = $client->doGoogleSearch( Index: presentations/slides/soap/examples/client-babelfish-real.php diff -u presentations/slides/soap/examples/client-babelfish-real.php:1.1 presentations/slides/soap/examples/client-babelfish-real.php:1.2 --- presentations/slides/soap/examples/client-babelfish-real.php:1.1 Sun Apr 20 15:58:12 2003 +++ presentations/slides/soap/examples/client-babelfish-real.php Mon Apr 21 03:26:13 2003 @@ -7,7 +7,7 @@ $time = time()-(3*60*60); $default = "It's ".date('g:i A',$time)." in Vancouver, thank God for Coffee!"; $text = isset($_GET['text'])?$_GET['text']:$default; -$trans = isset($_GET['translation'])?$_GET['translation']:'en_it'; +$trans = isset($_GET['translation'])?$_GET['translation']:'en_es'; $soapclient->setOpt('trace',1); $ret = $soapclient->BabelFish($trans,$text); Index: presentations/slides/soap/datatypemaps.xml +++ presentations/slides/soap/datatypemaps.xml <slide title="Data Type Maps"> <blurb>To include Schema for complex data types, you must define the data type map in your classes. </blurb> <list title="Data Type Map"> <bullet>The key is the data type name and namespace</bullet> <bullet>The value is a *structure* that will be mapped into schema. This can be an arbitrarily complex set of array's to define the data object.</bullet> </list> <example title="Dispatch Map Example" type="php" fontsize='1.4em'> <![CDATA[<?php $this->__typedef['{http://soapinterop.org/xsd}SOAPStruct'] = array( 'varString' => 'string', 'varInt' => 'int', 'varFloat' => 'float' ); $this->__typedef['{http://soapinterop.org/xsd}SOAPStructArray'] = array( array( 'item'=>'{http://soapinterop.org/xsd}SOAPStruct' ) ); ?>]]> </example> <example title="Schema Generated" type="xml" fontsize='1.4em'> <![CDATA[<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> <complexType name="SOAPStructArray"> <complexContent> <restriction base="SOAP-ENC:Array"> <attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="ns5:SOAPStruct[]" /> </restriction> </complexContent> </complexType> </schema>]]> </example> </slide> Index: presentations/slides/soap/dispatchmaps.xml +++ presentations/slides/soap/dispatchmaps.xml <slide title="Dispatch Maps"> <blurb>To aid in generating WSDL, you must provide a bunch of detailed information about your service. This is done via the *dispatch map* and the *data type map*.</blurb> <list> <bullet>Normally, all object methods are SOAP accessable (except _name)</bullet> <bullet>The dispactch map does not need to be used, but aids the server class in knowing what parameters are used with the functions</bullet> <bullet>For multiple OUT parameters, you MUST use the dispatch mapping</bullet> <bullet>If you use dispatch mapping, you MUST have a map for each SOAP function</bullet> </list> <list title="Dispatch Keys"> <bullet>IN: An array of IN parameters for the method</bullet> <bullet>OUT: An array of OUT parameters for the method</bullet> <bullet>ALIAS: Can be used to specify a PHP function to handle the SOAP call (usefull for handling SOAP calls that use PHP keywords)</bullet> </list> <example title="Dispatch Map Example" type="php" fontsize='1.4em' > <![CDATA[<?php $this->__dispatch_map['echoStructAsSimpleTypes'] = array( 'in' => array('inputStruct' => '{http://soapinterop.org/xsd}SOAPStruct'), 'out' => array('outputString' => 'string', 'outputInteger' => 'int', 'outputFloat' => 'float'), 'alias' => 'myEchoStructAsSimpleTypes' ); $this->__dispatch_map['echoStringSimple'] = array( 'in' => array('inputStringSimple' => 'string'), 'out' => array('outputStringSimple' => 'string'), ); ?>]]> </example> </slide> Index: presentations/slides/soap/serverdisco.xml +++ presentations/slides/soap/serverdisco.xml <slide title="Server Generated WSDL"> <blurb>PEAR::SOAP now can generate WSDL for you.</blurb> <blurb>The first part is setting up the basic logic to choose whether you process SOAP, or generate DISCO or WSDL output.</blurb> <example title="Disco Server Example" filename="examples\server.php" type="php" fontsize='1.4em' /> </slide> Index: presentations/slides/soap/serverdisco2.xml +++ presentations/slides/soap/serverdisco2.xml <slide title="Server Generated WSDL"> <blurb>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.</blurb> <list> <bullet>Normally, all object methods are SOAP accessable (except _name)</bullet> <bullet>The dispactch map does not need to be used, but aids the server class in knowing what parameters are used with the functions</bullet> <bullet>For multiple OUT parameters, you MUST use the dispatch mapping</bullet> <bullet>If you use dispatch mapping, you MUST have a map for each SOAP function</bullet> <bullet></bullet> <bullet></bullet> </list> <example title="Disco Server Example" filename="examples\example_server_small.php" type="php" fontsize='1.4em' /> <example title="WSDL Generated" type="xml" fontsize='1.4em'> <![CDATA[<?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>]]> </example> </slide> Index: presentations/slides/soap/examples/example_server.php +++ presentations/slides/soap/examples/example_server.php <?php require_once 'SOAP/Value.php'; require_once 'SOAP/Fault.php'; // SOAPStruct is defined in the following file require_once './example_types.php'; // create a class for your soap functions class SOAP_Example_Server { /** * The dispactch map does not need to be used, but aids * the server class in knowing what parameters are used * with the functions. This is the ONLY way to have * multiple OUT parameters. If you use a dispatch map, you * MUST add ALL functions you wish to allow be called. If * you do not use a dispatch map, then any public function * can be called from soap (in php4, we consider this to be * any function in the class unless it starts with underscore, * php5 support is not complete yet in this regard). * if you do not define in/out parameters, the function can be * called with parameters, but no validation on parameters will * occure. */ var $__dispatch_map = array(); var $__typedef = array(); function SOAP_Example_Server() { /** * when generating wsdl for a server, you have to define * any special complex types that you use (ie classes). * using a namespace id before the type will create an * xml schema with the targetNamespace for the type * multiple types with the same namespace will appear * in the same schema section. types with different * namespaces will be in seperate schema sections. * the following SOAPStruct typedef cooresponds to the * SOAPStruct class above. */ $this->__typedef['{http://soapinterop.org/xsd}SOAPStruct'] = array( 'varString' => 'string', 'varInt' => 'int', 'varFloat' => 'float' ); $this->__typedef['{http://soapinterop.org/xsd}SOAPStructArray'] = array( array( 'item' => '{http://soapinterop.org/xsd}SOAPStruct' ) ); // an aliased function with multiple out parameters $this->__dispatch_map['echoStructAsSimpleTypes'] = array('in' => array('inputStruct' => '{http://soapinterop.org/xsd}SOAPStruct'), 'out' => array('outputString' => 'string', 'outputInteger' => 'int', 'outputFloat' => 'float'), 'alias' => 'myEchoStructAsSimpleTypes' ); $this->__dispatch_map['echoStringSimple'] = array('in' => array('inputStringSimple' => 'string'), 'out' => array('outputStringSimple' => 'string'), ); $this->__dispatch_map['echoString'] = array('in' => array('inputString' => 'string'), 'out' => array('outputString' => 'string'), ); $this->__dispatch_map['divide'] = array('in' => array('dividend' => 'int', 'divisor' => 'int'), 'out' => array('outputFloat' => 'float'), ); $this->__dispatch_map['echoStruct'] = array('in' => array('inputStruct' => '{http://soapinterop.org/xsd}SOAPStruct'), 'out' => array('outputStruct' => '{http://soapinterop.org/xsd}SOAPStruct'), ); } /* this private function is called on by SOAP_Server to determine any special dispatch information that might be necessary. This, for example, can be used to set up a dispatch map for functions that return multiple OUT parameters */ function __dispatch($methodname) { if (isset($this->__dispatch_map[$methodname])) return $this->__dispatch_map[$methodname]; return NULL; } // a simple echoString function function echoStringSimple($inputString) { return $inputString; } // an explicit echostring function function echoString($inputString) { return new SOAP_Value('outputString','string',$inputString); } function divide($dividend, $divisor) { // the soap server would normally catch errors like this // and return a fault, but this is how you do it yourself. if ($divisor == 0) return new SOAP_Fault('You cannot divide by zero', 'Client'); else return $dividend / $divisor; } function echoStruct($inputStruct) { return $inputStruct->__to_soap('outputStruct'); #return new SOAP_Value('outputStruct','{http://soapinterop.org/xsd}SOAPStruct',$inputStruct); } /** * echoStructAsSimpleTypes * takes a SOAPStruct as input, and returns each of its elements * as OUT parameters * * this function is also aliased so you have to call it with * echoStructAsSimpleTypes * * SOAPStruct is defined as: * * struct SOAPStruct: * string varString * integer varInt * float varFloat * */ function myEchoStructAsSimpleTypes($struct) { # convert a SOAPStruct to an array return array( new SOAP_Value('outputString','string',$struct->varString), new SOAP_Value('outputInteger','int',$struct->varInt), new SOAP_Value('outputFloat','float',$struct->varFloat) ); } } ?> Index: presentations/slides/soap/examples/example_types.php +++ presentations/slides/soap/examples/example_types.php <?php /* * this is a data type that is used in SOAP Interop testing, but is * here as an example of using complex types. When the class is * deserialized from a SOAP message, it's constructor IS NOT CALLED! * So your type classes need to behave in a way that will work * with that. * * Some types may need more explicit serialization for SOAP. The * __to_soap function allows you to be very explicit in building the * SOAP_Value structures. The soap library does not call this directly, * you would call it from your soap server class, echoStruct in the server * class is an example of doing this. */ class SOAPStruct { var $varString; var $varInt; var $varFloat; function SOAPStruct($s=NULL, $i=NULL, $f=NULL) { $this->varString = $s; $this->varInt = $i; $this->varFloat = $f; } function &__to_soap($name = 'inputStruct', $header=false, $mustUnderstand=0, $actor='http://schemas.xmlsoap.org/soap/actor/next') { $inner[] =& new SOAP_Value('varString','string',$this->varString); $inner[] =& new SOAP_Value('varInt','int',$this->varInt); $inner[] =& new SOAP_Value('varFloat','float',$this->varFloat); if ($header) { return new SOAP_Header($name,'{http://soapinterop.org/xsd}SOAPStruct',$inner,$mustUnderstand,$actor); } return new SOAP_Value($name,'{http://soapinterop.org/xsd}SOAPStruct',$inner); } } ?> Index: presentations/slides/soap/examples/server.php +++ presentations/slides/soap/examples/server.php <?php require_once 'SOAP/Server.php'; $server =& new SOAP_Server; /* tell server to translate to classes we provide if possible */ $server->_auto_translation = true; require_once './example_server.php'; $soapclass =& new SOAP_Example_Server(); $server->addObjectMap($soapclass,'urn:SOAP_Example_Server'); if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD']=='POST') { $server->service($HTTP_RAW_POST_DATA); } else { require_once 'SOAP/Disco.php'; $disco = new SOAP_DISCO_Server($server,'ServerExample'); echo $disco->getWSDL(); return; header("Content-type: text/xml"); if (isset($_SERVER['QUERY_STRING']) && strcasecmp($_SERVER['QUERY_STRING'],'wsdl')==0) { echo $disco->getWSDL(); } else { echo $disco->getDISCO(); } exit; } ?>
« previous php.pres (#637) next »