![]() |
Table of Contents
PHP SOAPIntroductionPHP SOAP is included with PHP 5 making it the simplest tool kit to set-up. Creating a Service ProxyFor SOAP services providing a WSDL document, a service proxy object can be generated from the WSDL at runtime, allowing access to the current service interface.
For example using the WSDbfetch service ( # URL for the service WSDL $wsdlUrl = 'http://www.ebi.ac.uk/ws/services/WSDbfetch?wsdl'; try { // Get a service proxy from the WSDL $proxy = new SoapClient($wsdlUrl); // Call a method on the service via the proxy $result = $proxy->fetchData('UNIPROT:ADH1A_HUMAN', 'fasta', 'raw'); echo $result; } catch(SoapFault $ex) { echo 'Error: '; if($ex->getMessage() != '') echo $ex->getMessage(); else echo $ex; echo "\n"; } Complex Types
The methods in the WSDbfetch all use simple string parameters. Many of the other EBI services use more complex input structures. For example WSWUBlast requires a structure containing the various parameters and the input sequence to be passed to the // Input parameters $params = array( 'email' => 'email@example.org', 'async' => TRUE, 'program' => 'blastp', 'database' => 'swissprot' ); // Input data $data = array( array( 'type' => 'sequence', 'content' => <<<EOF >Q8E5Q5_STRA3 MKLSKRYRFWQKVIKALGVLALIATLVLVVYLYKLGILNDSNELKDLVHKYEFWGPMIFI VAQIVQIVFPVIPGGVTTVAGFLIFGPTLGFIYNYIGIIIGSVILFWLVKFYGRKFVLLF MDQKTFDKYESKLETSGYEKFFIFCMASPISPADIMVMITGLSNMSIKRFVTIIMITKPI SIIGYSYLWIYGGDILKNFLN EOF ) ); // Submit the job $jobId = $proxy->runWUBlast($params, $data); echo "$jobId\n";
The // Poll till job finishes $status = 'PENDING'; while(strcmp($status, 'RUNNING') == 0 || strcmp($status, 'PENDING') == 0) { $status = $proxy->checkStatus($jobId); echo "$status\n"; if(strcmp($status, 'RUNNING') == 0 || strcmp(status, 'PENDING') == 0) { sleep(10); } } // Get the result $result = $proxy->poll($jobId, 'tooloutput'); echo $result; Sample ClientsMost SOAP Web Services at EMBL-EBI have sample clients which provide command-line access to the service and example code. For PHP some of the clients are based on PHP-SOAP. Document/literal SOAPRPC/encoded SOAP![]() |